Library for use with VL53L1X, intended to represent the Proximity sensor expansion board with the same name.
Dependencies: VL53L1X_mbed
Dependents: HelloWorld_53L1A1 VL53L1A1_Simple_Ranging_With_One_Device VL53L1A1_Simple_Ranging_With_All_Devices VL53L1X_Ranging_With_Multiple_Devices_MbedOS ... more
Diff: Components/VL53L0X/vl53l0x_class.h
- Revision:
- 12:f6e2bad00dc7
- Parent:
- 11:ceaa5a026412
- Child:
- 13:615f7e38568c
diff -r ceaa5a026412 -r f6e2bad00dc7 Components/VL53L0X/vl53l0x_class.h
--- a/Components/VL53L0X/vl53l0x_class.h Mon Jun 12 13:59:20 2017 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h Wed Jun 14 14:39:27 2017 +0000
@@ -61,7 +61,7 @@
#define STATUS_FAIL 0x01
-#define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int)
+#define VL53L0X_OsDelay(...) HAL_Delay(2)
#ifdef USE_EMPTY_STRING
#define VL53L0X_STRING_DEVICE_INFO_NAME ""
@@ -584,8 +584,9 @@
*/
int RangeStartContinuousMode()
{
-// return VL6180x_RangeStartContinuousMode(Device);
- return 1;
+ int status;
+ status = RangeSetSystemMode(VL53L0X_REG_SYSRANGE_MODE_START_STOP|VL53L0X_REG_SYSRANGE_MODE_BACKTOBACK);
+ return status;
}
/**
@@ -733,8 +734,18 @@
*/
int RangeConfigInterrupt(uint8_t ConfigGpioInt)
{
-// return VL6180x_RangeConfigInterrupt(Device, ConfigGpioInt);
- return 1;
+ int status;
+ if( ConfigGpioInt<= VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY)
+ {
+ status = VL53L0X_UpdateByte(Device, VL53L0X_REG_SYSTEM_INTERRUPT_CONFIG_GPIO, (uint8_t)(~(0x7<<0)), ConfigGpioInt);
+ }
+ else
+ {
+ status = 1;
+ }
+ // return VL6180x_RangeConfigInterrupt(Device, ConfigGpioInt);
+
+ return status;
}
/**
@@ -986,9 +997,24 @@
* @return 0 on success
*/
int RangeSetSystemMode(uint8_t mode)
- {
+ {
+ int status;
+ /* FIXME we are not checking device is ready via @a VL6180X_RangeWaitDeviceReady
+ * so if called back to back real fast we are not checking
+ * if previous mode "set" got absorbed => bit 0 must be 0 so that it work
+ */
+ if( mode <= 3){
+ status=VL53L0X_WrByte(Device, VL53L0X_REG_SYSRANGE_START, mode);
+ if( status ){
+ VL53L0X_ErrLog("SYSRANGE_START wr fail");
+ }
+ }
+ else{
+ status = 1;
+ }
+ return status;
// return VL6180x_RangeSetSystemMode(Device, mode);
- return 1;
+// return 1;
}
/** @} */
@@ -1056,8 +1082,7 @@
if(!status)
Device->I2cDevAddr=NewAddr;
return status;
-
-// return 1;
+
}
/**
@@ -1146,8 +1171,9 @@
*/
int ClearInterrupt(uint8_t IntClear)
{
+ int status = VL53L0X_WrByte(Device, VL53L0X_REG_SYSTEM_INTERRUPT_CLEAR, IntClear);
// return VL6180x_ClearInterrupt(Device, IntClear );
- return 1;
+ return status;
}
/**
X-NUCLEO-53L1A1 Ranging Sensor Expansion Board