2025-03-25 7:35 AM - edited 2025-03-25 7:40 AM
Hi @John E KVAM ,
I am planning to interface stmvl53l8cx with cypress cx3 controller. I did not find any Register Reference for it to access the TOF registers. Instead I find en.STSW-IMG042.zip SDK for raspberry pi . Should I port this SDK to my microcontroller ? Is there any protocol document for communicating with the MCU inside stmvl53l8cx ?
Can I have a simpler c program for communicating with the MCU inside stmvl53l8cx , instead of having kernel and user space layers ?
Regards,
Vikaash.K.B
2025-03-25 8:07 AM
The VL53L8CX is a pretty complex sensor. During the Init phase, the host downloads some 80K of firmware. So creating a driver much smaller than the ones we supply is not realistic.
We have two Linux drivers. The kernel driver is for those designs where normal users simply cannot be granted access to the I2C bus. (Think cell phones. One simply cannot allow downloadable apps access to the eeproms and other stuff connected to the I2C bus.) In this arrangement the application asks the kernel to access the I2c bus and return the result.
But if your project does not involve downloadable apps, the User-level driver is easier to use. In this driver, the user code simply communicates with the sensor over I2C direct reads and writes.
please note that one uses either the kernel code or the user code. You don't need both.
I'd start with the ST driver you choose and get your project running. I'm pretty sure that code is about as efficient as we can make it.
- john
2025-03-26 12:07 AM - edited 2025-03-26 12:10 AM
Hi @John E KVAM ,
Thank you very much for your response.
I am not asking to optimize the existing code. I am seeking your help to get a similar SDK for cypress cx3 controller.
So, I have to port the user-level code( user/examples/Example_1_ranging_basic.c ) to cypress cx3 firmware.Is my understanding correct ?
Regards,
Vikaash.K.B
2025-03-26 8:01 AM
The user code by ST is written in 'c' and is reasonably straight forward. Your effort consists in ensuring the code in the file platform.c works for you.
Big endian vs Little endian can be an issue. But there is a good chance it just works.
Take our package.
run the makefile and see if runs. There's a good chance it will.
Then evaluate the dozen or so examples and see which one is closest to your application.
Modify that as you like.
Have a look at platform.h.
The sensor is capable of sending potentially lots of data. You can cut that down by uncommenting some of the following:
// #define VL53L8CX_DISABLE_AMBIENT_PER_SPAD
// #define VL53L8CX_DISABLE_NB_SPADS_ENABLED
// #define VL53L8CX_DISABLE_NB_TARGET_DETECTED
// #define VL53L8CX_DISABLE_SIGNAL_PER_SPAD
// #define VL53L8CX_DISABLE_RANGE_SIGMA_MM
// #define VL53L8CX_DISABLE_DISTANCE_MM
// #define VL53L8CX_DISABLE_REFLECTANCE_PERCENT
// #define VL53L8CX_DISABLE_TARGET_STATUS
// #define VL53L8CX_DISABLE_MOTION_INDICATOR
You need status, distance, and number of targets. Signal is nice to have, but the others are optional.
Just try it.
2025-03-26 8:05 AM
Thanks for your response.
/**
* @brief Inner function, not available outside this file. This function is used
* to set the Xtalk data from generic configuration, or user's calibration.
*/
static uint8_t _vl53l8cx_send_xtalk_data(
VL53L8CX_Configuration *p_dev,
uint8_t resolution)
{
What is the Xtalk calibration process mentioned in the above code ?
Also I need to set a upper and lower threshold in TOF , and I need an interrupt to be generated when an object is within the upper and lower threshold. Please let me know , if there is any example for this case.
Regards,
Vikaash.K.B