A sample program to control one VL53L1 ToF sensor in multizone mode using polling to find out if a measurement is available. Mbed V6.3 but will run any MBed version by dropping replacing this one. Maint6 release.
Dependencies: X_NUCLEO_53L1A2
Diff: main.cpp
- Revision:
- 15:ce041cbc8727
- Parent:
- 3:d1a3d15a06ff
- Child:
- 16:9fd42eb225c5
--- a/main.cpp Sun Nov 08 15:06:04 2020 +0000 +++ b/main.cpp Mon Nov 09 17:44:46 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> @@ -22,9 +22,21 @@ #define I2C_SDA D14 #define I2C_SCL D15 +// 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. +// the centre pin always exists +PinName LeftIntPin = D9; +PinName RightIntPin = D4; +// alternate set +//PinName LeftIntPin = D8; +//PinName RightIntPin = D2; -static XNucleo53L1A1 *board=NULL; + + +static XNucleo53L1A2 *board=NULL; #if (MBED_VERSION > 60300) UnbufferedSerial pc(SERIAL_TX, SERIAL_RX); extern "C" void wait_ms(int ms); @@ -32,7 +44,7 @@ Serial pc(SERIAL_TX, SERIAL_RX); #endif -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 ); VL53L1_Dev_t devCentre; @@ -46,7 +58,7 @@ int main() { int status; - VL53L1X * Sensor; + VL53L1 * Sensor; uint16_t wordData; @@ -56,8 +68,8 @@ // create i2c interface ToF_DevI2C *dev_I2C = new ToF_DevI2C(I2C_SDA, I2C_SCL); - /* creates the 53L1A1 expansion board singleton obj */ - board = XNucleo53L1A1::instance(dev_I2C, A2, D8, D2); + /* creates the 53L1A2 expansion board singleton obj */ + board = XNucleo53L1A2::instance(dev_I2C, CentreIntPin, LeftIntPin, RightIntPin); printf("board created!\r\n");