cancel
Showing results for 
Search instead for 
Did you mean: 

The APIs for VL53L5CX sensors in the X-CUBE-TOF1 are different from the ULD API for VL53L5CX?

VNava.1
Associate III
 
1 ACCEPTED SOLUTION

Accepted Solutions
John E KVAM
ST Employee

There is only one driver for the VL53L5CX. They should be the same.


If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.

View solution in original post

5 REPLIES 5
John E KVAM
ST Employee

The files should be the same, but there might have been modifications to comply with the X-CUBE format. Can you give me some examples of different code?

  • john

If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
VNava.1
Associate III

Thank you for the answer. Sorry, I put the question wrong. I wanted to know if the API used in the X-CUBE-TOF1 examples was different from the one used in the ULD driver examples. The doubt arises from the fact that for some sensors (VL53L1X) a "Full" version and an Ultra Lite version were available, so I was wondering if maybe this difference could exist also in the case of the VL53L5CX

John E KVAM
ST Employee

There is only one driver for the VL53L5CX. They should be the same.


If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
VNava.1
Associate III

Hi @John E KVAM​ ,

related to the VL53L5CX API in the X-CUBE-TOF1 package, I saw that effectively are the same as the ULD driver for VL53L5CX. I don't understand in which way they are used in the X-CUBE-TOF1 package. I will try to explain my doubt.

Trying to study the CUSTOM application for F401RE in this package I was not able to see the "link" between the structure RANGING_SENSOR_Drv_t

typedef struct
{
  int32_t (*Init)(void *);
  int32_t (*DeInit)(void *);
  int32_t (*ReadID)(void *, uint32_t *);
  int32_t (*GetCapabilities)(void *, void *);
  int32_t (*ConfigProfile)(void *, void *);
  int32_t (*ConfigROI)(void *, void *);
  int32_t (*ConfigIT)(void *, void *);
  int32_t (*GetDistance)(void *, void *);
  int32_t (*Start)(void *, uint8_t);
  int32_t (*Stop)(void *);
  int32_t (*SetAddress)(void *, uint16_t);
  int32_t (*GetAddress)(void *, uint16_t *);
  int32_t (*SetPowerMode)(void *, uint32_t);
  int32_t (*GetPowerMode)(void *, uint32_t *);
} RANGING_SENSOR_Drv_t;

and the various function defined in the ultra-lite driver files. But when I go in debug mode I see that effectively this structure is linked to the ULD. For example, the field "Init" is linked to the function:

int32_t VL53L5CX_Init(VL53L5CX_Object_t *pObj)
{
  int32_t ret;
 
  if (pObj == NULL)
  {
    ret = VL53L5CX_INVALID_PARAM;
  }
  else if (pObj->IsInitialized != 0U)
  {
    ret =  VL53L5CX_ERROR;
  }
  else if (vl53l5cx_init(&pObj->Dev) != VL53L5CX_STATUS_OK)
  {
    ret = VL53L5CX_ERROR;
  }
  else
  {
    pObj->IsRanging = 0U;
    pObj->IsBlocking = 0U;
    pObj->IsContinuous = 0U;
    pObj->IsAmbientEnabled = 0U;
    pObj->IsSignalEnabled = 0U;
    pObj->IsInitialized = 1U;
    ret = VL53L5CX_OK;
  }
 
  return ret;
}

which in turn invokes the function vl53l5cx_init defined in the ULD for VL53L5CX. Can you or someone please explain to me how this link is established?

Unfortunately I haven't been able to figure it out on my own. Thanks again for the answers and suggestions you have given me these days. They helped me a lot

AlexCloned
Senior

Somewere in your app code you will find the following sentence:

VL53L5A1_RANGING_SENSOR_Init(device);

If you debug your code you will see this functions finally calls

[Your custom]RANGING_SENSOR_Drv->Init(VL53L5A1_RANGING_SENSOR_CompObj[Instance])

And as you have cited RANGING_SENSOR_Drv_t is a struct type of function pointers. And bear in mind in vl53l5cx.h you have a symmetrical declaration of function pointers:

typedef struct
{
  int32_t (*Init)(VL53L5CX_Object_t *);
  int32_t (*DeInit)(VL53L5CX_Object_t *);
  int32_t (*ReadID)(VL53L5CX_Object_t *, uint32_t *);
  int32_t (*GetCapabilities)(VL53L5CX_Object_t *, VL53L5CX_Capabilities_t *);
  int32_t (*ConfigProfile)(VL53L5CX_Object_t *, VL53L5CX_ProfileConfig_t *);
  int32_t (*ConfigROI)(VL53L5CX_Object_t *, VL53L5CX_ROIConfig_t *);
  int32_t (*ConfigIT)(VL53L5CX_Object_t *, VL53L5CX_ITConfig_t *);
  int32_t (*GetDistance)(VL53L5CX_Object_t *, VL53L5CX_Result_t *);
  int32_t (*Start)(VL53L5CX_Object_t *, uint32_t);
  int32_t (*Stop)(VL53L5CX_Object_t *);
  int32_t (*SetAddress)(VL53L5CX_Object_t *, uint32_t);
  int32_t (*GetAddress)(VL53L5CX_Object_t *, uint32_t *);
  int32_t (*SetPowerMode)(VL53L5CX_Object_t *, uint32_t);
  int32_t (*GetPowerMode)(VL53L5CX_Object_t *, uint32_t *);
} VL53L5CX_RANGING_SENSOR_Drv_t;

  1. Again somewhere in your app you should find some code assigning a pointer with the corresponding cast that links your CUSTOM app driver to those funcitions (i.e. VL53L5CX_Init() ) and to the RANGING_SENSOR_Drv_t struct.

MYCUSTOM_RANGING_SENSOR_Drv = (RANGING_SENSOR_Drv_t *) &VL53L5CX_RANGING_SENSOR_Driver;