Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_53L1A2
Fork of VL53L1CB_shield_3sensors_interrupt_lite_ranging_MB6 by
Diff: main.cpp
- Revision:
- 4:8c96fc85fa6b
- Parent:
- 1:449614c84f8e
diff -r e6741cadb1f1 -r 8c96fc85fa6b main.cpp
--- a/main.cpp Fri Jun 11 18:00:10 2021 +0100
+++ b/main.cpp Mon Jun 14 08:14:59 2021 +0000
@@ -40,7 +40,7 @@
// MBed V6.4 has renamed wait_ms and UnbufferedSerial replaces Serial
#if (MBED_VERSION > 60300)
-UnbufferedSerial pc(SERIAL_TX, SERIAL_RX);
+UnbufferedSerial pc(USBTX, USBRX);
extern "C" void wait_ms(int ms);
#else
Serial pc(SERIAL_TX, SERIAL_RX);
@@ -120,7 +120,7 @@
int main()
{
int status;
- VL53L1 * Sensor;
+ VL53L1CB * Sensor;
uint16_t wordData;
uint8_t ToFSensor = 1; // loop count
@@ -186,10 +186,10 @@
Dev->comms_type = 1;
/* Device Initialization and setting */
- status = Sensor->vl53L1_DataInit();
- status = Sensor->vl53L1_StaticInit();
- status = Sensor->vl53L1_SetPresetMode( VL53L1_PRESETMODE_LITE_RANGING);
- status = Sensor->vl53L1_SetDistanceMode( VL53L1_DISTANCEMODE_LONG);
+ status = Sensor->VL53L1CB_DataInit();
+ status = Sensor->VL53L1CB_StaticInit();
+ status = Sensor->VL53L1CB_SetPresetMode( VL53L1_PRESETMODE_LITE_RANGING);
+ status = Sensor->VL53L1CB_SetDistanceMode( VL53L1_DISTANCEMODE_LONG);
// status = Sensor->vl53L1_SetMeasurementTimingBudgetMicroSeconds( 50000);
// status = Sensor->vl53L1_SetInterMeasurementPeriodMilliSeconds( 100);
} // end of sensor loop
@@ -201,7 +201,7 @@
Sensor=board->sensor_centre;
devCentre.i2c_slave_address = NEW_SENSOR_CENTRE_ADDRESS;
int1 = new WaitForMeasurement(CentreIntPin,&devCentre); // initialise sensor interrupts
- status = Sensor->vl53L1_StartMeasurement();
+ status = Sensor->VL53L1CB_StartMeasurement();
printf("started interrupt centre %d\n",status);
}
@@ -211,7 +211,7 @@
Sensor=board->sensor_left;
devLeft.i2c_slave_address = NEW_SENSOR_LEFT_ADDRESS;
int2 = new WaitForMeasurement(LeftIntPin,&devLeft);
- status = Sensor->vl53L1_StartMeasurement();
+ status = Sensor->VL53L1CB_StartMeasurement();
printf("started interrupt left %d\n",status);
}
@@ -220,7 +220,7 @@
Sensor=board->sensor_right;
devRight.i2c_slave_address = NEW_SENSOR_RIGHT_ADDRESS;
int3 = new WaitForMeasurement(RightIntPin,&devRight);
- status = board->sensor_right->vl53L1_StartMeasurement();
+ status = board->sensor_right->VL53L1CB_StartMeasurement();
printf("started interrupt sensor_right %d\n",status);
}
@@ -236,42 +236,42 @@
if (int_centre_result != 0)
{
// read result
- status = board->sensor_centre->vl53L1_GetRangingMeasurementData( &RangingData);
+ status = board->sensor_centre->VL53L1CB_GetRangingMeasurementData( &RangingData);
// if valid result print it
if (RangingData.RangeStatus != 255)
printf("c %d,%d \n",RangingData.RangeStatus,RangingData.RangeMilliMeter);
// clear interrupt flag
int_centre_result = 0;
// clear theinterrupt and wait for another result
- status = board->sensor_centre->vl53L1_ClearInterruptAndStartMeasurement();
+ status = board->sensor_centre->VL53L1CB_ClearInterruptAndStartMeasurement();
}
if (int_left_result != 0)
{
// read result
- status = board->sensor_left->vl53L1_GetRangingMeasurementData( &RangingData);
+ status = board->sensor_left->VL53L1CB_GetRangingMeasurementData( &RangingData);
// if valid result print it
if (RangingData.RangeStatus != 255)
printf("l %d,%d\n",RangingData.RangeStatus,RangingData.RangeMilliMeter);
// clear interrupt flag
int_left_result = 0;
// clear theinterrupt and wait for another result
- status = board->sensor_left->vl53L1_ClearInterruptAndStartMeasurement();
+ status = board->sensor_left->VL53L1CB_ClearInterruptAndStartMeasurement();
}
if (int_right_result != 0)
{
// read result
- status = board->sensor_right->vl53L1_GetRangingMeasurementData( &RangingData);
+ status = board->sensor_right->VL53L1CB_GetRangingMeasurementData( &RangingData);
// if valid result print it
if (RangingData.RangeStatus != 255)
printf("r %d,%d\n",RangingData.RangeStatus,RangingData.RangeMilliMeter);
// clear interrupt flag
int_right_result = 0;
// clear theinterrupt and wait for another result
- status = board->sensor_right->vl53L1_ClearInterruptAndStartMeasurement();
+ status = board->sensor_right->VL53L1CB_ClearInterruptAndStartMeasurement();
}
}
