Skip to main content
Associate
October 7, 2024
Solved

Set Target Order & Thresholds in 53L5A1 BSP for VL53L5A1 Multi-Sensor Ranging?

  • October 7, 2024
  • 2 replies
  • 909 views

In the 53L5A1 Board Support Package (BSP) for the VL53L5A1 Multi-Sensor Ranging module, setting the target order (e.g., VL53L5CX_TARGET_ORDER_STRONGEST or VL53L5CX_TARGET_ORDER_CLOSEST) doesn't seem to be directly exposed through the existing BSP functions.

The vl53l5cx_set_target_order() function in the vl53l5cx_api.h (from the VL53L5CX API) uses a different configuration structure (VL53L5CX_Configuration) compared to the structure used in the 53L5A1 BSP.

Is there any guidance, documentation, or example code available on how to create a wrapper function to bridge these APIs and control the target order and detection thresholds for each individual ToF sensor within the multi-sensor ranging module?

This topic has been closed for replies.
Best answer by moj

I found a typo in my code Platform_Init of the Dev structure - below code seems to work.


VL53L5CX_Configuration Dev;


void VL53L5CX_Platform_Init() {
 Dev.platform.address = 0x52;
 Dev.platform.Read = VL53L5A1_I2C_ReadReg ;
 Dev.platform.Write = VL53L5A1_I2C_WriteReg;
 Dev.platform.GetTick = VL53L5A1_GetTick;
}


uint16_t VL53L5A1_GetI2CAddress(uint32_t device) {

	switch (device) {
 case 0:
 return 0x54;
 case 1:
 return 0x56;
 case 2:
 return 0x58;
 default:
 return 0x00;
 }
}


int32_t VL53L5A1_RANGING_SENSOR_SetTargetOrder(uint32_t device, uint8_t target_order){
 uint8_t status;

 Dev.platform.address = VL53L5A1_GetI2CAddress(device);

 // Set the target order using the VL53L5CX API
 status = vl53l5cx_set_target_order(&Dev, target_order);
 if (status != 0) {
 return BSP_ERROR_COMPONENT_FAILURE;
 }

 return BSP_ERROR_NONE;
}

 

2 replies

John E KVAM
ST Employee
October 7, 2024

You don't see a:

uint8_t vl53l5cx_set_target_order(
		VL53L5CX_Configuration		*p_dev,
		uint8_t				target_order)

function in the vl53L5cx_api.c

Should be there. 

But if you are using the XCode_ToF, the functions get abstracted. 

That code tries to make a uniform interface even though the chips really are kind of different. 

And that leaves some stuff out. 

Your challenge is to figure out *p_dev is. 

With that you can call the functions in the API directly instead of going through the BSP.

- 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.
mojAuthorBest answer
Associate
October 9, 2024

I found a typo in my code Platform_Init of the Dev structure - below code seems to work.


VL53L5CX_Configuration Dev;


void VL53L5CX_Platform_Init() {
 Dev.platform.address = 0x52;
 Dev.platform.Read = VL53L5A1_I2C_ReadReg ;
 Dev.platform.Write = VL53L5A1_I2C_WriteReg;
 Dev.platform.GetTick = VL53L5A1_GetTick;
}


uint16_t VL53L5A1_GetI2CAddress(uint32_t device) {

	switch (device) {
 case 0:
 return 0x54;
 case 1:
 return 0x56;
 case 2:
 return 0x58;
 default:
 return 0x00;
 }
}


int32_t VL53L5A1_RANGING_SENSOR_SetTargetOrder(uint32_t device, uint8_t target_order){
 uint8_t status;

 Dev.platform.address = VL53L5A1_GetI2CAddress(device);

 // Set the target order using the VL53L5CX API
 status = vl53l5cx_set_target_order(&Dev, target_order);
 if (status != 0) {
 return BSP_ERROR_COMPONENT_FAILURE;
 }

 return BSP_ERROR_NONE;
}