Sample MBed program running ST XNucleo VL53L1CB ToF sensors directly connected to the the F401. Uses interrupts to cope with up to 3 sensors in multizone mode. Includes MBed V6.4
Dependencies: X_NUCLEO_53L1A2
Revision 1:51e9344a1f33, committed 2020-11-09
- Comitter:
- charlesmn
- Date:
- Mon Nov 09 17:53:08 2020 +0000
- Parent:
- 0:2ee129a3b1e8
- Child:
- 2:d480db875e4a
- Commit message:
- No functional change. Changed Filenames and functions names to be VL53L1
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_53L1A2.lib Mon Nov 09 17:53:08 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L1A2/#25be5ff92db5
--- a/X_NUCLEO_53L1CB.lib Mon Nov 09 09:36:03 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L1CB/#ac8e3765ece8
--- a/main.cpp Mon Nov 09 09:36:03 2020 +0000 +++ b/main.cpp Mon Nov 09 17:53:08 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> @@ -29,7 +29,7 @@ #define NUM_SENSORS 3 -// define the sensor interrupt pins. This much match the wiring! +// define the sensor interrupt pins. This must match the wiring! PinName CentreIntPin = A2; PinName LeftIntPin = D9; PinName RightIntPin = D4; @@ -103,10 +103,10 @@ int main() { int status; - VL53L1X * Sensor; - VL53L1X * SensorCentre; - VL53L1X * SensorLeft; - VL53L1X * SensorRight; + VL53L1 * Sensor; + VL53L1 * SensorCentre; + VL53L1 * SensorLeft; + VL53L1 * SensorRight; DigitalOut xshutdownCentre(D9); DigitalOut xshutdownLeft(D4); DigitalOut xshutdownRight(D3); @@ -125,16 +125,15 @@ // create the i2c instance ToF_DevI2C *dev_I2C = new ToF_DevI2C(I2C_SDA, I2C_SCL); // create the sensor instances - SensorCentre = new VL53L1X(dev_I2C, &xshutdownCentre, CentreIntPin); - SensorLeft = new VL53L1X(dev_I2C, &xshutdownLeft, LeftIntPin); - SensorRight = new VL53L1X(dev_I2C, &xshutdownRight, RightIntPin); + SensorCentre = new VL53L1(dev_I2C, &xshutdownCentre, CentreIntPin); + SensorLeft = new VL53L1(dev_I2C, &xshutdownLeft, LeftIntPin); + SensorRight = new VL53L1(dev_I2C, &xshutdownRight, RightIntPin); printf("board created!\r\n"); // initialise sensors for (ToFSensor=0;ToFSensor< NUM_SENSORS ;ToFSensor++){ switch(ToFSensor){ case 0: - if (SensorCentre == NULL ) continue; // try to initialise the sensor. returns -1 if sensor is not there. if (SensorCentre->InitSensor(NEW_SENSOR_CENTRE_ADDRESS) ==-1)