Library for use with VL53L0X, cut 1.1, based on mass-market API v1.1.

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Dependents:   ConcorsoFinal HelloWorld_IHM01A1 m3pi_BT m3pi_LIDAR ... more

Fork of X_NUCLEO_53L0A1 by ST Expansion SW Team

X-NUCLEO-53L0A1 Proximity Sensor Expansion Board Firmware Package

Introduction

This firmware package includes Component Device Drivers and the Board Support Package for STMicroelectronics' X-NUCLEO-53L0A1 Proximity sensor expansion board based on VL53L0X.

Firmware Library

Class X_NUCLEO_53L0A1 is intended to represent the Proximity sensor expansion board with the same name.

The expansion board provides support for the following components:

  1. on-board VL53L0X proximity sensor,
  2. up to two additional VL53L0X Satellites,
  3. on-board 4-digit display

It is intentionally implemented as a singleton because only one X-NUCLEO-VL53L0A1 may be deployed at a time in a HW component stack. In order to get the singleton instance you have to call class method `Instance()`, e.g.:

// Sensors expansion board singleton instance
static X_NUCLEO_53L0A1 *board = X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);

Example Applications

The library and sample application code were tested against mbed revision 143, dated 26th May 2017.

Revision:
11:ceaa5a026412
Parent:
10:faf8d62ce6d1
Child:
12:f6e2bad00dc7
--- a/Components/VL53L0X/vl53l0x_class.h	Wed Jun 07 14:58:36 2017 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h	Mon Jun 12 13:59:20 2017 +0000
@@ -61,7 +61,7 @@
 #define STATUS_FAIL            0x01
 
 
-#define VL53L0X_OsDelay(...) HAL_Delay(2)
+#define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int)
 
 #ifdef USE_EMPTY_STRING
 	#define  VL53L0X_STRING_DEVICE_INFO_NAME                             ""
@@ -303,7 +303,7 @@
      * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
      * @param[in] DevAddr device address, 0x29 by default  
      */
-    VL53L0X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), dev_i2c(i2c), gpio0(&pin)
+    VL53L0X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : dev_i2c(i2c), gpio0(&pin)
     {
        MyDevice.I2cDevAddr=DevAddr;		 
        MyDevice.comms_type=1; // VL53L0X_COMMS_I2C
@@ -320,7 +320,7 @@
      * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
      * @param[in] device address, 0x29 by default  
      */		
-    VL53L0X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), dev_i2c(i2c), expgpio0(&pin)
+    VL53L0X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : dev_i2c(i2c), expgpio0(&pin)
     {
        MyDevice.I2cDevAddr=DevAddr;		 
        MyDevice.comms_type=1; // VL53L0X_COMMS_I2C
@@ -479,6 +479,7 @@
 //			return 1;
     }
 
+
 /**
  *
  * @brief One time device initialization
@@ -495,9 +496,16 @@
  * @param void
  * @return     0 on success,  @a #CALIBRATION_WARNING if failed
  */		
+ 	virtual int init(void *init)
+	{
+		return VL53L0X_DataInit(Device);
+	}
+	
+/** deprecated Init funtion from ComponentObject. for backward compatibility
+*/	
     virtual int Init(void * NewAddr)
     {
-       return VL53L0X_DataInit(Device);
+    	return init(NewAddr);
     }
 
 /**
@@ -687,7 +695,7 @@
  * @param pRange_mm  Pointer to range distance
  * @return           0 on success
  */		
-    virtual int GetDistance(uint32_t *piData)
+    virtual int get_distance(uint32_t *piData)
     {
         int status=0;
         VL53L0X_RangingMeasurementData_t pRangingMeasurementData;
@@ -707,7 +715,11 @@
         StopMeasurement(range_single_shot_polling);
         return status;
     }
-		
+/* Deprecated funtion from RangeSensor class. For backward compatibility*/	
+	virtual int GetDistance(uint32_t *piData)
+	{
+		return get_distance(piData);
+	}	
 /**
  * @brief Configure ranging interrupt reported to application
  *
@@ -1339,9 +1351,13 @@
     		uint8_t *Revision,
     		VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo);
 
-    /* Read function of the ID device */
-//    virtual int ReadID();
+	/* deprecated Read function from Component class for backward compatibility*/
+	//   virtual int ReadID();
     virtual int ReadID(uint8_t *id);
+
+	/* Read function of the ID device */
+	//   virtual int read_id();    
+    virtual int read_id(uint8_t *id);
     
     VL53L0X_Error WaitMeasurementDataReady(VL53L0X_DEV Dev);
     VL53L0X_Error WaitStopCompleted(VL53L0X_DEV Dev);