Sample MBed program for use with ST XNucleo VL53L1CB board. Uses interrupts to cope with up to 3 sensors in multizone mode. Includes MBed V6.4
Dependencies: X_NUCLEO_53L1A2
Diff: main.cpp
- Revision:
- 1:c67af60ec906
- Parent:
- 0:e91189a84ad9
- Child:
- 2:25bcfa4b1aca
--- a/main.cpp Sun Nov 08 15:49:23 2020 +0000 +++ b/main.cpp Mon Nov 09 17:23:54 2020 +0000 @@ -13,7 +13,7 @@ #include <stdio.h> #include "mbed.h" -#include "XNucleo53L1A1.h" +#include "XNucleo53L1A2.h" #include "ToF_I2C.h" #include <time.h> @@ -24,6 +24,7 @@ #define NUM_SENSORS 3 +// define interrupt pins PinName CentreIntPin = A2; // the satellite pins depend on solder blobs on the back of the shield. // they may not exist or may be one of two sets. @@ -35,7 +36,7 @@ //PinName RightIntPin = D2; -static XNucleo53L1A1 *board=NULL; +static XNucleo53L1A2 *board=NULL; #if (MBED_VERSION > 60300) UnbufferedSerial pc(SERIAL_TX, SERIAL_RX); @@ -59,7 +60,7 @@ uint32_t centre_start_time_ms; uint32_t centre_end_time_ms; -void process_interrupt( VL53L1X * sensor,VL53L1_DEV dev ); +void process_interrupt( VL53L1 * sensor,VL53L1_DEV dev ); void print_results( int devSpiNumber, VL53L1_MultiRangingData_t *pMultiRangingData ); @@ -148,7 +149,7 @@ int main() { int status; - VL53L1X * Sensor; + VL53L1 * Sensor; uint16_t wordData; uint8_t ToFSensor = 1; // 0=Left, 1=Center(default), 2=Right @@ -166,8 +167,8 @@ dev_I2C->frequency(400000); //also needs doing in spi_interface.c - /* creates the 53L1A1 expansion board singleton obj */ - board = XNucleo53L1A1::instance(dev_I2C, CentreIntPin, RightIntPin, D2); + /* creates the 53L1A2 expansion board singleton obj */ + board = XNucleo53L1A2::instance(dev_I2C, CentreIntPin, RightIntPin, D2); printf("board created!\r\n");