The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2

Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.

Revision:
14:f06785b2a964
Parent:
13:ea6d0e60fd02
Child:
15:c0d8d300479f
--- a/inc/VL53L1CB.h	Mon Jun 14 07:57:55 2021 +0000
+++ b/inc/VL53L1CB.h	Sat Jun 19 16:45:54 2021 +0100
@@ -30,9 +30,19 @@
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
-#ifndef __VL53L1X_CLASS_H
-#define __VL53L1X_CLASS_H
+#ifndef __VL53L1CB_CLASS_H
+#define __VL53L1CB_CLASS_H
+
 
+#ifdef _MSC_VER
+#   ifdef VL53L1X_API_EXPORTS
+#       define VL53L1X_API  __declspec(dllexport)
+#   else
+#       define VL53L1X_API
+#   endif
+#else
+#   define VL53L1X_API
+#endif
 
 
 /* Includes ------------------------------------------------------------------*/
@@ -53,16 +63,16 @@
 /***********************************************************/
 
 
-#define VL53L1CB_IMPLEMENTATION_VER_MAJOR       1
-#define VL53L1CB_IMPLEMENTATION_VER_MINOR       0
-#define VL53L1CB_IMPLEMENTATION_VER_SUB         1
-#define VL53L1CB_IMPLEMENTATION_VER_REVISION  0000
+#define VL53L1_IMPLEMENTATION_VER_MAJOR       1
+#define VL53L1_IMPLEMENTATION_VER_MINOR       0
+#define VL53L1_IMPLEMENTATION_VER_SUB         1
+#define VL53L1_IMPLEMENTATION_VER_REVISION  0000
 
 typedef int8_t VL53L1CB_ERROR;
 
 //#define SOFT_RESET                                          0x0000
-#define VL53L1CB_I2C_SLAVE__DEVICE_ADDRESS                    0x0001
-#define VL53L1CB_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND        0x0008
+#define VL53L1_I2C_SLAVE__DEVICE_ADDRESS                    0x0001
+#define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND        0x0008
 #define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS      0x0016
 #define ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS  0x0018
 #define ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS  0x001A
@@ -81,6 +91,7 @@
 #define RANGE_CONFIG__SIGMA_THRESH                          0x0064
 #define RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS         0x0066
 #define RANGE_CONFIG__VALID_PHASE_HIGH                      0x0069
+#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD              0x006C
 #define SYSTEM__THRESH_HIGH                                 0x0072
 #define SYSTEM__THRESH_LOW                                  0x0074
 #define SD_CONFIG__WOI_SD0                                  0x0078
@@ -88,17 +99,23 @@
 #define ROI_CONFIG__USER_ROI_CENTRE_SPAD                    0x007F
 #define ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE       0x0080
 #define SYSTEM__SEQUENCE_CONFIG                             0x0081
+#define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD               0x0082
 #define SYSTEM__INTERRUPT_CLEAR                             0x0086
 #define SYSTEM__MODE_START                                  0x0087
+#define VL53L1_RESULT__RANGE_STATUS                         0x0089
+#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0       0x008C
 #define RESULT__AMBIENT_COUNT_RATE_MCPS_SD                  0x0090
-#define VL53L1CB_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0               0x0096
-#define VL53L1CB_FIRMWARE__SYSTEM_STATUS                      0x00E5
+#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0               0x0096
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0  0x0098
+#define VL53L1_RESULT__OSC_CALIBRATE_VAL                    0x00DE
+#define VL53L1_FIRMWARE__SYSTEM_STATUS                      0x00E5
+#define VL53L1_IDENTIFICATION__MODEL_ID                     0x010F
+#define VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD             0x013E
 
 
+#define VL53L1_DEFAULT_DEVICE_ADDRESS                      0x52
 
-#define VL53L1CB_DEFAULT_DEVICE_ADDRESS                      0x52
-
-#define VL53L1CB_REG_IDENTIFICATION_MODEL_ID                 0x010F
+#define VL53L1_REG_IDENTIFICATION_MODEL_ID                 0x010F
 
 /****************************************
  * PRIVATE define do not edit
@@ -116,7 +133,7 @@
 
 
 /* Classes -------------------------------------------------------------------*/
-/** Class representing a VL53L1CB sensor component
+/** Class representing a VL53L1 sensor component
  */
 class VL53L1CB : public RangeSensor
 {
@@ -132,8 +149,8 @@
      * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
      * @param[in] DevAddr device address, 0x52 by default
      */
-/*
-    VL53L1CB(ToF_DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L1CB_DEFAULT_DEVICE_ADDRESS) 
+
+    VL53L1CB(ToF_DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L1_DEFAULT_DEVICE_ADDRESS) 
     : RangeSensor(), dev_i2c(i2c), _gpio0(pin)
     {
         MyDevice.i2c_slave_address=dev_addr;
@@ -146,7 +163,7 @@
             _gpio1Int = NULL;
         }
     }
-*/
+
     
     /** Constructor 2 (STMPE1600DigiOut)
      * @param[in] i2c device I2C to be used for communication
@@ -155,7 +172,7 @@
      * @param[in] device address, 0x29 by default
      */
     VL53L1CB(ToF_DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1,
-            uint8_t dev_addr = VL53L1CB_DEFAULT_DEVICE_ADDRESS) 
+            uint8_t dev_addr = VL53L1_DEFAULT_DEVICE_ADDRESS) 
             : dev_i2c(i2c), _expgpio0(pin)
     {
         MyDevice.i2c_slave_address=dev_addr;
@@ -183,7 +200,7 @@
     VL53L1_DEV getDevicePtr() { return Device; }
 
     
-    /* warning: VL53L1CB class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor.
+    /* warning: VL53L1 class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor.
        The warning should request to introduce a virtual destructor to make sure to delete the object */
 
     /*** Interface Methods ***/
@@ -195,7 +212,7 @@
     /* turns on the sensor */
     virtual void VL53L1CB_On(void)
     {
-        printf("VL53L1CB_On\r\n");
+        printf("VL53L1_On\r\n");
         if (_gpio0) {
             *_gpio0 = 1;
         } else {
@@ -302,15 +319,15 @@
         ExpanderData[0] = 0;
         ExpanderData[1] = 0;
         rl_id = 0;
-        dev_i2c->ToF_i2c_read(&ExpanderData[0], Device->i2c_slave_address, VL53L1CB_REG_IDENTIFICATION_MODEL_ID, 2);
+        dev_i2c->ToF_i2c_read(&ExpanderData[0], Device->i2c_slave_address, VL53L1_REG_IDENTIFICATION_MODEL_ID, 2);
     
         rl_id = (ExpanderData[0] << 8) + ExpanderData[1];
         printf("Model ID is: %d (%X)  \r\n",rl_id, rl_id);
     
         uint8_t tmp = 0;
-        ExpanderData[0] = VL53L1CB_FIRMWARE__SYSTEM_STATUS >> 8;
-        ExpanderData[1] = VL53L1CB_FIRMWARE__SYSTEM_STATUS & 0x0FF;
-        dev_i2c->ToF_i2c_read(&tmp, Device->i2c_slave_address, VL53L1CB_FIRMWARE__SYSTEM_STATUS, 1);
+        ExpanderData[0] = VL53L1_FIRMWARE__SYSTEM_STATUS >> 8;
+        ExpanderData[1] = VL53L1_FIRMWARE__SYSTEM_STATUS & 0x0FF;
+        dev_i2c->ToF_i2c_read(&tmp, Device->i2c_slave_address, VL53L1_FIRMWARE__SYSTEM_STATUS, 1);
 
         printf("Firmware system is: %d\r\n",tmp);
     
@@ -497,7 +514,7 @@
     
     VL53L1CB_ERROR VL53L1CB_StaticInit();
         
-    VL53L1CB_ERROR VL53L1CB_ClearInterruptAndStartMeasurement();
+    VL53L1CB_ERROR VL53L1CB_learInterruptAndStartMeasurement();
     
     VL53L1CB_ERROR VL53L1CB_GetRangingMeasurementData(
         VL53L1_RangingMeasurementData_t *pRangingMeasurementData);
@@ -621,7 +638,7 @@
                                            
     VL53L1CB_ERROR VL53L1CB_SetROI(VL53L1_RoiConfig_t *pRoiConfig);
                                 
-    VL53L1CB_ERROR VL53L1CB_GetROI(VL53L1_RoiConfig_t *pRoiConfig);
+     VL53L1CB_ERROR VL53L1CB_GetROI(VL53L1_RoiConfig_t *pRoiConfig);
                                  
     VL53L1CB_ERROR VL53L1CB_GetNumberOfSequenceSteps(uint8_t *pNumberOfSequenceSteps);          
     
@@ -650,13 +667,13 @@
 
     /* Write and read functions from I2C */
 
-    VL53L1CB_ERROR VL53L1CB_WrByte(VL53L1_DEV dev, uint16_t index, uint8_t data);
-    VL53L1CB_ERROR VL53L1CB_WrWord(VL53L1_DEV dev, uint16_t index, uint16_t data);
-    VL53L1CB_ERROR VL53L1CB_WrDWord(VL53L1_DEV dev, uint16_t index, uint32_t data);
-    VL53L1CB_ERROR VL53L1CB_RdByte(VL53L1_DEV dev, uint16_t index, uint8_t *data);
-    VL53L1CB_ERROR VL53L1CB_RdWord(VL53L1_DEV dev, uint16_t index, uint16_t *data);
-    VL53L1CB_ERROR VL53L1CB_RdDWord(VL53L1_DEV dev, uint16_t index, uint32_t *data);
-    VL53L1CB_ERROR VL53L1CB_UpdateByte(VL53L1_DEV dev, uint16_t index, uint8_t AndData, uint8_t OrData);
+    VL53L1CB_ERROR VL53L1_WrByte(VL53L1_DEV dev, uint16_t index, uint8_t data);  // DON'T CHANGE NAME, SATELLITES STOP WORKING
+    VL53L1CB_ERROR VL53L1_WrWord(VL53L1_DEV dev, uint16_t index, uint16_t data); // DON'T CHANGE NAME,  SATELLITES STOP WORKING
+    VL53L1CB_ERROR VL53L1_WrDWord(VL53L1_DEV dev, uint16_t index, uint32_t data); // DON'T CHANGE NAME, SATELLITES STOP WORKING
+    VL53L1CB_ERROR VL53L1_RdByte(VL53L1_DEV dev, uint16_t index, uint8_t *data); // DON'T CHANGE NAME,  SATELLITES STOP WORKING
+    VL53L1CB_ERROR VL53L1_RdWord(VL53L1_DEV dev, uint16_t index, uint16_t *data); // DON'T CHANGE NAME, SATELLITES STOP WORKING
+    VL53L1CB_ERROR VL53L1_RdDWord(VL53L1_DEV dev, uint16_t index, uint32_t *data);// DON'T CHANGE NAME,  SATELLITES STOP WORKING
+    VL53L1CB_ERROR VL53L1_UpdateByte(VL53L1_DEV dev, uint16_t index, uint8_t AndData, uint8_t OrData); // DON'T CHANGE NAME,  SATELLITES STOP WORKING
 
     VL53L1CB_ERROR VL53L1CB_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count);
     VL53L1CB_ERROR VL53L1CB_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count);