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:
12:f6e2bad00dc7
Parent:
11:ceaa5a026412
Child:
13:615f7e38568c
--- 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;
     }
 
 /**