cancel
Showing results for 
Search instead for 
Did you mean: 

What are the purpose of the I2C functions?

LChan.4
Associate

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

1 REPLY 1
John E KVAM
ST Employee

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.

  • 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.