Skip to content

Commit

Permalink
adding timeout to sensorInit function
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew England committed Jan 6, 2020
1 parent 4de6811 commit 9d3e0e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun VL53L1X 4m Laser Distance Sensor
version=1.2.2
version=1.2.3
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for the SparkFun Qwiic 4m Distance Sensor - VL53L1X
Expand Down
10 changes: 8 additions & 2 deletions src/vl53l1x_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,20 @@ VL53L1X_ERROR VL53L1X::VL53L1X_SetI2CAddress(uint8_t new_address)
VL53L1X_ERROR VL53L1X::VL53L1X_SensorInit()
{
VL53L1X_ERROR status = 0;
uint8_t Addr = 0x00, tmp=0;
uint8_t Addr = 0x00, tmp=0, timeout = 0;

for (Addr = 0x2D; Addr <= 0x87; Addr++){
status = VL53L1_WrByte(Device, Addr, VL51L1X_DEFAULT_CONFIGURATION[Addr - 0x2D]);
}
status = VL53L1X_StartRanging();
while(tmp==0){
status = VL53L1X_CheckForDataReady(&tmp);
status = VL53L1X_CheckForDataReady(&tmp);
timeout++;
if (timeout > 50)
{
status = VL53L1_ERROR_TIME_OUT;
return status;
}
}
tmp = 0;
status = VL53L1X_ClearInterrupt();
Expand Down

0 comments on commit 9d3e0e4

Please sign in to comment.