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
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:
- on-board VL6180X proximity and ambient light sensor,
- up to three additional VL6180X Satellites,
- 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
A3pin; - to solder R47 resistor connected to
A5pin.
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
Revision 42:692c6223dc24, committed 2016-03-11
- Comitter:
- fabiombed
- Date:
- Fri Mar 11 09:47:43 2016 +0000
- Parent:
- 41:2e00362bdb8e
- Child:
- 43:8120a1ff3055
- Commit message:
- Now you can use NC as InterruptIn
Changed in this revision
| Components/VL6180X/vl6180x_class.h | Show annotated file Show diff for this revision Revisions of this file |
| x_nucleo_6180xa1.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Components/VL6180X/vl6180x_class.h Thu Mar 03 10:43:01 2016 +0000
+++ b/Components/VL6180X/vl6180x_class.h Fri Mar 11 09:47:43 2016 +0000
@@ -96,35 +96,37 @@
class VL6180X : public RangeSensor, public LightSensor
{
public:
- /** Constructor 1
+ /** Constructor 1 (DigitalOut)
* @param[in] &i2c device I2C to be used for communication
* @param[in] &pin Mbed DigitalOut pin to be used as component GPIO_0 CE
- * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
+ * @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), gpio1Int(pin_gpio1)
+ VL6180X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), gpio0(&pin)
{
MyDevice.I2cAddr=DevAddr;
MyDevice.Present=0;
MyDevice.Ready=0;
Device=&MyDevice;;
expgpio0=NULL;
- gpio1Pin=pin_gpio1;
+ if (pin_gpio1 != NC) { gpio1Int = new InterruptIn(pin_gpio1); }
+ else { gpio1Int = NULL; }
}
- /** Constructor 2
+ /** Constructor 2 (STMPE1600DigiOut)
* @param[in] i2c device I2C to be used for communication
* @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE
* @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), gpio1Int(pin_gpio1)
+ VL6180X(DevI2C &i2c, STMPE1600DigiOut &pin, PinName pin_gpio1, uint8_t DevAddr=DEFAULT_DEVICE_ADDRESS) : RangeSensor(), LightSensor(), dev_i2c(i2c), expgpio0(&pin)
{
MyDevice.I2cAddr=DevAddr;
MyDevice.Present=0;
MyDevice.Ready=0;
Device=&MyDevice;
gpio0=NULL;
- gpio1Pin=pin_gpio1;
+ if (pin_gpio1 != NC) { gpio1Int = new InterruptIn(pin_gpio1); }
+ else { gpio1Int = NULL; }
}
/** Destructor
@@ -206,7 +208,7 @@
*/
void EnableInterruptMeasureDetectionIRQ(void)
{
- if (gpio1Pin != NC) gpio1Int.enable_irq();
+ if (gpio1Pin != NC) gpio1Int->enable_irq();
}
/**
@@ -215,7 +217,7 @@
*/
void DisableInterruptMeasureDetectionIRQ(void)
{
- if (gpio1Pin != NC) gpio1Int.disable_irq();
+ if (gpio1Pin != NC) gpio1Int->disable_irq();
}
/*** End High level API ***/
@@ -226,7 +228,7 @@
*/
void AttachInterruptMeasureDetectionIRQ(void (*fptr)(void))
{
- if (gpio1Pin != NC) gpio1Int.rise(fptr);
+ if (gpio1Pin != NC) gpio1Int->rise(fptr);
}
/**
@@ -1187,7 +1189,7 @@
/* GPIO expander */
STMPE1600DigiOut *expgpio0;
/* Measure detection IRQ */
- InterruptIn gpio1Int;
+ InterruptIn *gpio1Int;
PinName gpio1Pin;
/* Device data */
MyVL6180Dev_t MyDevice;
--- a/x_nucleo_6180xa1.h Thu Mar 03 10:43:01 2016 +0000
+++ b/x_nucleo_6180xa1.h Fri Mar 11 09:47:43 2016 +0000
@@ -95,6 +95,7 @@
X_NUCLEO_6180XA1(DevI2C *ext_i2c, PinName gpio1_top, PinName gpio1_bottom,
PinName gpio1_left, PinName gpio1_right) : dev_i2c(ext_i2c) {
stmpe1600 = new STMPE1600(*ext_i2c);
+ stmpe1600->writeSYS_CTRL (SOFT_RESET);
Switch = new SWITCH (*stmpe1600, GPIO_11);
display = new Display(*stmpe1600);

X-NUCLEO-6180XA1 Proximity and Ambient Light Sensor