2020-05-30 06:55 PM
Hi,
For a project, I am trying to interface the VL53L1 sensor with the MSP432P401R development board using the API from ST. I'm writing the functions for writing and reading all the bits using I2C, and I was wondering what was the explicit purpose for the function. Is it ok to simply read and write? Or is it mandatory to use a timeout.
Also, are functions like VL53L1_WaitUs() and VL53L1_GetTimerFrequency() mandatory?
Thanks,
-Lucas
2020-06-01 07:54 AM
If you are going to use the functions that wait until the data is ready, then you do need the wait function.
I believe the only ones are wait_until_booted and wait_for_done.
But you don't have to call either one of those. Simulate want until booted by reading the booted register. (or just wait a while before accessing the chip)
Either use interrupts to signal done, or write your own version that polls the 'done' bit.
But try not to poll too often, if the tiny MCU in the sensor spends all it's time responding to your polling, it won't have any time to do real work.
If you want the simple version of the code, download the UltraLiteDriver STSW-IMG009.
It's a bit more straight-forward, and much smaller.
You can easily see what is going on.