cancel
Showing results for 
Search instead for 
Did you mean: 

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

moj
Associate

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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;
}

 

View solution in original post

2 REPLIES 2
John E KVAM
ST Employee

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.

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;
}