Mbed OS 5.x example, ranging with the VL53L1X Time-of-Flight (ToF) sensor on the X-NUCLEO-53L1A1 expansion board, and 2 VL53L1X Satellite boards, connected to the expansion board.
Dependencies: X_NUCLEO_53L1A1
Diff: main.cpp
- Revision:
- 6:e3857da4a7a5
- Parent:
- 2:91088f06f39e
--- a/main.cpp Tue Nov 03 11:45:33 2020 +0000 +++ b/main.cpp Wed May 12 10:05:25 2021 +0000 @@ -21,18 +21,18 @@ * INT_L & INT_R positions; or * U10 and U15 must be made/ON to allow interrupts to be received from the * Alternate INT_L & INT_R positions. - * The X_NUCLEO_53L1A1 firmware library defaults to use the INT_L/INT_R - * positions. - * INT_L is available on expansion board Arduino Connector CN5, pin 1 as D9. - * Alternate INT_L is on CN5 Connector pin 2 as D8. - * INT_R is available on expansion board Arduino Connector CN9, pin 3 as D4. - * Alternate INT_R is on CN9 Connector pin 5 as D2. + * The X_NUCLEO_53L1A1 library defaults to use the INT_L/INT_R positions. + * INT_L is available on expansion board Arduino Connector CN5, pin 1 as D8. + * Alternate INT_L is on CN5 Connector pin 2 as D9. + * INT_R is available on expansion board Arduino Connector CN9, pin 3 as D2. + * Alternate INT_R is on CN9 Connector pin 5 as D4. * The pinouts are shown here : https://developer.mbed.org/components/X-NUCLEO-53L1A1/ */ #include <stdio.h> #include "mbed.h" + #include "XNucleo53L1A1.h" #include "VL53L1X_I2C.h" @@ -40,7 +40,7 @@ #define VL53L1_I2C_SCL D15 #if TARGET_STM // we are cross compiling for an STM32-Nucleo - InterruptIn stop_button(USER_BUTTON); + InterruptIn stop_button(BUTTON1); #endif #if TARGET_Freescale // we are cross-compiling for NXP FRDM boards. InterruptIn stop_button(SW2); @@ -53,6 +53,12 @@ char installedSensors[3]; static XNucleo53L1A1 *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 /* interrupt requests */ volatile bool centerSensor = false; @@ -238,3 +244,9 @@ return 0; } +#if (MBED_VERSION > 60300) +extern "C" void wait_ms(int ms) +{ + thread_sleep_for(ms); +} +#endif