Sample program that reads from 3 VL53L3 ToF sensors in interrupt mode and outputs the data to the serial port at 115200 baud. MBed V5.15

Dependencies:   X_NUCLEO_53L3A2

Committer:
johnAlexander
Date:
Tue May 04 09:51:03 2021 +0000
Revision:
4:79402ad13f5d
Parent:
3:d6e7cc8dc1d0
Use published expnasion board and sensor class. Rebuild targetting MbedOS v5.15.7.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
johnAlexander 4:79402ad13f5d 1 /*/*
johnAlexander 4:79402ad13f5d 2 * This VL53L3 Expansion board test application performs range measurements
charlesmn 0:c77591fc308d 3 * using the onboard embedded centre sensor, in singleshot, polling mode.
johnAlexander 4:79402ad13f5d 4 * Measured ranges are ouput on the Serial Port, running at 115200 baud.
charlesmn 0:c77591fc308d 5 *
charlesmn 0:c77591fc308d 6 * The User Blue button stops the current measurement and entire program,
charlesmn 0:c77591fc308d 7 * releasing all resources.
charlesmn 0:c77591fc308d 8 *
charlesmn 0:c77591fc308d 9 * The Reset button can be used to restart the program.
charlesmn 0:c77591fc308d 10 */
charlesmn 0:c77591fc308d 11 //Main_interrupt_ranging.h
charlesmn 0:c77591fc308d 12
charlesmn 0:c77591fc308d 13 #include <stdio.h>
johnAlexander 4:79402ad13f5d 14 #include <time.h>
charlesmn 0:c77591fc308d 15
charlesmn 0:c77591fc308d 16 #include "mbed.h"
johnAlexander 4:79402ad13f5d 17 #include "XNucleo53L3A2.h"
charlesmn 3:d6e7cc8dc1d0 18 #include "vl53L3_I2c.h"
charlesmn 0:c77591fc308d 19
charlesmn 0:c77591fc308d 20
charlesmn 3:d6e7cc8dc1d0 21 #define I2C_SDA D14
charlesmn 3:d6e7cc8dc1d0 22 #define I2C_SCL D15
charlesmn 0:c77591fc308d 23
charlesmn 0:c77591fc308d 24 #define MEASUREMENTTIMING 55
charlesmn 0:c77591fc308d 25
johnAlexander 4:79402ad13f5d 26 static XNucleo53L3A2 *board=NULL;
johnAlexander 4:79402ad13f5d 27 #if (MBED_VERSION > 60300)
johnAlexander 4:79402ad13f5d 28 UnbufferedSerial pc(USBTX, USBRX);
johnAlexander 4:79402ad13f5d 29 extern "C" void wait_ms(int ms);
johnAlexander 4:79402ad13f5d 30 #else
johnAlexander 4:79402ad13f5d 31 Serial pc(SERIAL_TX, SERIAL_RX);
johnAlexander 4:79402ad13f5d 32 #endif
charlesmn 0:c77591fc308d 33
charlesmn 0:c77591fc308d 34 static int int_centre_result = 0;
charlesmn 0:c77591fc308d 35 static int int_left_result = 0;
charlesmn 0:c77591fc308d 36 static int int_right_result = 0;
charlesmn 0:c77591fc308d 37
charlesmn 0:c77591fc308d 38
charlesmn 0:c77591fc308d 39 class WaitForMeasurement {
charlesmn 0:c77591fc308d 40 public:
charlesmn 0:c77591fc308d 41
charlesmn 0:c77591fc308d 42
charlesmn 0:c77591fc308d 43 // this class services the interrupts from the ToF sensors.
charlesmn 0:c77591fc308d 44 // There is a limited amount you can do in an interrupt routine; printfs,mutexes break them among other things.
charlesmn 0:c77591fc308d 45 // We keep things simple by only raising a flag so all the real work is done outside the interrupt.
charlesmn 0:c77591fc308d 46 // This is designed around MBED V2 which doesn't have the RTOS features that would make this work nicely e.g. semaphores/queues.
charlesmn 0:c77591fc308d 47 WaitForMeasurement(): _interrupt(A1)
charlesmn 0:c77591fc308d 48 {
charlesmn 0:c77591fc308d 49 }
charlesmn 0:c77591fc308d 50
charlesmn 0:c77591fc308d 51
charlesmn 0:c77591fc308d 52 // constructor - Sensor is not used and can be removed
charlesmn 0:c77591fc308d 53 WaitForMeasurement(PinName pin,VL53LX_DEV Dev) : _interrupt(pin) // create the InterruptIn on the pin specified to Counter
charlesmn 0:c77591fc308d 54 {
charlesmn 0:c77591fc308d 55 Devlocal = Dev;
charlesmn 0:c77591fc308d 56 _interrupt.rise(callback(this, &WaitForMeasurement::got_interrupt)); // attach increment function of this counter instance
charlesmn 0:c77591fc308d 57
charlesmn 0:c77591fc308d 58 }
charlesmn 0:c77591fc308d 59
charlesmn 0:c77591fc308d 60 void process_right_interrupt()
charlesmn 0:c77591fc308d 61 {
charlesmn 0:c77591fc308d 62 printf("processing right interrupt\n");
charlesmn 0:c77591fc308d 63 }
charlesmn 0:c77591fc308d 64
charlesmn 0:c77591fc308d 65 // function is called every time an interupt is seen. A flag is raised which allows the main routine to service the interupt.
charlesmn 0:c77591fc308d 66 void got_interrupt()
charlesmn 0:c77591fc308d 67 {
charlesmn 0:c77591fc308d 68
charlesmn 0:c77591fc308d 69 _count++;
charlesmn 0:c77591fc308d 70
charlesmn 0:c77591fc308d 71 if (Devlocal->I2cDevAddr == NEW_SENSOR_CENTRE_ADDRESS)
charlesmn 0:c77591fc308d 72 int_centre_result = 1; //flag to main that interrupt happened
charlesmn 0:c77591fc308d 73 if (Devlocal->I2cDevAddr == NEW_SENSOR_LEFT_ADDRESS)
charlesmn 0:c77591fc308d 74 int_left_result = 1; //flag to main that interrupt happened
charlesmn 0:c77591fc308d 75 if (Devlocal->I2cDevAddr == NEW_SENSOR_RIGHT_ADDRESS)
charlesmn 0:c77591fc308d 76 {
charlesmn 0:c77591fc308d 77 int_right_result = 1; //flag to main that interrupt happened
charlesmn 0:c77591fc308d 78 }
charlesmn 0:c77591fc308d 79 }
charlesmn 0:c77591fc308d 80
charlesmn 0:c77591fc308d 81
charlesmn 0:c77591fc308d 82 //destructor
charlesmn 0:c77591fc308d 83 ~WaitForMeasurement()
charlesmn 0:c77591fc308d 84 {
charlesmn 0:c77591fc308d 85 printf("destruction \n");
charlesmn 0:c77591fc308d 86 }
charlesmn 0:c77591fc308d 87
charlesmn 0:c77591fc308d 88 private:
charlesmn 0:c77591fc308d 89 InterruptIn _interrupt;
charlesmn 0:c77591fc308d 90 volatile int _count;
charlesmn 0:c77591fc308d 91 VL53LX_DEV Devlocal;
charlesmn 0:c77591fc308d 92 int status;
charlesmn 0:c77591fc308d 93
charlesmn 0:c77591fc308d 94 };
charlesmn 0:c77591fc308d 95
charlesmn 0:c77591fc308d 96
charlesmn 0:c77591fc308d 97
charlesmn 0:c77591fc308d 98 VL53LX_Dev_t devCentre;
charlesmn 0:c77591fc308d 99 VL53LX_Dev_t devLeft;
charlesmn 0:c77591fc308d 100 VL53LX_Dev_t devRight;
charlesmn 0:c77591fc308d 101 VL53LX_DEV Dev = &devCentre;
charlesmn 0:c77591fc308d 102
charlesmn 0:c77591fc308d 103
charlesmn 0:c77591fc308d 104
charlesmn 0:c77591fc308d 105
charlesmn 0:c77591fc308d 106
charlesmn 0:c77591fc308d 107 /*=================================== Main ==================================
charlesmn 0:c77591fc308d 108 =============================================================================*/
charlesmn 0:c77591fc308d 109 int main()
charlesmn 0:c77591fc308d 110 {
charlesmn 0:c77591fc308d 111 int status;
johnAlexander 4:79402ad13f5d 112 VL53L3 * Sensor;
charlesmn 0:c77591fc308d 113 uint16_t wordData;
charlesmn 0:c77591fc308d 114 uint8_t ToFSensor = 1; // 0=Left, 1=Center(default), 2=Right
charlesmn 0:c77591fc308d 115
charlesmn 0:c77591fc308d 116
charlesmn 0:c77591fc308d 117 WaitForMeasurement* int2;
charlesmn 0:c77591fc308d 118 WaitForMeasurement* int1;
charlesmn 0:c77591fc308d 119 WaitForMeasurement* int3;
charlesmn 0:c77591fc308d 120
charlesmn 0:c77591fc308d 121 pc.baud(115200); // baud rate is important as printf statements take a lot of time
charlesmn 0:c77591fc308d 122
charlesmn 0:c77591fc308d 123 printf("Hello world!\r\n");
charlesmn 0:c77591fc308d 124
charlesmn 3:d6e7cc8dc1d0 125 vl53L3_DevI2C *dev_I2C = new vl53L3_DevI2C(I2C_SDA, I2C_SCL);
charlesmn 0:c77591fc308d 126
charlesmn 0:c77591fc308d 127 // printf("I2C device created! %d %d\r\n",dev_I2C,*dev_I2C);
charlesmn 0:c77591fc308d 128
charlesmn 0:c77591fc308d 129 /* creates the 53L1A1 expansion board singleton obj */
johnAlexander 4:79402ad13f5d 130 board = XNucleo53L3A2::instance(dev_I2C, A2, D8, D2);
charlesmn 0:c77591fc308d 131 printf("board created!\r\n");
charlesmn 0:c77591fc308d 132
charlesmn 0:c77591fc308d 133 /* init the 53L1A1 expansion board with default values */
charlesmn 0:c77591fc308d 134 status = board->init_board();
charlesmn 0:c77591fc308d 135 if (status) {
charlesmn 0:c77591fc308d 136 printf("Failed to init board!\r\n");
charlesmn 0:c77591fc308d 137 return 0;
charlesmn 0:c77591fc308d 138 }
charlesmn 0:c77591fc308d 139
charlesmn 0:c77591fc308d 140
charlesmn 0:c77591fc308d 141 printf("board initiated! - %d\r\n", status);
charlesmn 0:c77591fc308d 142
charlesmn 0:c77591fc308d 143 for (ToFSensor=0;ToFSensor<3;ToFSensor++){
charlesmn 0:c77591fc308d 144 wait_ms(15);
charlesmn 0:c77591fc308d 145 switch(ToFSensor){
charlesmn 0:c77591fc308d 146 case 0:
charlesmn 0:c77591fc308d 147 if (board->sensor_centre== NULL ) continue;
charlesmn 0:c77591fc308d 148 Dev=&devCentre;
charlesmn 0:c77591fc308d 149 Sensor=board->sensor_centre;
charlesmn 0:c77591fc308d 150 Dev->I2cDevAddr = NEW_SENSOR_CENTRE_ADDRESS;
charlesmn 0:c77591fc308d 151 printf("configuring centre channel \n");
charlesmn 0:c77591fc308d 152 break;
charlesmn 0:c77591fc308d 153 case 1:
charlesmn 0:c77591fc308d 154 if (board->sensor_left== NULL ) continue;
charlesmn 0:c77591fc308d 155 Dev=&devLeft;
charlesmn 0:c77591fc308d 156 Sensor=board->sensor_left;
charlesmn 0:c77591fc308d 157 Dev->I2cDevAddr = NEW_SENSOR_LEFT_ADDRESS;
charlesmn 0:c77591fc308d 158 printf("configuring left channel \n");
charlesmn 0:c77591fc308d 159 break;
charlesmn 0:c77591fc308d 160 case 2:
charlesmn 0:c77591fc308d 161 if (board->sensor_right== NULL ) continue;
charlesmn 0:c77591fc308d 162 Dev=&devRight;
charlesmn 0:c77591fc308d 163 Sensor=board->sensor_right;
charlesmn 0:c77591fc308d 164 Dev->I2cDevAddr = NEW_SENSOR_RIGHT_ADDRESS;
charlesmn 0:c77591fc308d 165 printf("configuring right channel \n");
charlesmn 0:c77591fc308d 166 break;
charlesmn 0:c77591fc308d 167 default:
charlesmn 0:c77591fc308d 168 printf(" error in switch, invalid ToF sensor \n");
charlesmn 0:c77591fc308d 169 }
charlesmn 0:c77591fc308d 170
charlesmn 0:c77591fc308d 171 // configure the sensors
charlesmn 0:c77591fc308d 172 Dev->comms_speed_khz = 400;
charlesmn 0:c77591fc308d 173
charlesmn 0:c77591fc308d 174 Dev->comms_type = 1;
charlesmn 0:c77591fc308d 175
charlesmn 0:c77591fc308d 176 Sensor->VL53LX_RdWord(Dev, 0x01, &wordData);
charlesmn 0:c77591fc308d 177 printf("VL53L1X: %02X %d\n\r", wordData,Dev->I2cDevAddr);
charlesmn 0:c77591fc308d 178 /* Device Initialization and setting */
charlesmn 0:c77591fc308d 179
charlesmn 0:c77591fc308d 180 status = Sensor->VL53LX_DataInit();
charlesmn 0:c77591fc308d 181 status = Sensor->VL53LX_SetDistanceMode(VL53LX_DISTANCEMODE_LONG);
charlesmn 0:c77591fc308d 182 status = Sensor->VL53LX_SetMeasurementTimingBudgetMicroSeconds( MEASUREMENTTIMING * 1000);
charlesmn 0:c77591fc308d 183 status = Sensor->VL53LX_SmudgeCorrectionEnable(VL53LX_SMUDGE_CORRECTION_SINGLE);
charlesmn 0:c77591fc308d 184 status = Sensor->VL53LX_SetXTalkCompensationEnable(1);
charlesmn 0:c77591fc308d 185
charlesmn 0:c77591fc308d 186
charlesmn 0:c77591fc308d 187 }
charlesmn 0:c77591fc308d 188
charlesmn 0:c77591fc308d 189 if (board->sensor_centre!= NULL )
charlesmn 0:c77591fc308d 190 {
charlesmn 0:c77591fc308d 191 printf("starting interrupt centre\n");
charlesmn 0:c77591fc308d 192 Sensor=board->sensor_centre;
charlesmn 0:c77591fc308d 193 devCentre.I2cDevAddr = NEW_SENSOR_CENTRE_ADDRESS;
charlesmn 0:c77591fc308d 194 int1 = new WaitForMeasurement(A2,&devCentre);
charlesmn 0:c77591fc308d 195 status = Sensor->VL53LX_StartMeasurement();
charlesmn 0:c77591fc308d 196 printf("VL53L1_StartMeasurement %d \n",status);
charlesmn 0:c77591fc308d 197 status = board->sensor_centre->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 198 }
charlesmn 0:c77591fc308d 199
charlesmn 0:c77591fc308d 200
charlesmn 0:c77591fc308d 201 if (board->sensor_left!= NULL )
charlesmn 0:c77591fc308d 202 {
charlesmn 0:c77591fc308d 203 printf("starting interrupt left\n");
charlesmn 0:c77591fc308d 204 Sensor=board->sensor_left;
charlesmn 0:c77591fc308d 205 devLeft.I2cDevAddr = NEW_SENSOR_LEFT_ADDRESS;
charlesmn 0:c77591fc308d 206 int2 = new WaitForMeasurement(D8,&devLeft);
charlesmn 0:c77591fc308d 207 status = Sensor->VL53LX_StartMeasurement();
charlesmn 0:c77591fc308d 208 printf("VL53L1_StartMeasurement %d \n",status);
charlesmn 0:c77591fc308d 209 status = board->sensor_left->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 210 }
charlesmn 0:c77591fc308d 211
charlesmn 0:c77591fc308d 212 if (board->sensor_right!= NULL )
charlesmn 0:c77591fc308d 213 {
charlesmn 0:c77591fc308d 214 printf("starting interrupt right\n");
charlesmn 0:c77591fc308d 215 Sensor=board->sensor_right;
charlesmn 0:c77591fc308d 216 devRight.I2cDevAddr = NEW_SENSOR_RIGHT_ADDRESS;
charlesmn 0:c77591fc308d 217 int3 = new WaitForMeasurement(D2,&devRight);
charlesmn 0:c77591fc308d 218 status = Sensor->VL53LX_StartMeasurement();
charlesmn 0:c77591fc308d 219 printf("VL53L1_StartMeasurement %d \n",status);
charlesmn 0:c77591fc308d 220 status = board->sensor_right->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 221 }
charlesmn 0:c77591fc308d 222
charlesmn 0:c77591fc308d 223
charlesmn 0:c77591fc308d 224 // loop waiting for interrupts to happen. This is signaled by int_centre_result,int_left_result or int_right_result
charlesmn 0:c77591fc308d 225 // being non zero. The are set back to zero when processing is completed
charlesmn 0:c77591fc308d 226 while (1)
charlesmn 0:c77591fc308d 227 {
charlesmn 0:c77591fc308d 228
charlesmn 0:c77591fc308d 229 VL53LX_MultiRangingData_t MultiRangingData;
charlesmn 0:c77591fc308d 230 VL53LX_MultiRangingData_t *pMultiRangingData = &MultiRangingData;
charlesmn 0:c77591fc308d 231
charlesmn 0:c77591fc308d 232 wait_ms( 1 * 10);
charlesmn 0:c77591fc308d 233 // printf("interruptcount %d \n",interruptcount);
charlesmn 0:c77591fc308d 234 if (int_centre_result != 0)
charlesmn 0:c77591fc308d 235 {
charlesmn 0:c77591fc308d 236 int_centre_result = 0;
charlesmn 0:c77591fc308d 237 // printf("int_centre_result \n");
charlesmn 0:c77591fc308d 238 status = board->sensor_centre->VL53LX_GetMultiRangingData( pMultiRangingData);
charlesmn 0:c77591fc308d 239 int no_of_object_found=pMultiRangingData->NumberOfObjectsFound;
charlesmn 0:c77591fc308d 240 // printf("int_centre_result %d %d \n",no_of_object_found,status);
charlesmn 0:c77591fc308d 241 if (( no_of_object_found < 10 ) && ( no_of_object_found != 0 ))
charlesmn 0:c77591fc308d 242 {
charlesmn 0:c77591fc308d 243 for(int j=0;j<no_of_object_found;j++){
charlesmn 0:c77591fc308d 244 if (pMultiRangingData->RangeData[j].RangeStatus == 0)
charlesmn 0:c77591fc308d 245 {
charlesmn 0:c77591fc308d 246 printf("centre\t status=%d, \t D=%5dmm, \t Signal=%2.2f Mcps, \t Ambient=%2.2f Mcps \n",
charlesmn 0:c77591fc308d 247 pMultiRangingData->RangeData[j].RangeStatus,
charlesmn 0:c77591fc308d 248 pMultiRangingData->RangeData[j].RangeMilliMeter,
charlesmn 0:c77591fc308d 249 pMultiRangingData->RangeData[j].SignalRateRtnMegaCps/65536.0,
charlesmn 0:c77591fc308d 250 pMultiRangingData->RangeData[j].AmbientRateRtnMegaCps/65536.0);
charlesmn 0:c77591fc308d 251 }
charlesmn 0:c77591fc308d 252 }
charlesmn 0:c77591fc308d 253 }
charlesmn 0:c77591fc308d 254 int_centre_result = 0;
charlesmn 0:c77591fc308d 255 wait_ms( MEASUREMENTTIMING );
charlesmn 0:c77591fc308d 256 status = board->sensor_centre->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 257 }
charlesmn 0:c77591fc308d 258
charlesmn 0:c77591fc308d 259
charlesmn 0:c77591fc308d 260 if (int_left_result != 0)
charlesmn 0:c77591fc308d 261 {
charlesmn 0:c77591fc308d 262 int_left_result = 0;
charlesmn 0:c77591fc308d 263 // printf("int_left_result \n");
charlesmn 0:c77591fc308d 264 status = board->sensor_left->VL53LX_GetMultiRangingData( pMultiRangingData);
charlesmn 0:c77591fc308d 265 // printf("int_left_result status %d \n",status);
charlesmn 0:c77591fc308d 266 if ( status == 0)
charlesmn 0:c77591fc308d 267 {
charlesmn 0:c77591fc308d 268 int no_of_object_found=pMultiRangingData->NumberOfObjectsFound;
charlesmn 0:c77591fc308d 269 // printf("int_left_result %d %d \n",no_of_object_found,status);
charlesmn 0:c77591fc308d 270 if (( no_of_object_found < 10 ) && ( no_of_object_found != 0 ))
charlesmn 0:c77591fc308d 271 {
charlesmn 0:c77591fc308d 272 for(int j=0;j<no_of_object_found;j++){
charlesmn 0:c77591fc308d 273 if (pMultiRangingData->RangeData[j].RangeStatus == 0)
charlesmn 0:c77591fc308d 274 {
charlesmn 0:c77591fc308d 275
charlesmn 0:c77591fc308d 276 printf("left \t status=%d, \t D=%5dmm, \t Signal=%2.2f Mcps, \t Ambient=%2.2f Mcps \n",
charlesmn 0:c77591fc308d 277 pMultiRangingData->RangeData[j].RangeStatus,
charlesmn 0:c77591fc308d 278 pMultiRangingData->RangeData[j].RangeMilliMeter,
charlesmn 0:c77591fc308d 279 pMultiRangingData->RangeData[j].SignalRateRtnMegaCps/65536.0,
charlesmn 0:c77591fc308d 280 pMultiRangingData->RangeData[j].AmbientRateRtnMegaCps/65536.0);
charlesmn 0:c77591fc308d 281 }
charlesmn 0:c77591fc308d 282 }
charlesmn 0:c77591fc308d 283 }
charlesmn 0:c77591fc308d 284 }
charlesmn 0:c77591fc308d 285 wait_ms( MEASUREMENTTIMING );
charlesmn 0:c77591fc308d 286 status = board->sensor_left->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 287
charlesmn 0:c77591fc308d 288 }
charlesmn 0:c77591fc308d 289
charlesmn 0:c77591fc308d 290
charlesmn 0:c77591fc308d 291 if (int_right_result != 0)
charlesmn 0:c77591fc308d 292 {
charlesmn 0:c77591fc308d 293 // clear interrupt flag
charlesmn 0:c77591fc308d 294 int_right_result = 0;
charlesmn 0:c77591fc308d 295 // printf("int_right_result \n");
charlesmn 0:c77591fc308d 296 status = board->sensor_right->VL53LX_GetMultiRangingData( pMultiRangingData);
charlesmn 0:c77591fc308d 297 if ( status == 0)
charlesmn 0:c77591fc308d 298 {
charlesmn 0:c77591fc308d 299 // printf("int_right_result status %d \n",status);
charlesmn 0:c77591fc308d 300 // if valid result print it
charlesmn 0:c77591fc308d 301 int no_of_object_found=pMultiRangingData->NumberOfObjectsFound;
charlesmn 0:c77591fc308d 302 // printf("int_right_result %d %d \n",no_of_object_found,status);
charlesmn 0:c77591fc308d 303 if (( no_of_object_found < 10 ) && ( no_of_object_found != 0 ))
charlesmn 0:c77591fc308d 304 {
charlesmn 0:c77591fc308d 305 for(int j=0;j<no_of_object_found;j++){
charlesmn 0:c77591fc308d 306 if (pMultiRangingData->RangeData[j].RangeStatus == 0)
charlesmn 0:c77591fc308d 307 {
charlesmn 0:c77591fc308d 308 // if(j!=0)printf("\n 0 ");
charlesmn 0:c77591fc308d 309 printf("right \t status=%d, \t D=%5dmm, \t Signal=%2.2f Mcps, \t Ambient=%2.2f Mcps \n",
charlesmn 0:c77591fc308d 310 pMultiRangingData->RangeData[j].RangeStatus,
charlesmn 0:c77591fc308d 311 pMultiRangingData->RangeData[j].RangeMilliMeter,
charlesmn 0:c77591fc308d 312 pMultiRangingData->RangeData[j].SignalRateRtnMegaCps/65536.0,
charlesmn 0:c77591fc308d 313 pMultiRangingData->RangeData[j].AmbientRateRtnMegaCps/65536.0);
charlesmn 0:c77591fc308d 314 }
charlesmn 0:c77591fc308d 315 }
charlesmn 0:c77591fc308d 316 }
charlesmn 0:c77591fc308d 317 }
charlesmn 0:c77591fc308d 318 wait_ms( MEASUREMENTTIMING );
charlesmn 0:c77591fc308d 319 // clear theinterrupt and wait for another result
charlesmn 0:c77591fc308d 320 status = board->sensor_right->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 321
charlesmn 0:c77591fc308d 322 }
charlesmn 0:c77591fc308d 323 /*
charlesmn 0:c77591fc308d 324 if ( interruptcount > 10000)
charlesmn 0:c77591fc308d 325 {
charlesmn 0:c77591fc308d 326 printf("interruptcount exceeded \n");
charlesmn 0:c77591fc308d 327 int_left_result = 0;
charlesmn 0:c77591fc308d 328 int_centre_result = 0;
charlesmn 0:c77591fc308d 329 int_right_result = 0;
charlesmn 0:c77591fc308d 330 if (board->sensor_centre!= NULL )
charlesmn 0:c77591fc308d 331 status = board->sensor_centre->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 332 if (board->sensor_left!= NULL )
charlesmn 0:c77591fc308d 333 status = board->sensor_left->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 334 if (board->sensor_right!= NULL )
charlesmn 0:c77591fc308d 335 status = board->sensor_right->VL53LX_ClearInterruptAndStartMeasurement();
charlesmn 0:c77591fc308d 336 interruptcount = 0;
charlesmn 0:c77591fc308d 337 }
charlesmn 0:c77591fc308d 338 */
charlesmn 0:c77591fc308d 339
charlesmn 0:c77591fc308d 340 }
charlesmn 0:c77591fc308d 341 printf("terminated");
charlesmn 0:c77591fc308d 342 }
johnAlexander 4:79402ad13f5d 343
johnAlexander 4:79402ad13f5d 344 #if (MBED_VERSION > 60300)
johnAlexander 4:79402ad13f5d 345 extern "C" void wait_ms(int ms)
johnAlexander 4:79402ad13f5d 346 {
johnAlexander 4:79402ad13f5d 347 thread_sleep_for(ms);
johnAlexander 4:79402ad13f5d 348 }
johnAlexander 4:79402ad13f5d 349 #endif