Range with a (green) VL53L1X Satellite board connected directly to the motherboard, without Expansion board support.
Dependencies: X_NUCLEO_53L1A1_mbed
Diff: main.cpp
- Revision:
- 2:91088f06f39e
- Parent:
- 1:e5cce6b28b6f
- Child:
- 3:78fae258d69f
--- a/main.cpp Fri May 17 12:24:17 2019 +0000 +++ b/main.cpp Wed Jul 24 14:26:03 2019 +0000 @@ -7,10 +7,11 @@ * * The application supports the centre, on-board, sensor and up to two satellite boards. * - * The User Blue button switches between the currently selected sensor to display range - * results from. + * On STM32-Nucleo boards : + * The User Blue button stops the current measurement and entire program, + * releasing all resources. * - * The Black Reset button is used to restart the program. + * The Black Reset button is used to restart the program. * * *** NOTE : By default hardlinks U10, U11, U15 & U18, on the underside of * the X-NUCELO-53L0A1 expansion board are not made/OFF. @@ -33,13 +34,16 @@ #include "mbed.h" #include "XNucleo53L1A1.h" -#include "vl53L1x_I2c.h" +#include "VL53L1X_I2C.h" #define VL53L1_I2C_SDA D14 #define VL53L1_I2C_SCL D15 -#if USER_BUTTON==PC_13 // we are cross compiling for Nucleo-64s -InterruptIn stop_button(USER_BUTTON); +#if TARGET_STM // we are cross compiling for an STM32-Nucleo + InterruptIn stop_button(USER_BUTTON); +#endif +#if TARGET_Freescale // we are cross-compiling for NXP FRDM boards. + InterruptIn stop_button(SW2); #endif /* Installed sensors count */ @@ -49,7 +53,6 @@ char installedSensors[3]; static XNucleo53L1A1 *board=NULL; -Serial pc(SERIAL_TX, SERIAL_RX); /* interrupt requests */ volatile bool centerSensor = false; @@ -183,7 +186,7 @@ /* * Main ranging function */ -int range_measure(vl53L1X_DevI2C *device_i2c) +int range_measure(VL53L1X_DevI2C *device_i2c) { int status = 0; @@ -226,12 +229,12 @@ =============================================================================*/ int main() { -#if USER_BUTTON==PC_13 // we are cross compiling for Nucleo-f401 stop_button.rise(&switch_measuring_sensor_irq); stop_button.enable_irq(); -#endif - vl53L1X_DevI2C *dev_I2C = new vl53L1X_DevI2C(VL53L1_I2C_SDA, VL53L1_I2C_SCL); + + VL53L1X_DevI2C *dev_I2C = new VL53L1X_DevI2C(VL53L1_I2C_SDA, VL53L1_I2C_SCL); range_measure(dev_I2C); // start continuous measures -return 0; + + return 0; }