VL53L0X for non-Wire platforms

Is there a way to get assistance for using the VL53L0X on non-wire platforms?
I’ve several sensors from Pololu, VL53L0X, VL53L1X, and VL53L3CX but cannot get them to function without going into the Arduino world.
I’m wanting to use these on the TI-RSLK MAX with the MSP432. Using the CCS IDE.
ST won’t help with this because I’m not using their MCU.
I’ve diligently gone through the API but it is a nightmare. It is a wee bit enmeshed, part of it is for Linux, part of it is for Windows, and part of it is locked in to be used only on their MCUs.
I’ve looked through several examples: Adafruit, SparkFun, Arduino…there is Energia examples, but it is all on the Wire.h.
Are there any non-Wire, platform independent, MCU independent, API examples available?

Hello,

While ST’s APIs for these sensors are definitely very complex, the key thing to understand is that they are designed to be well isolated so that all of the platform-specific code is in one file, and you can fill in that one file without touching the rest of the API source code. This platform-specific code is what you would need to write to translate higher-level function calls like “read a 16-bit sensor register” (VL53L0X_RdWord) into low-level operations that actually perform the I2C communication on the MSP432. If you haven’t already, I recommend looking at the “Platform” section in the API specification (with a .chm extension) included with the API files:

We do not have an example implementation of the VL53L0X API, but another user’s port of the API for Raspberry Pi might help show you what you would need to do for the MSP432. Specifically, you’ll probably want to look at his vl53l0x_platform.c.

We also have an implementation of the VL53l1X API for Arduino that might be another useful reference; here, the relevant file is vl53l1_platform.cpp.

Kevin

Update: ST has followed up with me about requests for assistance and is working me on this.

Kevin,
Thank you for the response.
The Pi’s _platform.c looks like they took the _i2c_platform.h from the API and then made prototypes in the _platform.c. I’m not fully sure why I need to setup the I2C structure of the VL53. Shouldn’t this already be done?

I think this is what you are saying to do, translate the LV53 higher-level function into MSP432 low-level function. This baffles me. I’m talking to the sensor through the controller, not talking to the controller through the sensor. I don’t think I’m compiling any code to program the VL53? I’m just talking to it.

I’ve looked through several Arduino uses (including Pololu) and, although it is great to see the *.h and *.c files created, I also find that because they have the wire.h foundation, I can see I might need to write something like this, but it is all to recreate classes for the Arduino base, verses just sending an I2C request to the sensor and know to send the address to a register or being able to parse a chunk of data from the sensor?

Thank you

The API runs on the controller, so everything in it defines how the controller should talk to the VL53. If it helps, you can think of a function like VL53L0X_RdWord as “a function that reads a word (2 bytes) from the VL53L0X”, and the platform-specific implementation defines how a specific controller would accomplish that over I2C. So the Arduino port calls some functions from the Wire library, the Raspberry Pi port calls some Linux I2C functions, and likewise an MSP432 port would need to do the right I2C operations (whether that involves an MPS432 I2C library or not).

Kevin

1 Like