cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L3CX API : WaitDeviceBooted returns 1??

Ben1
Associate III

Hi everyone. I try to integrate VL53L3CX range sensor in an applicaction using nRF microcontrollers. I am using the API 1.1.4. I would like to test a I2C read first, so I edited the function VL53LX_ReadMulti() in file vl53lx_platform.c as follow :

VL53LX_Error VL53LX_ReadMulti(
	VL53LX_Dev_t *pdev,
	uint16_t      index,
	uint8_t      *pdata,
	uint32_t      count)
{
	VL53LX_Error status         = VL53LX_ERROR_NONE;
	uint8_t *pBuffer = pdata;
	//uint8_t DevAddr = pdev->I2cDevAddr;
 
	status = (int8_t)bus_i2c_ReadData( pdev->i2c_slave_address, pdata, pdev->i2c_slave_address|1, count);
 
	return status;
}

The function I have to use is implemented as follow :

/**
  * @brief  Reads Data from I2C communication bus.
  * @param[in] DevAddr: Device address.
  * @param[out] pBuffer: pointer to the buffer that receives the data read from the Device.
  * @param[in] ReadAddr: Device's internal address to start reading from.
  * @param[in] DataSize: number of bytes to read.
  * @retval ret_code_t: NRF_SUCCESS (0) if operation is correctly performed, else return value different from NRF_SUCCESS (0).
  */
ret_code_t bus_i2c_ReadData(uint8_t DevAddr, uint8_t * pBuffer, uint8_t ReadAddr, size_t DataSize)
{
	ret_code_t ret;
	uint8_t addr8 = (uint8_t)ReadAddr;
 
	do
	{
		ret = nrf_drv_twi_tx(&I2C_drv, DevAddr, &addr8, 2, true);
		if (NRF_SUCCESS != ret)
			break;
		ret = nrf_drv_twi_rx(&I2C_drv, DevAddr, pBuffer, DataSize);
		debug_uart_printf("ret = 0x%x \n\r", ret);
	} while(0);
 
	debug_uart_printf("ret = 0x%x \n\r", ret);
	return ret;
}

And my main is :

#include "system.h"
#include "hardware.h"
#include "vl53lx_api.h"
#include "bus_i2c_drv.h"
#include "debug_uart_nrf52.h"
#include "nrf_delay.h"
 
 
/**@brief Application main function.
 */
 
VL53LX_Dev_t                   dev;
VL53LX_DEV                     Dev = &dev;
VL53LX_Error status=0;
volatile int IntCount;
 
int main(void)
{
	uint8_t byteData;
	uint16_t wordData;
	uint8_t ToFSensor = 1; // 0=Left, 1=Center(default), 2=Right
	VL53LX_MultiRangingData_t MultiRangingData;
	VL53LX_MultiRangingData_t *pMultiRangingData = &MultiRangingData;
	uint8_t NewDataReady=0;
	int no_of_object_found=0,j;
	// Initialize.
	hardware_IO_init();
	debug_uart_init();
 
	Dev->i2c_slave_address = 0X52;
	bus_i2c_Init();
 
 
    // Enter main loop.
    for (;;)
    {
 
    	hardware_set_pin(PIN_PWR_SENS2); // VDD VL53L3
    	hardware_set_pin(PIN_PWR_SENS); // Pull-up i2c
    	status=VL53LX_WaitDeviceBooted(Dev);
    	debug_uart_printf("Status = %d \n\r", status);
    	nrf_delay_ms(2);
    	status = 0;
 
    	VL53LX_RdByte(Dev, 0x010F, &byteData);
 
    	nrf_delay_ms(1000);
    }
}

I use VL53LX_RdByte() according to the STM32F401RE example because I know which value must be returned. However, the nrf returns a NACK after VL53LX_RdByte(). So I checked the status value returned from the function WaitDeviceBooted(Dev), and it seems the function return 1 :

0693W00000593ZqQAI.pngConfirmed by frame analysis :

0693W00000593ZgQAI.pngHow is that possible? I see in vl53lx_error_codes.h that there is no error code equal to 1. All error codes are signed interger, and negative numbers. Power supply around 3V (battery) and is fine. XSHUT in is directly wired to VDD because I don't want to handle hardware standby mode. Is there something I miss? Thank you for your help!

1 REPLY 1
Ben1
Associate III

UPDATE : the issue was solved by itself, Thank you