How to add VL53L0x drivers to STM32 Project
I need to simply add VL53L0x API STSW-IMG005 to my project without any compilation errors. And need to know the necessary functions to get the distance.
Regard
I need to simply add VL53L0x API STSW-IMG005 to my project without any compilation errors. And need to know the necessary functions to get the distance.
Regard
The STSW-IMG005 software is an API containing all the calls you need to make - but it stops at the I2C call. You need to supply the platform layer between the I2C_read/write functions and your MCU. Refer to the platform.c file (which is where you put your functions).
Attached is a platform.c file I developed for an STM32 to give you the idea. Adapt it as you require.
As for what is in the main, try something like:
status=VL53L0X_StaticInit(&VL53L0XDevs[i]);
if( status ){
debug_printf("VL53L0X_StaticInit %d failed\n",i);
}
status = VL53L0X_PerformRefCalibration(&VL53L0XDevs[i], &VhvSettings, &PhaseCal);
if( status ){
debug_printf("VL53L0X_PerformRefCalibration failed\n");
}
status = VL53L0X_PerformRefSpadManagement(&VL53L0XDevs[i], &refSpadCount, &isApertureSpads);
if( status ){
debug_printf("VL53L0X_PerformRefSpadManagement failed\n");
}
status = VL53L0X_SetDeviceMode(&VL53L0XDevs[i], VL53L0X_DEVICEMODE_SINGLE_RANGING); // Setup in single ranging mode
if( status ){
debug_printf("VL53L0X_SetDeviceMode failed\n");
}
status = VL53L0X_SetLimitCheckEnable(&VL53L0XDevs[i], VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE, 1); // Enable Sigma limit
if( status ){
debug_printf("VL53L0X_SetLimitCheckEnable failed\n");
}
status = VL53L0X_SetLimitCheckEnable(&VL53L0XDevs[i], VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, 1); // Enable Signa limit
if( status ){
debug_printf("VL53L0X_SetLimitCheckEnable failed\n");
}To set things up, then to run:
status = VL53L0X_PerformSingleRangingMeasurement(&VL53L0XDevs[SingleSensorNo],&RangingMeasurementData);
if( status ==0 ){
/* Push data logging to UART */
trace_printf("%d,%u,%d,%d,%d\n", VL53L0XDevs[SingleSensorNo].Id, TimeStamp_Get(), RangingMeasurementData.RangeStatus, RangingMeasurementData.RangeMilliMeter, RangingMeasurementData.SignalRateRtnMegaCps);But there are lots of ways to configure and run - so do read the user's guide
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.