cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1X Sensor VL53L0X_StaticInit() failing

Kpodu.1
Associate II

While implementing the middleware for vl53l0x I am facing the following problem. Can you please let me know what mistake am I making 

“please see the commands in bold�?

       tofDev->I2cDevAddr = VL53L0X_I2C_ADDR //0x52;

       tofDev->comms_type = I2C ;

       tofDev->comms_speed_khz = VL53L0X_I2C_SPEED // 100;

       VL53L0X_Error ret = VL53L0X_DataInit(tofDev);   //succeding

       if(ret!= VL53L0X_ERROR_NONE)

       {

              logErr("data init failed");

              return -1;

       }

       ret = VL53L0X_GetDeviceInfo(tofDev ,DeviceInfo); //succeding

       if(ret!= VL53L0X_ERROR_NONE)

       {

              logErr("unable to get device info");

       }

       ret = VL53L0X_StaticInit(tofDev); //failing

       if(ret!= VL53L0X_ERROR_NONE)

       {

              logErr("static init failed");

              //return -1;

       }

The static init function is failing at the below 

VL53L0X_Error VL53L0X_measurement_poll_for_completion(VL53L0X_DEV Dev)

{

       VL53L0X_Error Status = VL53L0X_ERROR_NONE;

       uint8_t NewDataReady = 0;

       uint32_t LoopNb;

      LOG_FUNCTION_START("");

      LoopNb = 0;

       do {

             Status = VL53L0X_GetMeasurementDataReady(Dev, &NewDataReady);

              if (Status != 0)

                     break; /* the error is set */

              if (NewDataReady == 1)

                     break; /* done note that status == 0 */

             LoopNb++;

              if (LoopNb >= VL53L0X_DEFAULT_MAX_LOOP) {

                    Status = VL53L0X_ERROR_TIME_OUT;    <- Here it is failing. Timeout 

                     break;

             }

             VL53L0X_PollingDelay(Dev);

      } while (1);

      LOG_FUNCTION_END(Status);

       return Status;

}

The implementation of VL53L0X_PollingDelay(Dev); is as below

VL53L0X_Error VL53L0X_PollingDelay(VL53L0X_DEV Dev){

   VL53L0X_Error status = VL53L0X_ERROR_NONE;

  LOG_FUNCTION_START("");

   HAL_Delay(1);

//   const DWORD cTimeout_ms = 1;

//  HANDLE hEvent = CreateEvent(0, TRUE, FALSE, 0);

//  if(hEvent != NULL)

//  {

//    WaitForSingleObject(hEvent,cTimeout_ms);

//  }

  LOG_FUNCTION_END(status);

   return status;

}

I think the platform layer I2C integration must be fine because data init….get device info seems to be working….even setbudget functions as well are working. 

I am still not understanding what issue is this about.

Any help is highly appreciated.

Thanks,

Krishna

0 REPLIES 0