2024-12-04 03:22 AM
I'm using the full API for the VL53L1 ToF sensor. The project is pretty simple as I'm using 4 sensor to measure distance connected on an I2C of an STM32F091.
I'm optimizing the code and I'm come across the VL53L1X ULD API (Ultra Lite Driver Application Programming Interface) STSW-IMG009.
From what I'm seeing most of the function I'm using:
Could be replaced with the ones available in the ULD API.
The only thing I can't understand is how to edit the Dev structure. I'm currently using
Dev->I2cHandle = &hi2c2;
Dev->comms_speed_khz = 100; //400
Dev->comms_type = 1;
Dev->I2cDevAddr = 0x52; // default ToF sensor I2C address
From what I'm understanding I have to edit VL51L1X_NVM_CONFIGURATION and VL51L1X_DEFAULT_CONFIGURATION with the settings I'm using.
Is that right?
Solved! Go to Solution.
2024-12-06 07:53 AM
Ok I got it. Firstly I set up the I2C on the micro with
static void MX_I2C2_Init(void) {
HAL_I2C_DeInit(&hi2c2);
hi2c2.Instance = I2C2;
...
and then XNUCLEO53L1A1_Init() editing XNUCLEO53L1A1_I2C1Configure() with the config used in MX_I2C2_Init().
About the function I was using I switched them following like below:
2024-12-04 12:18 PM
When I set down the rules for the ULD driver, I specified absolute simplicity. No hiding of classes, no layers to hide behind, and dead simple code.
Someone decided to eliminate all structures as well. INCLUDNG the 'dev' structure.
Change that structure to an 'int'. Make the 'int' equal to the I2C address of your sensor.
So uint16_t dev=0x52; by default, should do it.
uint16_t dev=0x52;
But you should see an example of this.
Downloaded the latest from STSW-IMG009 - VL53L1X ULD API (Ultra Lite Driver Application Programming Interface) - STMicroelectronics
We are at version 3.5.4.
2024-12-06 07:53 AM
Ok I got it. Firstly I set up the I2C on the micro with
static void MX_I2C2_Init(void) {
HAL_I2C_DeInit(&hi2c2);
hi2c2.Instance = I2C2;
...
and then XNUCLEO53L1A1_Init() editing XNUCLEO53L1A1_I2C1Configure() with the config used in MX_I2C2_Init().
About the function I was using I switched them following like below: