Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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
x_nucleo_6180xa1.cpp@46:116dadbc80f1, 2016-05-19 (annotated)
- Committer:
- mapellil
- Date:
- Thu May 19 14:11:25 2016 +0000
- Revision:
- 46:116dadbc80f1
- Parent:
- 36:f6278b3e7c82
- Child:
- 48:e799ad44dab7
Fixed /Components/Interfaces/GenericSensor.h model and its vl6180xa1 inheritors classes.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| gallonm | 10:4954b09b72d8 | 1 | /** |
| gallonm | 10:4954b09b72d8 | 2 | ****************************************************************************** |
| gallonm | 10:4954b09b72d8 | 3 | * @file x_nucleo_6180xa1.cpp |
| gallonm | 10:4954b09b72d8 | 4 | * @author AST / EST |
| gallonm | 10:4954b09b72d8 | 5 | * @version V0.0.1 |
| gallonm | 10:4954b09b72d8 | 6 | * @date 13-April-2015 |
| gallonm | 10:4954b09b72d8 | 7 | * @brief Implementation file for the X_NUCLEO_VL6180XA1 singleton class |
| gallonm | 10:4954b09b72d8 | 8 | ****************************************************************************** |
| gallonm | 10:4954b09b72d8 | 9 | * @attention |
| gallonm | 10:4954b09b72d8 | 10 | * |
| gallonm | 10:4954b09b72d8 | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
| gallonm | 10:4954b09b72d8 | 12 | * |
| gallonm | 10:4954b09b72d8 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
| gallonm | 10:4954b09b72d8 | 14 | * are permitted provided that the following conditions are met: |
| gallonm | 10:4954b09b72d8 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
| gallonm | 10:4954b09b72d8 | 16 | * this list of conditions and the following disclaimer. |
| gallonm | 10:4954b09b72d8 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| gallonm | 10:4954b09b72d8 | 18 | * this list of conditions and the following disclaimer in the documentation |
| gallonm | 10:4954b09b72d8 | 19 | * and/or other materials provided with the distribution. |
| gallonm | 10:4954b09b72d8 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| gallonm | 10:4954b09b72d8 | 21 | * may be used to endorse or promote products derived from this software |
| gallonm | 10:4954b09b72d8 | 22 | * without specific prior written permission. |
| gallonm | 10:4954b09b72d8 | 23 | * |
| gallonm | 10:4954b09b72d8 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| gallonm | 10:4954b09b72d8 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| gallonm | 10:4954b09b72d8 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| gallonm | 10:4954b09b72d8 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| gallonm | 10:4954b09b72d8 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| gallonm | 10:4954b09b72d8 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| gallonm | 10:4954b09b72d8 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| gallonm | 10:4954b09b72d8 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| gallonm | 10:4954b09b72d8 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| gallonm | 10:4954b09b72d8 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| gallonm | 10:4954b09b72d8 | 34 | * |
| gallonm | 10:4954b09b72d8 | 35 | ****************************************************************************** |
| gallonm | 10:4954b09b72d8 | 36 | */ |
| gallonm | 10:4954b09b72d8 | 37 | |
| gallonm | 10:4954b09b72d8 | 38 | |
| gallonm | 10:4954b09b72d8 | 39 | /* Includes ------------------------------------------------------------------*/ |
| gallonm | 10:4954b09b72d8 | 40 | #include "x_nucleo_6180xa1.h" |
| gallonm | 10:4954b09b72d8 | 41 | |
| gallonm | 10:4954b09b72d8 | 42 | /* Static variables ----------------------------------------------------------*/ |
| gallonm | 10:4954b09b72d8 | 43 | X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::_instance = NULL; |
| gallonm | 10:4954b09b72d8 | 44 | |
| gallonm | 10:4954b09b72d8 | 45 | X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::Instance(DevI2C *ext_i2c) |
| gallonm | 10:4954b09b72d8 | 46 | { |
| gallonm | 16:0d4776564733 | 47 | if(_instance==NULL) |
| gallonm | 16:0d4776564733 | 48 | _instance=new X_NUCLEO_6180XA1(ext_i2c); |
| gallonm | 16:0d4776564733 | 49 | else |
| gallonm | 28:7c9031e96c22 | 50 | VL6180x_ErrLog("Failed to create X_NUCLEO_6180XA1 instance\n\r"); |
| gallonm | 16:0d4776564733 | 51 | return _instance; |
| gallonm | 10:4954b09b72d8 | 52 | } |
| gallonm | 10:4954b09b72d8 | 53 | |
| mapellil | 36:f6278b3e7c82 | 54 | X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::Instance(DevI2C *ext_i2c, |
| mapellil | 36:f6278b3e7c82 | 55 | PinName gpio1_top, PinName gpio1_bottom, |
| mapellil | 36:f6278b3e7c82 | 56 | PinName gpio1_left, PinName gpio1_right) |
| mapellil | 36:f6278b3e7c82 | 57 | { |
| mapellil | 36:f6278b3e7c82 | 58 | if(_instance==NULL) |
| mapellil | 36:f6278b3e7c82 | 59 | //_instance=new X_NUCLEO_6180XA1(ext_i2c); |
| mapellil | 36:f6278b3e7c82 | 60 | _instance=new X_NUCLEO_6180XA1(ext_i2c, gpio1_top, gpio1_bottom, gpio1_left, gpio1_right); |
| mapellil | 36:f6278b3e7c82 | 61 | else |
| mapellil | 36:f6278b3e7c82 | 62 | VL6180x_ErrLog("Failed to create X_NUCLEO_6180XA1 instance\n\r"); |
| mapellil | 36:f6278b3e7c82 | 63 | return _instance; |
| mapellil | 36:f6278b3e7c82 | 64 | } |
| mapellil | 36:f6278b3e7c82 | 65 | |
| gallonm | 10:4954b09b72d8 | 66 | |
| gallonm | 20:dd8390d615bf | 67 | int X_NUCLEO_6180XA1::InitBoard() |
| gallonm | 10:4954b09b72d8 | 68 | { |
| mapellil | 46:116dadbc80f1 | 69 | int status, n_dev=0; uint8_t sensor_address; |
| gallonm | 15:454710d17358 | 70 | |
| gallonm | 16:0d4776564733 | 71 | sensor_top->VL6180x_Off(); |
| gallonm | 16:0d4776564733 | 72 | sensor_bottom->VL6180x_Off(); |
| gallonm | 16:0d4776564733 | 73 | sensor_left->VL6180x_Off(); |
| gallonm | 16:0d4776564733 | 74 | sensor_right->VL6180x_Off(); |
| mapellil | 46:116dadbc80f1 | 75 | sensor_address = NEW_SENSOR_TOP_ADDRESS; |
| mapellil | 46:116dadbc80f1 | 76 | status=sensor_top->Init(&sensor_address); |
| gallonm | 16:0d4776564733 | 77 | if(status) |
| gallonm | 16:0d4776564733 | 78 | { |
| gallonm | 16:0d4776564733 | 79 | delete sensor_top; |
| gallonm | 16:0d4776564733 | 80 | delete gpio0_top; |
| gallonm | 16:0d4776564733 | 81 | sensor_top=NULL; |
| gallonm | 16:0d4776564733 | 82 | gpio0_top=NULL; |
| gallonm | 27:22c6f69967d9 | 83 | printf("Sensor top not present\n\r"); |
| gallonm | 16:0d4776564733 | 84 | } |
| gallonm | 16:0d4776564733 | 85 | else |
| gallonm | 16:0d4776564733 | 86 | { |
| gallonm | 27:22c6f69967d9 | 87 | printf("Sensor top present\n\r"); |
| gallonm | 16:0d4776564733 | 88 | n_dev++; |
| gallonm | 16:0d4776564733 | 89 | } |
| mapellil | 46:116dadbc80f1 | 90 | sensor_address = NEW_SENSOR_BOTTOM_ADDRESS; |
| mapellil | 46:116dadbc80f1 | 91 | status=sensor_bottom->Init(&sensor_address); |
| gallonm | 16:0d4776564733 | 92 | if(status) |
| gallonm | 16:0d4776564733 | 93 | { |
| gallonm | 16:0d4776564733 | 94 | delete sensor_bottom; |
| gallonm | 16:0d4776564733 | 95 | delete gpio0_bottom; |
| gallonm | 16:0d4776564733 | 96 | sensor_bottom=NULL; |
| gallonm | 16:0d4776564733 | 97 | gpio0_bottom=NULL; |
| gallonm | 27:22c6f69967d9 | 98 | printf("Sensor bottom not present\n\r"); |
| gallonm | 16:0d4776564733 | 99 | } |
| gallonm | 16:0d4776564733 | 100 | else |
| gallonm | 16:0d4776564733 | 101 | { |
| gallonm | 27:22c6f69967d9 | 102 | printf("Sensor bottom present\n\r"); |
| gallonm | 16:0d4776564733 | 103 | n_dev++; |
| gallonm | 16:0d4776564733 | 104 | } |
| mapellil | 46:116dadbc80f1 | 105 | sensor_address = NEW_SENSOR_LEFT_ADDRESS; |
| mapellil | 46:116dadbc80f1 | 106 | status=sensor_left->Init(&sensor_address); |
| gallonm | 16:0d4776564733 | 107 | if(status) |
| gallonm | 16:0d4776564733 | 108 | { |
| gallonm | 16:0d4776564733 | 109 | delete sensor_left; |
| gallonm | 16:0d4776564733 | 110 | delete gpio0_left; |
| gallonm | 16:0d4776564733 | 111 | sensor_left=NULL; |
| gallonm | 16:0d4776564733 | 112 | gpio0_left=NULL; |
| gallonm | 27:22c6f69967d9 | 113 | printf("Sensor left not present\n\r"); |
| gallonm | 16:0d4776564733 | 114 | } |
| gallonm | 16:0d4776564733 | 115 | else |
| gallonm | 16:0d4776564733 | 116 | { |
| gallonm | 27:22c6f69967d9 | 117 | printf("Sensor left present\n\r"); |
| gallonm | 16:0d4776564733 | 118 | n_dev++; |
| gallonm | 16:0d4776564733 | 119 | } |
| mapellil | 46:116dadbc80f1 | 120 | sensor_address = NEW_SENSOR_RIGHT_ADDRESS; |
| mapellil | 46:116dadbc80f1 | 121 | status=sensor_right->Init(&sensor_address); |
| gallonm | 16:0d4776564733 | 122 | if(status) |
| gallonm | 16:0d4776564733 | 123 | { |
| gallonm | 16:0d4776564733 | 124 | delete sensor_right; |
| gallonm | 16:0d4776564733 | 125 | delete gpio0_right; |
| gallonm | 16:0d4776564733 | 126 | sensor_right=NULL; |
| gallonm | 20:dd8390d615bf | 127 | gpio0_right=NULL; |
| gallonm | 27:22c6f69967d9 | 128 | printf("Sensor right not present\n\r"); |
| gallonm | 16:0d4776564733 | 129 | } |
| gallonm | 16:0d4776564733 | 130 | else |
| gallonm | 16:0d4776564733 | 131 | { |
| gallonm | 27:22c6f69967d9 | 132 | printf("Sensor right present\n\r"); |
| gallonm | 16:0d4776564733 | 133 | n_dev++; |
| gallonm | 16:0d4776564733 | 134 | } |
| gallonm | 16:0d4776564733 | 135 | if(n_dev==0) |
| gallonm | 16:0d4776564733 | 136 | return 1; |
| gallonm | 16:0d4776564733 | 137 | else |
| gallonm | 16:0d4776564733 | 138 | return 0; |
| gallonm | 10:4954b09b72d8 | 139 | } |
| gallonm | 10:4954b09b72d8 | 140 | |
| gallonm | 10:4954b09b72d8 | 141 |

X-NUCLEO-6180XA1 Proximity and Ambient Light Sensor