Library to handle the X-NUCLEO-6180XA1 Proximity and ambient light sensor expansion board based on VL6180X.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_6180XA1 SunTracker_BLE Servo_6180XA1 BLE_HR_Light ... more

Fork of X_NUCLEO_6180XA1 by ST Expansion SW Team

X-NUCLEO-6180XA1 Proximity and Ambient Light Sensor Expansion Board Firmware Package

Introduction

This firmware package includes Components Device Drivers and Board Support Package for STMicroelectronics' X-NUCLEO-6180XA1 Proximity and ambient light sensor expansion board based on VL6180X.

Firmware Library

Class X_NUCLEO_6180XA1 is intended to represent the Proximity and ambient light sensor expansion board with the same name.

The expansion board is providing the support of the following components:

  1. on-board VL6180X proximity and ambient light sensor,
  2. up to three additional VL6180X Satellites,
  3. on-board 4-digit display

It is intentionally implemented as a singleton because only one X-NUCLEO-VL6180XA1 at a time might be deployed 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_6180XA1 *6180X_expansion_board = X_NUCLEO_6180XA1::Instance();

Arduino Connector Compatibility Warning

Using the X-NUCLEO-6180XA1 expansion board with the NUCLEO-F429ZI requires adopting the following patch:

  • to remove R46 resistor connected to A3 pin;
  • to solder R47 resistor connected to A5 pin.

Alternatively, you can route the Nucleo board’s A5 pin directly to the expansion board’s A3 pin with a wire. In case you patch your expansion board or route the pin, the interrupt signal for the front sensor will be driven on A5 pin rather than on A3 pin.


Example Applications

Files at this revision

API Documentation at this revision

Comitter:
mapellil
Date:
Tue Nov 10 10:46:15 2015 +0000
Parent:
31:f99c53a51917
Child:
33:1573db91352c
Commit message:
Extended Doxy doc

Changed in this revision

Components/VL6180X/vl6180x_class.h Show annotated file Show diff for this revision Revisions of this file
--- a/Components/VL6180X/vl6180x_class.h	Mon Nov 09 15:37:48 2015 +0000
+++ b/Components/VL6180X/vl6180x_class.h	Tue Nov 10 10:46:15 2015 +0000
@@ -102,7 +102,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  
      */
-    VL6180X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), gpio0(&pin), interrupt_measure(pin_gpio1)
+    VL6180X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), gpio0(&pin), gpio1Int(pin_gpio1)
     {
        MyDevice.I2cAddr=DevAddr;		 
        MyDevice.Present=0;
@@ -116,7 +116,7 @@
      * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
      * @param[in] device address, 0x29 by default  
      */		
-    VL6180X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), expgpio0(&pin), interrupt_measure(pin_gpio1)
+    VL6180X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), expgpio0(&pin), gpio1Int(pin_gpio1)
     {
        MyDevice.I2cAddr=DevAddr;		 
        MyDevice.Present=0;
@@ -132,6 +132,7 @@
        The warning should request to introduce a virtual destructor to make sure to delete the object */
 
 	/*** Interface Methods ***/	
+	/*** High level API ***/		
 	/**
 	 * @brief       PowerOn the sensor
 	 * @return      void
@@ -167,9 +168,9 @@
 	/**
 	 * @brief       Start the measure indicated by operating mode
 	 * @param[in]   operating_mode specifies requested measure 
-	 * @param[in]   fptr specifies call back function in case of interrupt measure	 
-	 * @param[in]   low specifies measure low threashold
-	 * @param[in]   high specifies measure high threashold	 
+	 * @param[in]   fptr specifies call back function must be !NULL in case of interrupt measure	 
+	 * @param[in]   low specifies measure low threashold in Lux or in mm according to measure
+	 * @param[in]   high specifies measure high threashold in Lux or in mm according to measure
 	 * @return      0 on Success
 	 */					     
     int StartMeasurement(OperatingMode operating_mode, void (*fptr)(void), uint16_t low, uint16_t high);
@@ -189,15 +190,13 @@
 	 */					             
     int StopMeasurement(OperatingMode operating_mode);
      
-	/**
-	 * @brief       Attach a function to call when an interrupt is detected, i.e. measurement is ready
-	 * @param[in]   fptr pointer to call back function to be called whenever an interrupt occours
+ 	/**
+	 * @brief       Interrupt handling func to be called by user after an INT is occourred
+	 * @param[in]   opeating_mode indicating the in progress measure
+	 * @param[out]  Data pointer to the MeasureData_t structure to read data in to
 	 * @return      0 on Success
-	 */					                  
-    void AttachInterruptMeasureDetectionIRQ(void (*fptr)(void))
-    {
-       interrupt_measure.rise(fptr);
-    }
+	 */					          		
+    int HandleIRQ(OperatingMode operating_mode, MeasureData_t *Data);    
 
 	/**
 	 * @brief       Enable interrupt measure IRQ
@@ -205,7 +204,7 @@
 	 */					     
     void EnableInterruptMeasureDetectionIRQ(void) 
     {
-       interrupt_measure.enable_irq();
+       gpio1Int.enable_irq();
     }
 
 	/**
@@ -214,18 +213,21 @@
 	 */					          
     void DisableInterruptMeasureDetectionIRQ(void) 
     {
-       interrupt_measure.disable_irq();
+       gpio1Int.disable_irq();
+    }
+	/*** End High level API ***/	          
+	
+	/**
+	 * @brief       Attach a function to call when an interrupt is detected, i.e. measurement is ready
+	 * @param[in]   fptr pointer to call back function to be called whenever an interrupt occours
+	 * @return      0 on Success
+	 */					                  
+    void AttachInterruptMeasureDetectionIRQ(void (*fptr)(void))
+    {
+       gpio1Int.rise(fptr);
     }
     
 	/**
-	 * @brief       Interrupt handling func to be called by user after an INT is occourred
-	 * @param[in]   opeating_mode indicating the in progress measure
-	 * @param[out]  Data pointer to the MeasureData_t structure to read data in to
-	 * @return      0 on Success
-	 */					          		
-    int HandleIRQ(OperatingMode operating_mode, MeasureData_t *Data);
-
-	/**
 	 * @brief       Check the sensor presence
 	 * @return      1 when device is present
 	 */						
@@ -234,7 +236,12 @@
        return Device->Present;
     }
 		
-    /* Wrapper functions */	
+    /** Wrapper functions */	
+    
+ 	/**
+	 * @brief       Wait sensor to boot
+	 * @return      0 when device is booted
+	 */		   
     int WaitDeviceBooted()
     {
        return VL6180x_WaitDeviceBooted(Device);
@@ -623,7 +630,7 @@
     /* GPIO expander */
     STMPE1600DigiOut *expgpio0;
     /* Measure detection IRQ */
-    InterruptIn interrupt_measure;
+    InterruptIn gpio1Int;
     /* Device data */
     MyVL6180Dev_t MyDevice;
     VL6180xDev_t Device;