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:
4:4e1576541eed
Parent:
0:c523920bcc09
Child:
7:35ecf3e060c3
--- a/Components/VL53L0X/vl53l0x_class.h	Mon Nov 28 14:52:49 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h	Mon Dec 05 11:03:50 2016 +0000
@@ -42,6 +42,7 @@
 
 
 /* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
 #include "RangeSensor.h"
 #include "DevI2C.h" 
 
@@ -372,10 +373,10 @@
 	 */					 
     int InitSensor(uint8_t NewAddr);
     
-    int RawInitSensor(void);
-    int initDevice(VL53L0X_DEV Dev);
-    int setLongRangePresets(VL53L0X_DEV Dev);
-    int DoRanging(VL53L0X_Dev_t *pMyDevice);
+//    int RawInitSensor(void);
+//    int initDevice(VL53L0X_DEV Dev);
+//    int setLongRangePresets(VL53L0X_DEV Dev);
+//    int DoRanging(VL53L0X_Dev_t *pMyDevice);
 
 
 
@@ -491,10 +492,11 @@
  * @param void
  * @return     0 on success,  @a #CALIBRATION_WARNING if failed
  */		
-    virtual int Init() 
+//    virtual int Init()
+    virtual int Init(void *NewAddr)
     {
-       return VL53L0X_DataInit(&MyDevice);
-//       return VL53L0X_DataInit(Device);
+//       return VL53L0X_DataInit(&MyDevice);
+       return VL53L0X_DataInit(Device);
 //			return 1;
     }
 
@@ -687,10 +689,25 @@
  * @param pRange_mm  Pointer to range distance
  * @return           0 on success
  */		
-    virtual int GetRange(int32_t *piData)
+    virtual int GetDistance(uint32_t *piData)
     {
-//       return VL6180x_RangeGetResult(Device, piData);
-			return 1;
+        int status=0;
+        VL53L0X_RangingMeasurementData_t pRangingMeasurementData;
+
+        status=StartMeasurement(range_single_shot_polling, NULL);
+        if (!status) {
+            status=GetMeasurement(range_single_shot_polling, &pRangingMeasurementData);
+        }
+        if (pRangingMeasurementData.RangeStatus == 0) {
+        // we have a valid range.
+            *piData = pRangingMeasurementData.RangeMilliMeter;
+        }
+        else {
+            *piData = 0;
+            status = VL53L0X_ERROR_RANGE_ERROR;
+        }
+        StopMeasurement(range_single_shot_polling);
+        return status;
     }
 		
 /**
@@ -1325,7 +1342,7 @@
     		VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo);
 
     /* Read function of the ID device */
-    virtual int ReadID();
+    virtual int ReadID(uint8_t *id);
     
     VL53L0X_Error WaitMeasurementDataReady(VL53L0X_DEV Dev);
     VL53L0X_Error WaitStopCompleted(VL53L0X_DEV Dev);
@@ -1352,7 +1369,7 @@
     {
        int status;
 			
-       status=ReadID();
+       status=ReadID((uint8_t *)MyDevice.I2cDevAddr);
        if(status)
           VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r");
        return status;