Sample program that reads from 3 VL53L3 ToF sensors in interrupt mode and outputs the data to the serial port at 115200 baud. MBed V5.15
Dependencies: X_NUCLEO_53L3A2
Diff: main.cpp
- Revision:
- 4:79402ad13f5d
- Parent:
- 3:d6e7cc8dc1d0
--- a/main.cpp Mon Oct 19 09:09:19 2020 +0000 +++ b/main.cpp Tue May 04 09:51:03 2021 +0000 @@ -1,7 +1,7 @@ -/* - * This VL53L1X Expansion board test application performs range measurements +/*/* + * This VL53L3 Expansion board test application performs range measurements * using the onboard embedded centre sensor, in singleshot, polling mode. - * Measured ranges are ouput on the Serial Port, running at 9600 baud. + * Measured ranges are ouput on the Serial Port, running at 115200 baud. * * The User Blue button stops the current measurement and entire program, * releasing all resources. @@ -11,11 +11,11 @@ //Main_interrupt_ranging.h #include <stdio.h> +#include <time.h> #include "mbed.h" -#include "XNucleo53LX.h" +#include "XNucleo53L3A2.h" #include "vl53L3_I2c.h" -#include <time.h> #define I2C_SDA D14 @@ -23,8 +23,13 @@ #define MEASUREMENTTIMING 55 -static XNucleo53LX *board=NULL; -Serial pc(SERIAL_TX, SERIAL_RX); +static XNucleo53L3A2 *board=NULL; +#if (MBED_VERSION > 60300) + UnbufferedSerial pc(USBTX, USBRX); + extern "C" void wait_ms(int ms); +#else + Serial pc(SERIAL_TX, SERIAL_RX); +#endif static int int_centre_result = 0; static int int_left_result = 0; @@ -104,7 +109,7 @@ int main() { int status; - VL53LX * Sensor; + VL53L3 * Sensor; uint16_t wordData; uint8_t ToFSensor = 1; // 0=Left, 1=Center(default), 2=Right @@ -122,7 +127,7 @@ // printf("I2C device created! %d %d\r\n",dev_I2C,*dev_I2C); /* creates the 53L1A1 expansion board singleton obj */ - board = XNucleo53LX::instance(dev_I2C, A2, D8, D2); + board = XNucleo53L3A2::instance(dev_I2C, A2, D8, D2); printf("board created!\r\n"); /* init the 53L1A1 expansion board with default values */ @@ -335,4 +340,10 @@ } printf("terminated"); } - \ No newline at end of file + +#if (MBED_VERSION > 60300) +extern "C" void wait_ms(int ms) + { + thread_sleep_for(ms); + } +#endif