2024-10-07 01:20 PM - last edited on 2024-10-07 01:34 PM by Andrew Neil
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?
Solved! Go to Solution.
2024-10-09 04:36 AM
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;
}
2024-10-07 01:38 PM
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
2024-10-09 04:36 AM
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;
}