Simple Ranging with only the Time-of-Flight (ToF) Sensor on the X-NUCLEO-53L1A1 expansion board. Does not use Satellite boards.
Dependencies: X_NUCLEO_53L1A1
Revision 3:f61dd7863e32, committed 2019-07-24
- Comitter:
- johnAlexander
- Date:
- Wed Jul 24 14:18:51 2019 +0000
- Parent:
- 2:46dcd0517f2a
- Child:
- 4:5aeaebdaf6ad
- Commit message:
- Update for non-ST boards.; Refactor init_sensor.
Changed in this revision
| X_NUCLEO_53L1A1_mbed.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/X_NUCLEO_53L1A1_mbed.lib Fri May 17 12:29:28 2019 +0000 +++ b/X_NUCLEO_53L1A1_mbed.lib Wed Jul 24 14:18:51 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L1A1_mbed/#24a73ef7469f +https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L1A1_mbed/#0e99f593daa9
--- a/main.cpp Fri May 17 12:29:28 2019 +0000
+++ b/main.cpp Wed Jul 24 14:18:51 2019 +0000
@@ -3,15 +3,16 @@
* with interrupts enabled to generate a hardware interrupt each time a new
* measurement is ready to be read.
*
- * Measured ranges are ouput on the Serial Port, running at 115200 baud.
+ * Measured ranges are output on the Serial Port, running at 115200 baud.
*
- * The User Blue button stops the current measurement and entire program,
- * releasing all resources.
+ * 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.
+ * the X-NUCELO-53L1A1 expansion board are not made/OFF.
* These links must be made to allow interrupts from the Satellite boards
* to be received.
* U11 and U18 must be made/ON to allow interrupts to be received from the
@@ -31,13 +32,20 @@
#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 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
+
+
static XNucleo53L1A1 *board=NULL;
-Serial pc(SERIAL_TX, SERIAL_RX);
/* flags that handle interrupt request for sensor and user blue button*/
volatile bool int_sensor = false;
@@ -78,7 +86,7 @@
/*
* Main ranging function
*/
-int range_measure(vl53L1X_DevI2C *device_i2c)
+int range_measure(VL53L1X_DevI2C *device_i2c)
{
int status = 0;
uint16_t distance = 0;
@@ -123,10 +131,8 @@
=============================================================================*/
int main()
{
-#if USER_BUTTON==PC_13 // we are cross compiling for Nucleo-f401
- InterruptIn stop_button(USER_BUTTON);
stop_button.rise(&measuring_stop_irq);
-#endif
- vl53L1X_DevI2C *device_i2c = new vl53L1X_DevI2C(VL53L1_I2C_SDA, VL53L1_I2C_SCL);
+
+ VL53L1X_DevI2C *device_i2c = new VL53L1X_DevI2C(VL53L1_I2C_SDA, VL53L1_I2C_SCL);
range_measure(device_i2c); // start continuous measures
}
X-NUCLEO-53L1A1 Ranging Sensor Expansion Board