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 56:37d1736bd896, committed 2017-03-13
- Comitter:
- davide.aliprandi@st.com
- Date:
- Mon Mar 13 17:57:03 2017 +0100
- Parent:
- 55:a37f407230ca
- Child:
- 57:fa4c622b04a7
- Commit message:
- Aligning to ARM mbed coding style.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Display/Display.h Mon Mar 13 17:57:03 2017 +0100
@@ -0,0 +1,345 @@
+/**
+ ******************************************************************************
+ * @file Display.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Header file for display
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+*/
+
+
+#ifndef __DISPLAY_H
+#define __DISPLAY_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "mbed.h"
+#include "Stmpe1600.h"
+#include "DevI2C.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DP (1<<7)
+#define NOT_7_NO_DP( ... ) (uint8_t) ~( __VA_ARGS__ + DP )
+#define S0 (1<<0)
+#define S1 (1<<1)
+#define S2 (1<<2)
+#define S3 (1<<3)
+#define S4 (1<<4)
+#define S5 (1<<5)
+#define S6 (1<<6)
+
+#ifndef __cpluplus
+/* refer to http://www.twyman.org.uk/Fonts/ */
+static const uint8_t ascii_to_display_lut[256]={
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ [32]= 0,
+ 0,0,0,0,0,0,0,0,
+ 0,
+ [42]= NOT_7_NO_DP(),
+ 0,0,
+ [45]= S6,
+ 0,0,
+ [48]= NOT_7_NO_DP(S6),
+ [49]= S1+S2,
+ [50]= S0+S1+S6+S4+S3,
+ [51]= NOT_7_NO_DP(S4+S5),
+ [52]= S5+S1+S6+S2,
+ [53]= NOT_7_NO_DP(S1+S4),
+ [54]= NOT_7_NO_DP(S1),
+ [55]= S0+S1+S2,
+ [56]= NOT_7_NO_DP(0),
+ [57]= NOT_7_NO_DP(S4),
+ 0,0,0,
+ [61]= S3+S6,
+ 0,
+ [63]= NOT_7_NO_DP(S5+S3+S2),
+ [64]= S0+S3,
+ [65]= NOT_7_NO_DP(S3),
+ [66]= NOT_7_NO_DP(S0+S1), /* as b */
+ [67]= S0+S3+S4+S5, // same as [
+ [68]= S0+S3+S4+S5, // same as [ DUMMY
+ [69]= NOT_7_NO_DP(S1+S2),
+ [70]= S6+S5+S4+S0,
+ [71]= NOT_7_NO_DP(S4), /* same as 9 */
+ [72]= NOT_7_NO_DP(S0+S3),
+ [73]= S1+S2,
+ [74]= S1+S2+S3+S4,
+ [75]= NOT_7_NO_DP(S0+S3), /* same as H */
+ [76]= S3+S4+S5,
+ [77]= S0+S4+S2, /* same as m*/
+ [78]= S2+S4+S6, /* same as n*/
+ [79]= NOT_7_NO_DP(S6),
+ [80]= S0+S1+S2+S5+S6, // sames as 'q'
+ [81]= NOT_7_NO_DP(S3+S2),
+ [82]= S4+S6,
+ [83]= NOT_7_NO_DP(S1+S4), /* sasme as 5 */
+ [84]= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */
+ [85]= NOT_7_NO_DP(S6+S0),
+ [86]= S4+S3+S2, // is u but u use U
+ [87]= S1+S3+S5,
+ [88]= NOT_7_NO_DP(S0+S3), // similar to H
+ [89]= NOT_7_NO_DP(S0+S4),
+ [90]= S0+S1+S6+S4+S3, // same as 2
+ [91]= S0+S3+S4+S5,
+ 0,
+ [93]= S0+S3+S2+S1,
+ [94]= S0, /* use as top bar */
+ [95]= S3,
+ 0,
+ [97]= S2+ S3+ S4+ S6 ,
+ [98]= NOT_7_NO_DP(S0+S1),
+ [99]= S6+S4+S3,
+ [100]= NOT_7_NO_DP(S0+S5),
+ [101]= NOT_7_NO_DP(S2),
+ [102]= S6+S5+S4+S0, /* same as F */
+ [103]= NOT_7_NO_DP(S4), /* same as 9 */
+ [104]= S6+S5+S4+S2,
+ [105]= S4,
+ [106]= S1+S2+S3+S4,
+ [107]= S6+S5+S4+S2, /* a h */
+ [108]= S3+S4,
+ [109]= S0+S4+S2, /* same as */
+ [110]= S2+S4+S6,
+ [111]= S6+S4+S3+S2,
+ [112]= NOT_7_NO_DP(S3+S2), // same as P
+ [113]= S0+S1+S2+S5+S6,
+ [114]= S4+S6,
+ [115]= NOT_7_NO_DP(S1+S4),
+ [116]= NOT_7_NO_DP(S0+S1+S2),
+ [117]= S4+S3+S2+S5+S1, // U
+ [118]= S4+S3+S2, // is u but u use U
+ [119]= S1+S3+S5,
+ [120]= NOT_7_NO_DP(S0+S3), // similar to H
+ [121]= NOT_7_NO_DP(S0+S4),
+ [122]= S0+S1+S6+S4+S3, // same as 2
+ 0,0,0,
+ [126]= S0+S3+S6 /* 3 h bar */
+};
+#else
+/* refer to http://www.twyman.org.uk/Fonts/ */
+static const uint8_t ascii_to_display_lut[256]={
+ [' ']= 0,
+ ['-']= S6,
+ ['_']= S3,
+ ['=']= S3+S6,
+ ['~']= S0+S3+S6, /* 3 h bar */
+ ['^']= S0, /* use as top bar */
+
+ ['?']= NOT_7_NO_DP(S5+S3+S2),
+ ['*']= NOT_7_NO_DP(),
+ ['[']= S0+S3+S4+S5,
+ [']']= S0+S3+S2+S1,
+ ['@']= S0+S3,
+
+ ['0']= NOT_7_NO_DP(S6),
+ ['1']= S1+S2,
+ ['2']= S0+S1+S6+S4+S3,
+ ['3']= NOT_7_NO_DP(S4+S5),
+ ['4']= S5+S1+S6+S2,
+ ['5']= NOT_7_NO_DP(S1+S4),
+ ['6']= NOT_7_NO_DP(S1),
+ ['7']= S0+S1+S2,
+ ['8']= NOT_7_NO_DP(0),
+ ['9']= NOT_7_NO_DP(S4),
+
+ ['a']= S2+ S3+ S4+ S6 ,
+ ['b']= NOT_7_NO_DP(S0+S1),
+ ['c']= S6+S4+S3,
+ ['d']= NOT_7_NO_DP(S0+S5),
+ ['e']= NOT_7_NO_DP(S2),
+ ['f']= S6+S5+S4+S0, /* same as F */
+ ['g']= NOT_7_NO_DP(S4), /* same as 9 */
+ ['h']= S6+S5+S4+S2,
+ ['i']= S4,
+ ['j']= S1+S2+S3+S4,
+ ['k']= S6+S5+S4+S2, /* a h */
+ ['l']= S3+S4,
+ ['m']= S0+S4+S2, /* same as */
+ ['n']= S2+S4+S6,
+ ['o']= S6+S4+S3+S2,
+ ['p']= NOT_7_NO_DP(S3+S2), // same as P
+ ['q']= S0+S1+S2+S5+S6,
+ ['r']= S4+S6,
+ ['s']= NOT_7_NO_DP(S1+S4),
+ ['t']= NOT_7_NO_DP(S0+S1+S2),
+ ['u']= S4+S3+S2+S5+S1, // U
+ ['v']= S4+S3+S2, // is u but u use U
+ ['w']= S1+S3+S5,
+ ['x']= NOT_7_NO_DP(S0+S3), // similar to H
+ ['y']= NOT_7_NO_DP(S0+S4),
+ ['z']= S0+S1+S6+S4+S3, // same as 2
+
+ ['A']= NOT_7_NO_DP(S3),
+ ['B']= NOT_7_NO_DP(S0+S1), /* as b */
+ ['C']= S0+S3+S4+S5, // same as [
+ ['E']= NOT_7_NO_DP(S1+S2),
+ ['F']= S6+S5+S4+S0,
+ ['G']= NOT_7_NO_DP(S4), /* same as 9 */
+ ['H']= NOT_7_NO_DP(S0+S3),
+ ['I']= S1+S2,
+ ['J']= S1+S2+S3+S4,
+ ['K']= NOT_7_NO_DP(S0+S3), /* same as H */
+ ['L']= S3+S4+S5,
+ ['M']= S0+S4+S2, /* same as m*/
+ ['N']= S2+S4+S6, /* same as n*/
+ ['O']= NOT_7_NO_DP(S6),
+ ['P']= S0+S1+S2+S5+S6, // sames as 'q'
+ ['Q']= NOT_7_NO_DP(S3+S2),
+ ['R']= S4+S6,
+ ['S']= NOT_7_NO_DP(S1+S4), /* sasme as 5 */
+ ['T']= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */
+ ['U']= NOT_7_NO_DP(S6+S0),
+ ['V']= S4+S3+S2, // is u but u use U
+ ['W']= S1+S3+S5,
+ ['X']= NOT_7_NO_DP(S0+S3), // similar to H
+ ['Y']= NOT_7_NO_DP(S0+S4),
+ ['Z']= S0+S1+S6+S4+S3 // same as 2
+};
+#endif
+
+#undef S0
+#undef S1
+#undef S2
+#undef S3
+#undef S4
+#undef S5
+#undef S6
+#undef DP
+
+#define DISPLAY_DELAY 1 // in mSec
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing Display
+ */
+
+class Display
+{
+public:
+ /** Constructor
+ * @param[in] &stmpe_1600 device handler to be used for display control
+ */
+ Display(STMPE1600 &stmpe_1600) : stmpe1600(stmpe_1600) {
+ stmpe1600.setGPIOdir (GPIO_7, OUTPUT); // Digit1
+ stmpe1600.setGPIOdir (GPIO_8, OUTPUT); // Digit2
+ stmpe1600.setGPIOdir (GPIO_9, OUTPUT); // Digit3
+ stmpe1600.setGPIOdir (GPIO_10, OUTPUT); // Digit4
+
+ stmpe1600.setGPIOdir (GPIO_0, OUTPUT); // SegmentA
+ stmpe1600.setGPIOdir (GPIO_1, OUTPUT); // SegmentB
+ stmpe1600.setGPIOdir (GPIO_2, OUTPUT); // SegmentC
+ stmpe1600.setGPIOdir (GPIO_3, OUTPUT); // SegmentD
+ stmpe1600.setGPIOdir (GPIO_4, OUTPUT); // SegmentE
+ stmpe1600.setGPIOdir (GPIO_5, OUTPUT); // SegmentF
+ stmpe1600.setGPIOdir (GPIO_6, OUTPUT); // SegmentG
+ }
+
+ /*** Interface Methods ***/
+ /**
+ * @brief Print the string on display
+ * @param[in] String to be printed
+ * @param[in] String lenght [min 1, max 4]
+ * @return void
+ */
+ void display_string (char str[4], char strlen)
+ {
+ int i, dgt;
+ const char *pc;
+ uint8_t data[2];
+ uint16_t *pdata = (uint16_t*)data;
+
+ for (i=0, dgt=4-strlen, pc=str; i<strlen && *pc!=0; i++, pc++, dgt++) {
+ _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*pc], dgt);
+ if ( (pc+1)== '.') {
+ pc++;
+ }
+ wait_ms(DISPLAY_DELAY);
+ stmpe1600.read_16_bit_reg(GPSR_0_7, pdata);
+ *pdata = *pdata | (uint16_t)0x0780; // all digits off
+ stmpe1600.write_16_bit_reg(GPSR_0_7, pdata);
+ }
+ }
+
+ /**
+ * @brief Print the digit on display
+ * @param[in] Digit value to be printed
+ * @param[in] Digit to be used [min 0, max 3]
+ * @return void
+ */
+ void DisplayDigit (char *val, char dgt)
+ {
+ uint8_t data[2];
+ uint16_t *pdata = (uint16_t*)data;
+
+ stmpe1600.read_16_bit_reg(GPSR_0_7, pdata);
+ *pdata = *pdata | (uint16_t)0x0780; // all digits off
+ stmpe1600.write_16_bit_reg(GPSR_0_7, pdata);
+ _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*val], dgt);
+ }
+
+private:
+ void _V2_Set7Segment( int Leds, int digit )
+ {
+ //Digits_off();
+ uint16_t dgt;
+ dgt = 1<<digit;
+ dgt = ((uint16_t)dgt)<<7;
+ dgt = ~dgt;
+ uint8_t data[2];
+ uint16_t *pdata = (uint16_t*)data;
+
+
+ /* set the exppinname state to lvl */
+ stmpe1600.read_16_bit_reg(GPSR_0_7, pdata);
+ *pdata = *pdata | (uint16_t)0x007F; // 7 segments off
+ stmpe1600.write_16_bit_reg(GPSR_0_7, pdata);
+
+ int mask=1;
+ for (int i=0; i<7; i++) {
+ if (Leds & mask) *pdata = *pdata & ~(uint16_t)mask;
+ mask = mask<<1;
+ }
+ *pdata = *pdata & dgt;
+ stmpe1600.write_16_bit_reg(GPSR_0_7, pdata);
+ }
+ STMPE1600 &stmpe1600;
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif // __DISPLAY_H
--- a/Components/Display/Display_class.h Fri Mar 03 15:06:18 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,346 +0,0 @@
-/**
- ******************************************************************************
- * @file Display.h
- * @author AST / EST
- * @version V0.0.1
- * @date 14-April-2015
- * @brief Header file for display
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
-*/
-
-#ifndef __DISPLAY_H
-#define __DISPLAY_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-#include "stmpe1600_class.h"
-#include "DevI2C.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DP (1<<7)
-#define NOT_7_NO_DP( ... ) (uint8_t) ~( __VA_ARGS__ + DP )
-#define S0 (1<<0)
-#define S1 (1<<1)
-#define S2 (1<<2)
-#define S3 (1<<3)
-#define S4 (1<<4)
-#define S5 (1<<5)
-#define S6 (1<<6)
-
-#ifndef __cpluplus
-/* refer to http://www.twyman.org.uk/Fonts/ */
-static const uint8_t ascii_to_display_lut[256]={
- 0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,
- [32]= 0,
- 0,0,0,0,0,0,0,0,
- 0,
- [42]= NOT_7_NO_DP(),
- 0,0,
- [45]= S6,
- 0,0,
- [48]= NOT_7_NO_DP(S6),
- [49]= S1+S2,
- [50]= S0+S1+S6+S4+S3,
- [51]= NOT_7_NO_DP(S4+S5),
- [52]= S5+S1+S6+S2,
- [53]= NOT_7_NO_DP(S1+S4),
- [54]= NOT_7_NO_DP(S1),
- [55]= S0+S1+S2,
- [56]= NOT_7_NO_DP(0),
- [57]= NOT_7_NO_DP(S4),
- 0,0,0,
- [61]= S3+S6,
- 0,
- [63]= NOT_7_NO_DP(S5+S3+S2),
- [64]= S0+S3,
- [65]= NOT_7_NO_DP(S3),
- [66]= NOT_7_NO_DP(S0+S1), /* as b */
- [67]= S0+S3+S4+S5, // same as [
- [68]= S0+S3+S4+S5, // same as [ DUMMY
- [69]= NOT_7_NO_DP(S1+S2),
- [70]= S6+S5+S4+S0,
- [71]= NOT_7_NO_DP(S4), /* same as 9 */
- [72]= NOT_7_NO_DP(S0+S3),
- [73]= S1+S2,
- [74]= S1+S2+S3+S4,
- [75]= NOT_7_NO_DP(S0+S3), /* same as H */
- [76]= S3+S4+S5,
- [77]= S0+S4+S2, /* same as m*/
- [78]= S2+S4+S6, /* same as n*/
- [79]= NOT_7_NO_DP(S6),
- [80]= S0+S1+S2+S5+S6, // sames as 'q'
- [81]= NOT_7_NO_DP(S3+S2),
- [82]= S4+S6,
- [83]= NOT_7_NO_DP(S1+S4), /* sasme as 5 */
- [84]= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */
- [85]= NOT_7_NO_DP(S6+S0),
- [86]= S4+S3+S2, // is u but u use U
- [87]= S1+S3+S5,
- [88]= NOT_7_NO_DP(S0+S3), // similar to H
- [89]= NOT_7_NO_DP(S0+S4),
- [90]= S0+S1+S6+S4+S3, // same as 2
- [91]= S0+S3+S4+S5,
- 0,
- [93]= S0+S3+S2+S1,
- [94]= S0, /* use as top bar */
- [95]= S3,
- 0,
- [97]= S2+ S3+ S4+ S6 ,
- [98]= NOT_7_NO_DP(S0+S1),
- [99]= S6+S4+S3,
- [100]= NOT_7_NO_DP(S0+S5),
- [101]= NOT_7_NO_DP(S2),
- [102]= S6+S5+S4+S0, /* same as F */
- [103]= NOT_7_NO_DP(S4), /* same as 9 */
- [104]= S6+S5+S4+S2,
- [105]= S4,
- [106]= S1+S2+S3+S4,
- [107]= S6+S5+S4+S2, /* a h */
- [108]= S3+S4,
- [109]= S0+S4+S2, /* same as */
- [110]= S2+S4+S6,
- [111]= S6+S4+S3+S2,
- [112]= NOT_7_NO_DP(S3+S2), // same as P
- [113]= S0+S1+S2+S5+S6,
- [114]= S4+S6,
- [115]= NOT_7_NO_DP(S1+S4),
- [116]= NOT_7_NO_DP(S0+S1+S2),
- [117]= S4+S3+S2+S5+S1, // U
- [118]= S4+S3+S2, // is u but u use U
- [119]= S1+S3+S5,
- [120]= NOT_7_NO_DP(S0+S3), // similar to H
- [121]= NOT_7_NO_DP(S0+S4),
- [122]= S0+S1+S6+S4+S3, // same as 2
- 0,0,0,
- [126]= S0+S3+S6 /* 3 h bar */
-};
-#else
-/* refer to http://www.twyman.org.uk/Fonts/ */
-static const uint8_t ascii_to_display_lut[256]={
- [' ']= 0,
- ['-']= S6,
- ['_']= S3,
- ['=']= S3+S6,
- ['~']= S0+S3+S6, /* 3 h bar */
- ['^']= S0, /* use as top bar */
-
- ['?']= NOT_7_NO_DP(S5+S3+S2),
- ['*']= NOT_7_NO_DP(),
- ['[']= S0+S3+S4+S5,
- [']']= S0+S3+S2+S1,
- ['@']= S0+S3,
-
- ['0']= NOT_7_NO_DP(S6),
- ['1']= S1+S2,
- ['2']= S0+S1+S6+S4+S3,
- ['3']= NOT_7_NO_DP(S4+S5),
- ['4']= S5+S1+S6+S2,
- ['5']= NOT_7_NO_DP(S1+S4),
- ['6']= NOT_7_NO_DP(S1),
- ['7']= S0+S1+S2,
- ['8']= NOT_7_NO_DP(0),
- ['9']= NOT_7_NO_DP(S4),
-
- ['a']= S2+ S3+ S4+ S6 ,
- ['b']= NOT_7_NO_DP(S0+S1),
- ['c']= S6+S4+S3,
- ['d']= NOT_7_NO_DP(S0+S5),
- ['e']= NOT_7_NO_DP(S2),
- ['f']= S6+S5+S4+S0, /* same as F */
- ['g']= NOT_7_NO_DP(S4), /* same as 9 */
- ['h']= S6+S5+S4+S2,
- ['i']= S4,
- ['j']= S1+S2+S3+S4,
- ['k']= S6+S5+S4+S2, /* a h */
- ['l']= S3+S4,
- ['m']= S0+S4+S2, /* same as */
- ['n']= S2+S4+S6,
- ['o']= S6+S4+S3+S2,
- ['p']= NOT_7_NO_DP(S3+S2), // same as P
- ['q']= S0+S1+S2+S5+S6,
- ['r']= S4+S6,
- ['s']= NOT_7_NO_DP(S1+S4),
- ['t']= NOT_7_NO_DP(S0+S1+S2),
- ['u']= S4+S3+S2+S5+S1, // U
- ['v']= S4+S3+S2, // is u but u use U
- ['w']= S1+S3+S5,
- ['x']= NOT_7_NO_DP(S0+S3), // similar to H
- ['y']= NOT_7_NO_DP(S0+S4),
- ['z']= S0+S1+S6+S4+S3, // same as 2
-
- ['A']= NOT_7_NO_DP(S3),
- ['B']= NOT_7_NO_DP(S0+S1), /* as b */
- ['C']= S0+S3+S4+S5, // same as [
- ['E']= NOT_7_NO_DP(S1+S2),
- ['F']= S6+S5+S4+S0,
- ['G']= NOT_7_NO_DP(S4), /* same as 9 */
- ['H']= NOT_7_NO_DP(S0+S3),
- ['I']= S1+S2,
- ['J']= S1+S2+S3+S4,
- ['K']= NOT_7_NO_DP(S0+S3), /* same as H */
- ['L']= S3+S4+S5,
- ['M']= S0+S4+S2, /* same as m*/
- ['N']= S2+S4+S6, /* same as n*/
- ['O']= NOT_7_NO_DP(S6),
- ['P']= S0+S1+S2+S5+S6, // sames as 'q'
- ['Q']= NOT_7_NO_DP(S3+S2),
- ['R']= S4+S6,
- ['S']= NOT_7_NO_DP(S1+S4), /* sasme as 5 */
- ['T']= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */
- ['U']= NOT_7_NO_DP(S6+S0),
- ['V']= S4+S3+S2, // is u but u use U
- ['W']= S1+S3+S5,
- ['X']= NOT_7_NO_DP(S0+S3), // similar to H
- ['Y']= NOT_7_NO_DP(S0+S4),
- ['Z']= S0+S1+S6+S4+S3 // same as 2
-};
-#endif
-
-#undef S0
-#undef S1
-#undef S2
-#undef S3
-#undef S4
-#undef S5
-#undef S6
-#undef DP
-
-#define DISPLAY_DELAY 1 // in mSec
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing Display
- */
-
-class Display
-{
- public:
- /** Constructor
- * @param[in] &stmpe_1600 device handler to be used for display control
- */
- Display(STMPE1600 &stmpe_1600) : stmpe1600(stmpe_1600) {
- stmpe1600.setGPIOdir (GPIO_7, OUTPUT); // Digit1
- stmpe1600.setGPIOdir (GPIO_8, OUTPUT); // Digit2
- stmpe1600.setGPIOdir (GPIO_9, OUTPUT); // Digit3
- stmpe1600.setGPIOdir (GPIO_10, OUTPUT); // Digit4
-
- stmpe1600.setGPIOdir (GPIO_0, OUTPUT); // SegmentA
- stmpe1600.setGPIOdir (GPIO_1, OUTPUT); // SegmentB
- stmpe1600.setGPIOdir (GPIO_2, OUTPUT); // SegmentC
- stmpe1600.setGPIOdir (GPIO_3, OUTPUT); // SegmentD
- stmpe1600.setGPIOdir (GPIO_4, OUTPUT); // SegmentE
- stmpe1600.setGPIOdir (GPIO_5, OUTPUT); // SegmentF
- stmpe1600.setGPIOdir (GPIO_6, OUTPUT); // SegmentG
- }
-
- /*** Interface Methods ***/
- /**
- * @brief Print the string on display
- * @param[in] String to be printed
- * @param[in] String lenght [min 1, max 4]
- * @return void
- */
- void DisplayString (char str[4], char strlen)
- {
- int i, dgt;
- const char *pc;
- uint8_t data[2];
- uint16_t *pdata = (uint16_t*)data;
-
- for(i=0, dgt=4-strlen, pc=str; i<strlen && *pc!=0; i++, pc++, dgt++)
- {
- _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*pc], dgt);
- if( *(pc+1)== '.')
- {
- pc++;
- }
- wait_ms(DISPLAY_DELAY);
- stmpe1600.read16bitReg(GPSR_0_7, pdata);
- *pdata = *pdata | (uint16_t)0x0780; // all digits off
- stmpe1600.write16bitReg(GPSR_0_7, pdata);
- }
-
- }
-
- /**
- * @brief Print the digit on display
- * @param[in] Digit value to be printed
- * @param[in] Digit to be used [min 0, max 3]
- * @return void
- */
- void DisplayDigit (char *val, char dgt)
- {
- uint8_t data[2];
- uint16_t *pdata = (uint16_t*)data;
-
- stmpe1600.read16bitReg(GPSR_0_7, pdata);
- *pdata = *pdata | (uint16_t)0x0780; // all digits off
- stmpe1600.write16bitReg(GPSR_0_7, pdata);
- _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*val], dgt);
- }
-
-private:
- void _V2_Set7Segment( int Leds, int digit )
- {
- //Digits_off();
- uint16_t dgt;
- dgt = 1<<digit;
- dgt = ((uint16_t)dgt)<<7;
- dgt = ~dgt;
- uint8_t data[2];
- uint16_t *pdata = (uint16_t*)data;
-
-
- /* set the exppinname state to lvl */
- stmpe1600.read16bitReg(GPSR_0_7, pdata);
- *pdata = *pdata | (uint16_t)0x007F; // 7 segments off
- stmpe1600.write16bitReg(GPSR_0_7, pdata);
-
- int mask=1;
- for (int i=0; i<7; i++)
- {
- if (Leds & mask) *pdata = *pdata & ~(uint16_t)mask;
- mask = mask<<1;
- }
- *pdata = *pdata & dgt;
- stmpe1600.write16bitReg(GPSR_0_7, pdata);
- }
- STMPE1600 &stmpe1600;
-};
-
-#ifdef __cplusplus
-}
-#endif
-#endif // __DISPLAY_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/STMPE1600/Stmpe1600.h Mon Mar 13 17:57:03 2017 +0100
@@ -0,0 +1,326 @@
+/**
+ ******************************************************************************
+ * @file Stmpe1600.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Header file for component stmpe1600
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+*/
+#ifndef __Stmpe1600_CLASS
+#define __Stmpe1600_CLASS
+/* Includes ------------------------------------------------------------------*/
+#include "DevI2C.h"
+
+#define STMPE1600_DEF_DEVICE_ADDRESS (uint8_t)0x42*2
+#define STMPE1600_DEF_DIGIOUT_LVL 1
+
+/** Stmpe1600 registr map **/
+#define ChipID_0_7 (uint8_t)0x00
+#define ChipID_8_15 (uint8_t)0x01
+#define VersionId (uint8_t)0x02
+#define SYS_CTRL (uint8_t)0x03
+#define IEGPIOR_0_7 (uint8_t)0x08
+#define IEGPIOR_8_15 (uint8_t)0x09
+#define ISGPIOR_0_7 (uint8_t)0x0A
+#define ISGPIOR_8_15 (uint8_t)0x0B
+#define GPMR_0_7 (uint8_t)0x10
+#define GPMR_8_15 (uint8_t)0x11
+#define GPSR_0_7 (uint8_t)0x12
+#define GPSR_8_15 (uint8_t)0x13
+#define GPDR_0_7 (uint8_t)0x14
+#define GPDR_8_15 (uint8_t)0x15
+#define GPIR_0_7 (uint8_t)0x16
+#define GPIR_8_15 (uint8_t)0x17
+
+#define SOFT_RESET (uint8_t)0x80
+
+typedef enum {
+ // GPIO Expander pin names
+ GPIO_0=0,
+ GPIO_1,
+ GPIO_2,
+ GPIO_3,
+ GPIO_4,
+ GPIO_5,
+ GPIO_6,
+ GPIO_7,
+ GPIO_8,
+ GPIO_9,
+ GPIO_10,
+ GPIO_11,
+ GPIO_12,
+ GPIO_13,
+ GPIO_14,
+ GPIO_15,
+ NOT_CON
+} exp_gpio_pin_name;
+
+typedef enum {
+ INPUT = 0,
+ OUTPUT,
+ NOT_CONNECTED
+} exp_gpio_pin_direction;
+
+
+/* Classes -------------------------------------------------------------------*/
+
+/**
+ * Class representing a single stmpe1600 GPIO expander output pin
+ */
+class Stmpe1600DigiOut {
+public:
+ /** Constructor
+ * @param[in] &i2c device I2C to be used for communication
+ * @param[in] outpinname the desired out pin name to be created
+ * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
+ * @param[in] lvl the default ot pin level
+ */
+ Stmpe1600DigiOut (DevI2C &i2c, ExpGpioPinName outpinname, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS, bool lvl=STMPE1600_DEF_DIGIOUT_LVL):
+ _dev_i2c(i2c),
+ _expdevaddr(DevAddr),
+ _exppinname(outpinname)
+ {
+ uint8_t data[2];
+ if (_exppinname == NOT_CON) {
+ return;
+ }
+ /* set the _exppinname as output */
+ _dev_i2c.i2c_read(data, _expdevaddr, GPDR_0_7, 1);
+ _dev_i2c.i2c_read(&data[1], _expdevaddr, GPDR_8_15, 1);
+ *(uint16_t*)data = *(uint16_t*)data | (1<<(uint16_t)_exppinname); // set gpio as out
+ _dev_i2c.i2c_write(data, _expdevaddr, GPDR_0_7, 1);
+ _dev_i2c.i2c_write(&data[1], _expdevaddr, GPDR_8_15, 1);
+ write (lvl);
+ }
+
+ /**
+ * @brief Write on the out pin
+ * @param[in] lvl level to write
+ * @return 0 on Success
+ */
+ void write (int lvl)
+ {
+ uint8_t data[2];
+ if (_exppinname == NOT_CON) return;
+ /* set the _exppinname state to lvl */
+ _dev_i2c.i2c_read(data, _expdevaddr, GPSR_0_7, 2);
+ *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(~(1<<(uint16_t)_exppinname)); // set pin mask
+ if (lvl) *(uint16_t*)data = *(uint16_t*)data | (uint16_t)(1<<(uint16_t)_exppinname);
+ _dev_i2c.i2c_write(data, _expdevaddr, GPSR_0_7, 2);
+ }
+
+ /**
+ * @brief Overload assignement operator
+ */
+ Stmpe1600DigiOut& operator=(int lvl)
+ {
+ write (lvl);
+ return *this;
+ }
+
+private:
+ DevI2C &_dev_i2c;
+ uint8_t _expdevaddr;
+ ExpGpioPinName _exppinname;
+};
+
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a single stmpe1600 GPIO expander input pin
+ */
+class Stmpe1600DigiIn
+{
+public:
+ /** Constructor
+ * @param[in] &i2c device I2C to be used for communication
+ * @param[in] inpinname the desired input pin name to be created
+ * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
+ */
+ Stmpe1600DigiIn (DevI2C &i2c, ExpGpioPinName inpinname, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS): _dev_i2c(i2c), _expdevaddr(DevAddr), _exppinname(inpinname)
+ {
+ uint8_t data[2];
+ if (_exppinname == NOT_CON) return;
+ /* set the _exppinname as input pin direction */
+ _dev_i2c.i2c_read(data, _expdevaddr, GPDR_0_7, 2);
+ *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(~(1<<(uint16_t) _exppinname)); // set gpio as in
+ _dev_i2c.i2c_write(data, _expdevaddr, GPDR_0_7, 2);
+ }
+
+ /**
+ * @brief Read the input pin
+ * @return The pin logical state 0 or 1
+ */
+ bool read () {
+ uint8_t data[2];
+ if (_exppinname == NOT_CON) {
+ return 0;
+ }
+
+ /* read the _exppinname */
+ _dev_i2c.i2c_read(data, _expdevaddr, GPMR_0_7, 2);
+ *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(1<<(uint16_t)_exppinname); // mask the in gpio
+
+ if (data[0] || data[1]) {
+ return 1;
+ }
+ return 0;
+ }
+
+ operator int() {
+ return read();
+ }
+
+private:
+ DevI2C &_dev_i2c;
+ uint8_t _expdevaddr;
+ ExpGpioPinName _exppinname;
+};
+
+
+/* Classes -------------------------------------------------------------------*/
+
+/**
+ * Class representing a whole stmpe1600 component (16 gpio)
+ */
+class Stmpe1600 {
+public:
+ /** Constructor
+ * @param[in] &i2c device I2C to be used for communication
+ * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
+ */
+ Stmpe1600 (DevI2C &i2c, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS ) : _dev_i2c(i2c)
+ {
+ _dev_i2c = i2c;
+ _expdevaddr = DevAddr;
+ write_sys_ctrl (SOFT_RESET);
+
+ _gpdro_15 = (uint16_t)0; // gpio dir all IN
+ _write_16_bit_reg (GPDR_0_7, &_gpdro_15);
+ _gpsro_15 = (uint16_t)0x0ffff; // gpio status all 1
+ _write_16_bit_reg (GPSR_0_7, &_gpsro_15);
+ }
+
+ /**
+ * @brief Write the SYS_CTRL register
+ * @param[in] Data to be written (bit fields)
+ */
+ void write_sys_ctrl (uint8_t data) // data = SOFT_RESET reset the device
+ {
+ _dev_i2c.i2c_write((uint8_t*)SYS_CTRL, _expdevaddr, data, 1);
+ }
+
+ /**
+ * @brief Set the out pin
+ * @param[in] The pin name
+ * @return 0 on Success
+ */
+ bool set_gpio (ExpGpioPinName pin_name)
+ {
+ if (pin_name == NOT_CON) return true;
+ _gpsro_15 = _gpsro_15 | ((uint16_t)0x0001<<pin_name);
+ _write_16_bit_reg (GPSR_0_7 , &_gpsro_15);
+ return false;
+ }
+
+ /**
+ * @brief Clear the out pin
+ * @param[in] The pin name
+ * @return 0 on Success
+ */
+ bool clr_gpio (ExpGpioPinName pin_name)
+ {
+ if (pin_name == NOT_CON) return true;
+ _gpsro_15 = _gpsro_15 & (~((uint16_t)0x0001<<pin_name));
+ (GPSR_0_7 , &_gpsro_15);
+ return false;
+ }
+
+ /**
+ * @brief Read the input pin
+ * @param[in] The pin name
+ * @return The logical pin level
+ */
+ bool rd_gpio (ExpGpioPinName pin_name)
+ {
+ uint16_t gpmr0_15;
+ if (pin_name == NOT_CON) return true;
+ _read_16_bit_reg (GPMR_0_7, &gpmr0_15);
+ gpmr0_15 = gpmr0_15 & ((uint16_t)0x0001<<pin_name);
+ if (gpmr0_15) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @brief Set the pin direction
+ * @param[in] The pin name
+ * @param[in] The pin direction
+ * @return 0 on success
+ */
+ bool _set_gpio_dir (ExpGpioPinName pin_name, exp_gpio_pin_direction pin_dir)
+ {
+ if (pin_name == NOT_CON || pin_dir == NOT_CONNECTED) {
+ return true;
+ }
+ _gpdro_15 = _gpdro_15 & (~((uint16_t)0x0001<<pin_name)); // clear the Pin
+ _gpdro_15 = _gpdro_15 | ((uint16_t)pin_dir<<pin_name);
+ _write_16_bit_reg (GPDR_0_7 , &_gpdro_15);
+ return false;
+ }
+
+ /**
+ * @brief Read a 16 bits register
+ * @param[in] The register address
+ * @param[in] The pointer to the read data
+ */
+ void _read_16_bit_reg (uint8_t reg_16_addr, uint16_t *reg_16_data)
+ {
+ _dev_i2c.i2c_read((uint8_t*)reg_16_data, _expdevaddr, reg_16_addr, 2);
+ }
+
+ /**
+ * @brief Write a 16 bits register
+ * @param[in] The register address
+ * @param[in] The pointer to the data to be written
+ */
+ void _write_16_bit_reg (uint8_t reg_16_addr, uint16_t *reg_16_data)
+ {
+ _dev_i2c.i2c_write((uint8_t*)reg_16_data, _expdevaddr, reg_16_addr, 2);
+ }
+
+private:
+ DevI2C &_dev_i2c;
+ uint16_t _gpdro_15; // local copy of bit direction reg
+ uint16_t _gpsro_15; // local copy of bit status reg
+ uint8_t _expdevaddr; // expander device i2c addr
+};
+
+#endif // __Stmpe1600_CLASS
--- a/Components/STMPE1600/stmpe1600_class.h Fri Mar 03 15:06:18 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,309 +0,0 @@
-/**
- ******************************************************************************
- * @file stmpe1600_class.h
- * @author AST / EST
- * @version V0.0.1
- * @date 14-April-2015
- * @brief Header file for component stmpe1600
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
-*/
-#ifndef __STMPE1600_CLASS
-#define __STMPE1600_CLASS
-/* Includes ------------------------------------------------------------------*/
-#include "DevI2C.h"
-
-#define STMPE1600_DEF_DEVICE_ADDRESS (uint8_t)0x42*2
-#define STMPE1600_DEF_DIGIOUT_LVL 1
-
-/** STMPE1600 registr map **/
-#define ChipID_0_7 (uint8_t)0x00
-#define ChipID_8_15 (uint8_t)0x01
-#define VersionId (uint8_t)0x02
-#define SYS_CTRL (uint8_t)0x03
-#define IEGPIOR_0_7 (uint8_t)0x08
-#define IEGPIOR_8_15 (uint8_t)0x09
-#define ISGPIOR_0_7 (uint8_t)0x0A
-#define ISGPIOR_8_15 (uint8_t)0x0B
-#define GPMR_0_7 (uint8_t)0x10
-#define GPMR_8_15 (uint8_t)0x11
-#define GPSR_0_7 (uint8_t)0x12
-#define GPSR_8_15 (uint8_t)0x13
-#define GPDR_0_7 (uint8_t)0x14
-#define GPDR_8_15 (uint8_t)0x15
-#define GPIR_0_7 (uint8_t)0x16
-#define GPIR_8_15 (uint8_t)0x17
-
-#define SOFT_RESET (uint8_t)0x80
-
- typedef enum {
- // GPIO Expander pin names
- GPIO_0=0,
- GPIO_1,
- GPIO_2,
- GPIO_3,
- GPIO_4,
- GPIO_5,
- GPIO_6,
- GPIO_7,
- GPIO_8,
- GPIO_9,
- GPIO_10,
- GPIO_11,
- GPIO_12,
- GPIO_13,
- GPIO_14,
- GPIO_15,
- NOT_CON
-} ExpGpioPinName;
-
-typedef enum {
- INPUT = 0,
- OUTPUT,
- NOT_CONNECTED
-}ExpGpioPinDirection;
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing a single stmpe1600 GPIO expander output pin
- */
-class STMPE1600DigiOut {
-
- public:
- /** Constructor
- * @param[in] &i2c device I2C to be used for communication
- * @param[in] outpinname the desired out pin name to be created
- * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
- * @param[in] lvl the default ot pin level
- */
- STMPE1600DigiOut (DevI2C &i2c, ExpGpioPinName outpinname, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS, bool lvl=STMPE1600_DEF_DIGIOUT_LVL): dev_i2c(i2c), expdevaddr(DevAddr), exppinname(outpinname)
- {
- uint8_t data[2];
- if (exppinname == NOT_CON) return;
- /* set the exppinname as output */
- dev_i2c.i2c_read(data, expdevaddr, GPDR_0_7, 1);
- dev_i2c.i2c_read(&data[1], expdevaddr, GPDR_8_15, 1);
- *(uint16_t*)data = *(uint16_t*)data | (1<<(uint16_t)exppinname); // set gpio as out
- dev_i2c.i2c_write(data, expdevaddr, GPDR_0_7, 1);
- dev_i2c.i2c_write(&data[1], expdevaddr, GPDR_8_15, 1);
- write(lvl);
- }
-
- /**
- * @brief Write on the out pin
- * @param[in] lvl level to write
- * @return 0 on Success
- */
- void write (int lvl)
- {
- uint8_t data[2];
- if (exppinname == NOT_CON) return;
- /* set the exppinname state to lvl */
- dev_i2c.i2c_read(data, expdevaddr, GPSR_0_7, 2);
- *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(~(1<<(uint16_t)exppinname)); // set pin mask
- if (lvl) *(uint16_t*)data = *(uint16_t*)data | (uint16_t)(1<<(uint16_t)exppinname);
- dev_i2c.i2c_write(data, expdevaddr, GPSR_0_7, 2);
- }
-
- /**
- * @brief Overload assignement operator
- */
- STMPE1600DigiOut& operator=(int lvl)
- {
- write (lvl);
- return *this;
- }
-
- private:
- DevI2C &dev_i2c;
- uint8_t expdevaddr;
- ExpGpioPinName exppinname;
-};
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing a single stmpe1600 GPIO expander input pin
- */
-class STMPE1600DigiIn
-{
- public:
- /** Constructor
- * @param[in] &i2c device I2C to be used for communication
- * @param[in] inpinname the desired input pin name to be created
- * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
- */
- STMPE1600DigiIn (DevI2C &i2c, ExpGpioPinName inpinname, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS): dev_i2c(i2c), expdevaddr(DevAddr), exppinname(inpinname)
- {
- uint8_t data[2];
- if (exppinname == NOT_CON) return;
- /* set the exppinname as input pin direction */
- dev_i2c.i2c_read(data, expdevaddr, GPDR_0_7, 2);
- *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(~(1<<(uint16_t)exppinname)); // set gpio as in
- dev_i2c.i2c_write(data, expdevaddr, GPDR_0_7, 2);
- }
-
- /**
- * @brief Read the input pin
- * @return The pin logical state 0 or 1
- */
- bool read ()
- {
- uint8_t data[2];
- if (exppinname == NOT_CON) return 0;
- /* read the exppinname */
- dev_i2c.i2c_read(data, expdevaddr, GPMR_0_7, 2);
- *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(1<<(uint16_t)exppinname); // mask the in gpio
- if (data[0] || data[1]) return 1;
- return 0;
- }
-
- operator int()
- {
- return read();
- }
-
- private:
- DevI2C &dev_i2c;
- uint8_t expdevaddr;
- ExpGpioPinName exppinname;
-};
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing a whole stmpe1600 component (16 gpio)
- */
-class STMPE1600 {
-
- public:
- /** Constructor
- * @param[in] &i2c device I2C to be used for communication
- * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
- */
- STMPE1600 (DevI2C &i2c, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS ) : dev_i2c(i2c)
- {
- dev_i2c = i2c;
- expdevaddr = DevAddr;
- writeSYS_CTRL (SOFT_RESET);
-
- GPDR0_15 = (uint16_t)0; // gpio dir all IN
- write16bitReg (GPDR_0_7, &GPDR0_15);
- GPSR0_15 = (uint16_t)0x0ffff; // gpio status all 1
- write16bitReg (GPSR_0_7, &GPSR0_15);
- }
-
- /**
- * @brief Write the SYS_CTRL register
- * @param[in] Data to be written (bit fields)
- */
- void writeSYS_CTRL (uint8_t data) // data = SOFT_RESET reset the device
- {
- dev_i2c.i2c_write((uint8_t*)SYS_CTRL, expdevaddr, data, 1);
- }
-
- /**
- * @brief Set the out pin
- * @param[in] The pin name
- * @return 0 on Success
- */
- bool setGPIO (ExpGpioPinName PinName)
- {
- if (PinName == NOT_CON) return true;
- GPSR0_15 = GPSR0_15 | ((uint16_t)0x0001<<PinName);
- write16bitReg (GPSR_0_7 , &GPSR0_15);
- return false;
- }
-
- /**
- * @brief Clear the out pin
- * @param[in] The pin name
- * @return 0 on Success
- */
- bool clrGPIO (ExpGpioPinName PinName)
- {
- if (PinName == NOT_CON) return true;
- GPSR0_15 = GPSR0_15 & (~((uint16_t)0x0001<<PinName));
- write16bitReg (GPSR_0_7 , &GPSR0_15);
- return false;
- }
-
- /**
- * @brief Read the input pin
- * @param[in] The pin name
- * @return The logical pin level
- */
- bool rdGPIO (ExpGpioPinName PinName)
- {
- uint16_t gpmr0_15;
- if (PinName == NOT_CON) return true;
- read16bitReg (GPMR_0_7, &gpmr0_15);
- gpmr0_15 = gpmr0_15 & ((uint16_t)0x0001<<PinName);
- if (gpmr0_15) return true;
- return false;
- }
-
- /**
- * @brief Set the pin direction
- * @param[in] The pin name
- * @param[in] The pin direction
- * @return 0 on success
- */
- bool setGPIOdir (ExpGpioPinName PinName, ExpGpioPinDirection PinDir)
- {
- if (PinName == NOT_CON || PinDir == NOT_CONNECTED) return true;
- GPDR0_15 = GPDR0_15 & (~((uint16_t)0x0001<<PinName)); // clear the Pin
- GPDR0_15 = GPDR0_15 | ((uint16_t)PinDir<<PinName);
- write16bitReg (GPDR_0_7 , &GPDR0_15);
- return false;
- }
-
- /**
- * @brief Read a 16 bits register
- * @param[in] The register address
- * @param[in] The pointer to the read data
- */
- void read16bitReg (uint8_t Reg16Addr, uint16_t *Reg16Data)
- {
- dev_i2c.i2c_read((uint8_t*)Reg16Data, expdevaddr, Reg16Addr, 2);
- }
-
- /**
- * @brief Write a 16 bits register
- * @param[in] The register address
- * @param[in] The pointer to the data to be written
- */
- void write16bitReg (uint8_t Reg16Addr, uint16_t *Reg16Data)
- {
- dev_i2c.i2c_write((uint8_t*)Reg16Data, expdevaddr, Reg16Addr, 2);
- }
-
- private:
- DevI2C &dev_i2c;
- uint16_t GPDR0_15; // local copy of bit direction reg
- uint16_t GPSR0_15; // local copy of bit status reg
- uint8_t expdevaddr; // expander device i2c addr
-};
-
-#endif // __STMPE1600_CLASS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Switch/Switch.h Mon Mar 13 17:57:03 2017 +0100
@@ -0,0 +1,87 @@
+/**
+ ******************************************************************************
+ * @file Switch.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 14-April-2015
+ * @brief Header file for red switch
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+*/
+
+
+#ifndef __SWITCH_H
+#define __SWITCH_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "mbed.h"
+#include "Stmpe1600.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ RANGE = 0,
+ ALS
+} SwitchState;
+
+
+/* Classes -------------------------------------------------------------------*/
+
+/**
+ * Class representing Red Switch
+ */
+
+class Switch
+{
+public:
+ Switch(STMPE1600 &stmpe_1600, ExpGpioPinName Pin_Name=GPIO_11) : stmpe1600(stmpe_1600), PinName(Pin_Name) {
+ stmpe1600.set_gpio_dir(PinName, INPUT);
+ }
+
+ bool rd_switch () {
+ return stmpe1600.rd_gpio(PinName);
+ }
+
+ operator int() {
+ return rd_switch();
+ }
+
+ private:
+ STMPE1600 &stmpe1600;
+ ExpGpioPinName PinName;
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif // __SWITCH_H
--- a/Components/Switch/Switch_class.h Fri Mar 03 15:06:18 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/**
- ******************************************************************************
- * @file Switch_class.h
- * @author AST / EST
- * @version V0.0.1
- * @date 14-April-2015
- * @brief Header file for red switch
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
-*/
-
-#ifndef __SWITCH_H
-#define __SWITCH_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-#include "stmpe1600_class.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
- RANGE = 0,
- ALS
-}SwitchState;
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing Red Switch
- */
-
-class SWITCH
-{
- public:
- SWITCH(STMPE1600 &stmpe_1600, ExpGpioPinName Pin_Name=GPIO_11) : stmpe1600(stmpe_1600), PinName(Pin_Name) {
- stmpe1600.setGPIOdir(PinName, INPUT);
- }
-
- bool RdSwitch () {
- return stmpe1600.rdGPIO(PinName);
- }
-
- operator int()
- {
- return RdSwitch();
- }
-
- private:
- STMPE1600 &stmpe1600;
- ExpGpioPinName PinName;
-};
-
-#ifdef __cplusplus
-}
-#endif
-#endif // __SWITCH_H
\ No newline at end of file
--- a/Components/VL6180X/vl6180x_class.h Fri Mar 03 15:06:18 2017 +0000
+++ b/Components/VL6180X/vl6180x_class.h Mon Mar 13 17:57:03 2017 +0100
@@ -218,7 +218,7 @@
* @brief Disable interrupt measure IRQ
* @return 0 on Success
*/
- void DisableInterruptMeasureDetectionIRQ(void)
+ void disable_interrupt_measure_detection_irq(void)
{
if (gpio1Int != NULL) gpio1Int->disable_irq();
}
--- a/Components/VL6180X/vl6180x_platform.h Fri Mar 03 15:06:18 2017 +0000
+++ b/Components/VL6180X/vl6180x_platform.h Mon Mar 13 17:57:03 2017 +0100
@@ -29,9 +29,9 @@
#include "vl6180x_def.h"
-#define VL6180x_SINGLE_DEVICE_DRIVER 0
+#define VL6180x_SINGLE_DEVICE_DRIVER 0
#define VL6180x_RANGE_STATUS_ERRSTRING 1
-#define VL6180X_SAFE_POLLING_ENTER 0
+#define VL6180X_SAFE_POLLING_ENTER 0
#define VL6180X_LOG_ENABLE 0
#define MY_LOG 1
@@ -58,15 +58,15 @@
trace_printf("beg %s start @%d\t" fmt "\n", __func__, LOG_GET_TIME(), ##__VA_ARGS__)
#define LOG_FUNCTION_END(status)\
- trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status)
+ trace_printf("end %s @%d %d\n", __func__, LOG_GET_TIME(), (int)status)
#define LOG_FUNCTION_END_FMT(status, fmt, ... )\
- trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)
+ trace_printf("End %s @%d %d\t"fmt"\n" , __func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)
#define VL6180x_ErrLog(msg, ... )\
- do{\
+ do {\
trace_printf("ERR in %s line %d\n" msg, __func__, __LINE__, ##__VA_ARGS__);\
- }while(0)
+ } while(0)
#else /* VL6180X_LOG_ENABLE no logging */
//void OnErrLog(void);
@@ -76,13 +76,11 @@
#define VL6180x_ErrLog(... ) //OnErrLog() //(void)0
#endif
-
#ifdef MY_LOG /* define printf as pc.printf in order to change the baudrate */
extern Serial pc;
#define printf(...) pc.printf(__VA_ARGS__)
#endif
-
#if VL6180x_SINGLE_DEVICE_DRIVER
#error "VL6180x_SINGLE_DEVICE_DRIVER must be set"
#endif
@@ -101,8 +99,4 @@
#define VL6180xDevDataGet(dev, field) (dev->Data.field)
#define VL6180xDevDataSet(dev, field, data) (dev->Data.field)=(data)
-
#endif /* VL6180x_PLATFORM */
-
-
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/XNucleo6180xa1.cpp Mon Mar 13 17:57:03 2017 +0100
@@ -0,0 +1,172 @@
+/**
+ ******************************************************************************
+ * @file XNucleo6180xa1.cpp
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 13-April-2015
+ * @brief Implementation file for the X_NUCLEO_VL6180XA1 singleton class
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "XNucleo6180xa1.h"
+
+
+/* Static variables ----------------------------------------------------------*/
+
+XNucleo6180xa1 *XNucleo6180xa1::_instance = NULL;
+
+
+/* Methods -------------------------------------------------------------------*/
+
+XNucleo6180xa1 *XNucleo6180xa1::instance(DevI2C *ext_i2c)
+{
+ if (_instance==NULL) {
+ _instance=new X_NUCLEO_6180XA1(ext_i2c);
+ } else {
+ VL6180x_ErrLog("Failed to create X_NUCLEO_6180XA1 instance\n\r");
+ }
+ return _instance;
+}
+
+XNucleo6180xa1 *XNucleo6180xa1::instance(DevI2C *ext_i2c,
+ PinName gpio1_top, PinName gpio1_bottom,
+ PinName gpio1_left, PinName gpio1_right)
+{
+ if (_instance==NULL) {
+ //_instance=new X_NUCLEO_6180XA1(ext_i2c);
+ _instance=new X_NUCLEO_6180XA1(ext_i2c, gpio1_top, gpio1_bottom, gpio1_left, gpio1_right);
+ } else {
+ VL6180x_ErrLog("Failed to create X_NUCLEO_6180XA1 instance\n\r");
+ }
+ return _instance;
+}
+
+int XNucleo6180xa1::init_board()
+{
+ int status, n_dev=0; uint8_t sensor_address;
+
+ if (sensor_top) {
+ sensor_top->VL6180x_Off();
+ }
+ if (sensor_bottom) {
+ sensor_bottom->VL6180x_Off();
+ }
+ if (sensor_left) {
+ sensor_left->VL6180x_Off();
+ }
+ if (sensor_right) {
+ sensor_right->VL6180x_Off();
+ }
+
+ sensor_address = NEW_SENSOR_TOP_ADDRESS;
+ status=sensor_top->init(&sensor_address);
+ if (status) {
+ printf("Error: Mandatory top sensor fail, Init failed!\n\r");
+ if (sensor_top !=NULL) {
+ delete sensor_top;
+ sensor_top=NULL;
+ }
+ if (sensor_left !=NULL) {
+ delete sensor_left;
+ sensor_left=NULL;
+ }
+ if (sensor_bottom !=NULL) {
+ delete sensor_bottom;
+ sensor_bottom=NULL;
+ }
+ if (sensor_right !=NULL) {
+ delete sensor_right;
+ sensor_right=NULL;
+ }
+ n_dev=0;
+ return 1;
+ } else {
+ printf("Sensor top present\n\r");
+ n_dev++;
+ }
+
+ sensor_address = NEW_SENSOR_BOTTOM_ADDRESS;
+ status=1;
+ if (sensor_bottom) {
+ status=sensor_bottom->init(&sensor_address);
+ }
+ if (status)
+ {
+ printf("Sensor bottom not present\n\r");
+ if (sensor_bottom !=NULL) {
+ delete sensor_bottom;
+ sensor_bottom=NULL;
+ }
+ } else {
+ printf("Sensor bottom present\n\r");
+ n_dev++;
+ }
+
+ sensor_address = NEW_SENSOR_LEFT_ADDRESS;
+ status=1;
+ if (sensor_left) {
+ status=sensor_left->init(&sensor_address);
+ }
+ if (status) {
+ printf("Sensor left not present\n\r");
+ if (sensor_left !=NULL) {
+ delete sensor_left;
+ sensor_left=NULL;
+ }
+ } else {
+ printf("Sensor left present\n\r");
+ n_dev++;
+ }
+
+ sensor_address = NEW_SENSOR_RIGHT_ADDRESS;
+ status=1;
+ if (sensor_right) {
+ status=sensor_right->init(&sensor_address);
+ }
+ if (status) {
+ printf("Sensor right not present\n\r");
+ if (sensor_right!=NULL) {
+ delete sensor_right;
+ sensor_right=NULL;
+ }
+ } else {
+ printf("Sensor right present\n\r");
+ n_dev++;
+ }
+
+ if (n_dev==0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/XNucleo6180xa1.h Mon Mar 13 17:57:03 2017 +0100
@@ -0,0 +1,236 @@
+/**
+ ******************************************************************************
+ * @file XNucleo6180xa1.h
+ * @author AST / EST
+ * @version V0.0.1
+ * @date 13-April-2015
+ * @brief Header file for class X_NUCLEO_6180XA1 representing a X-NUCLEO-6180XA1
+ * expansion board
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Define to prevent from recursive inclusion --------------------------------*/
+
+#ifndef __X_NUCLEO_6180XA1_H
+#define __X_NUCLEO_6180XA1_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "mbed.h"
+#include "vl6180x_class.h"
+#include "Display_class.h"
+#include "stmpe1600_class.h"
+#include "DevI2C.h"
+#include "Switch_class.h"
+
+/** New device addresses */
+#define NEW_SENSOR_TOP_ADDRESS 0x10
+#define NEW_SENSOR_BOTTOM_ADDRESS 0x11
+#define NEW_SENSOR_LEFT_ADDRESS 0x12
+#define NEW_SENSOR_RIGHT_ADDRESS 0x13
+
+
+/* Classes--------------------------------------------------------------------*/
+
+/**
+ * Class representing the X-NUCLEO-VL6180XA1 expansion board singleton obj
+ */
+class XNucleo6180xa1
+{
+protected:
+ /** Constructor 1
+ * @brief x_nucleo_6180xa1 board Constructor. Default the INT gpio \
+ * configuration as the electrical schematic. Self sensing for optional \
+ * expansion sensors (L/B/R).
+ * @param[in] &i2c device I2C to be used for communication
+ */
+ XNucleo6180xa1(DevI2C *ext_i2c) : dev_i2c(ext_i2c)
+ {
+ stmpe1600 = new STMPE1600(*ext_i2c);
+ stmpe1600->writeSYS_CTRL (SOFT_RESET);
+ Switch = new SWITCH (*stmpe1600, GPIO_11);
+ display = new Display(*stmpe1600);
+
+ _gpio0_top=new STMPE1600DigiOut(*dev_i2c, GPIO_12);
+ sensor_top=new VL6180X(*dev_i2c, *_gpio0_top, A3);
+
+ _gpio0_bottom=new STMPE1600DigiOut(*dev_i2c, GPIO_13);
+ sensor_bottom=new VL6180X(*dev_i2c, *_gpio0_bottom, A2);
+
+ _gpio0_left=new STMPE1600DigiOut(*dev_i2c, GPIO_14);
+ sensor_left=new VL6180X(*dev_i2c, *_gpio0_left, D13);
+
+ _gpio0_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15);
+ sensor_right=new VL6180X(*dev_i2c, *_gpio0_right, D2);
+
+ if (init_board()) { // init failed
+ printf ("ERROR Init X-NUCLEO-6180XA1 Board\n\r");
+ }
+ }
+
+ /** Constructor 2
+ * @param[in] &i2c device I2C to be used for communication
+ * @param[in] PinName gpio1_top Mbed DigitalOut pin name to be used as a top sensor GPIO_1 INT
+ * @param[in] PinName gpio1_bottom Mbed DigitalOut pin name to be used as a bottom sensor GPIO_1 INT
+ * @param[in] PinName gpio1_left Mbed DigitalOut pin name to be used as a left sensor GPIO_1 INT
+ * @param[in] PinName gpio1_right Mbed DigitalOut pin name to be used as a right sensor GPIO_1 INT
+ */
+ XNucleo6180xa1(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);
+
+ _gpio0_top=new STMPE1600DigiOut(*dev_i2c, GPIO_12);
+ sensor_top=new VL6180X(*dev_i2c, *_gpio0_top, gpio1_top);
+
+ _gpio0_bottom=new STMPE1600DigiOut(*dev_i2c, GPIO_13);
+ sensor_bottom=new VL6180X(*dev_i2c, *_gpio0_bottom, gpio1_bottom);
+
+ _gpio0_left=new STMPE1600DigiOut(*dev_i2c, GPIO_14);
+ sensor_left=new VL6180X(*dev_i2c, *_gpio0_left, gpio1_left);
+
+ _gpio0_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15);
+ sensor_right=new VL6180X(*dev_i2c, *_gpio0_right, gpio1_right);
+ }
+
+ /**
+ * @brief Override default copy constructor as empty
+ * @param[in] &XNucleo6180xa1 singleton object reference
+ * @return
+ */
+ XNucleo6180xa1() {};
+
+ /**
+ * @brief Override default assignement operator to avoid multiple singletons
+ * @param[in] &XNucleo6180xa1 singleton object reference
+ * @return
+ */
+ void operator = (const XNucleo6180xa1&);
+
+public:
+ /**
+ * @brief Creates a singleton object instance
+ * @param[in] &i2c device I2C to be used for communication
+ * @return Pointer to the object instance
+ */
+ static XNucleo6180xa1 *instance(DevI2C *ext_i2c);
+
+ /**
+ * @brief Creates a singleton object instance
+ * @param[in] &i2c device I2C to be used for communication
+ * @param[in] PinName gpio1_top the pin connected to top sensor INT
+ * @param[in] PinName gpio1_bottem the pin connected to bottom sensor INT
+ * @param[in] PinName gpio1_left the pin connected to left sensor INT
+ * @param[in] PinName gpio1_right the pin connected to right sensor INT
+ * @return Pointer to the object instance
+ */
+ static XNucleo6180xa1 *instance(DevI2C *ext_i2c, PinName gpio1_top, PinName gpio1_bottom,
+ PinName gpio1_left, PinName gpio1_right);
+
+ /**
+ * @brief Initialize the board and sensors with deft values
+ * @return 0 on success
+ */
+ int init_board();
+
+ /**
+ * @brief Read the on board red slider switch
+ * @return 0 or 1 according to switch position
+ */
+ bool rd_switch () {
+ return the_switch->rd_switch();
+ }
+
+ /**
+ * @brief Check the presence of sensor top. To be called after init_board
+ * @return true is present, false if absent
+ */
+ bool is_sensor_top_present() {
+ if (sensor_top) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @brief Check the presence of sensor bottom. To be called after init_board
+ * @return true is present, false if absent
+ */
+ bool is_sensor_bottom_present() {
+ if (sensor_bottom) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @brief Check the presence of sensor left. To be called after init_board
+ * @return true is present, false if absent
+ */
+ bool is_sensor_left_present() {
+ if (sensor_left) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @brief Check the presence of sensor right. To be called after init_board
+ * @return true is present, false if absent
+ */
+ bool is_sensor_right_present() {
+ if (sensor_right) {
+ return true;
+ }
+ return false;
+ }
+
+ DevI2C *dev_i2c;
+ VL6180X *sensor_top;
+ VL6180X *sensor_bottom;
+ VL6180X *sensor_left;
+ VL6180X *sensor_right;
+ STMPE1600 *stmpe1600;
+ SWITCH *the_witch;
+ Display *display;
+
+private:
+ STMPE1600DigiOut *_gpio0_top;
+ STMPE1600DigiOut *_gpio0_bottom;
+ STMPE1600DigiOut *_gpio0_left;
+ STMPE1600DigiOut *_gpio0_right;
+ static XNucleo6180xa1 *_instance;
+};
+
+#endif /* __X_NUCLEO_6180XA1_H */
--- a/x_nucleo_6180xa1.cpp Fri Mar 03 15:06:18 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/**
- ******************************************************************************
- * @file x_nucleo_6180xa1.cpp
- * @author AST / EST
- * @version V0.0.1
- * @date 13-April-2015
- * @brief Implementation file for the X_NUCLEO_VL6180XA1 singleton class
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-
-/* Includes ------------------------------------------------------------------*/
-#include "x_nucleo_6180xa1.h"
-
-/* Static variables ----------------------------------------------------------*/
-X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::_instance = NULL;
-
-X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::Instance(DevI2C *ext_i2c)
-{
- if(_instance==NULL)
- _instance=new X_NUCLEO_6180XA1(ext_i2c);
- else
- VL6180x_ErrLog("Failed to create X_NUCLEO_6180XA1 instance\n\r");
- return _instance;
-}
-
-X_NUCLEO_6180XA1* X_NUCLEO_6180XA1::Instance(DevI2C *ext_i2c,
- PinName gpio1_top, PinName gpio1_bottom,
- PinName gpio1_left, PinName gpio1_right)
-{
- if(_instance==NULL)
- //_instance=new X_NUCLEO_6180XA1(ext_i2c);
- _instance=new X_NUCLEO_6180XA1(ext_i2c, gpio1_top, gpio1_bottom, gpio1_left, gpio1_right);
- else
- VL6180x_ErrLog("Failed to create X_NUCLEO_6180XA1 instance\n\r");
- return _instance;
-}
-
-
-int X_NUCLEO_6180XA1::InitBoard()
-{
- int status, n_dev=0; uint8_t sensor_address;
-
- if (sensor_top) sensor_top->VL6180x_Off();
- if (sensor_bottom) sensor_bottom->VL6180x_Off();
- if (sensor_left) sensor_left->VL6180x_Off();
- if (sensor_right) sensor_right->VL6180x_Off();
- sensor_address = NEW_SENSOR_TOP_ADDRESS;
- status=sensor_top->Init(&sensor_address);
- if(status)
- {
- printf("Error: Mandatory top sensor fail, Init failed!\n\r");
- if (sensor_top !=NULL) { delete sensor_top; sensor_top=NULL; }
- if (sensor_left !=NULL) {delete sensor_left; sensor_left=NULL; }
- if (sensor_bottom !=NULL){ delete sensor_bottom; sensor_bottom=NULL; }
- if (sensor_right !=NULL) { delete sensor_right; sensor_right=NULL; }
- n_dev=0;
- return 1;
- }
- else
- {
- printf("Sensor top present\n\r");
- n_dev++;
- }
- sensor_address = NEW_SENSOR_BOTTOM_ADDRESS;
- status=1;
- if (sensor_bottom) status=sensor_bottom->Init(&sensor_address);
- if(status)
- {
- printf("Sensor bottom not present\n\r");
- if (sensor_bottom !=NULL) { delete sensor_bottom; sensor_bottom=NULL; }
- }
- else
- {
- printf("Sensor bottom present\n\r");
- n_dev++;
- }
- sensor_address = NEW_SENSOR_LEFT_ADDRESS;
- status=1;
- if (sensor_left) status=sensor_left->Init(&sensor_address);
- if(status)
- {
- printf("Sensor left not present\n\r");
- if (sensor_left !=NULL) {delete sensor_left; sensor_left=NULL; }
- }
- else
- {
- printf("Sensor left present\n\r");
- n_dev++;
- }
- sensor_address = NEW_SENSOR_RIGHT_ADDRESS;
- status=1;
- if (sensor_right) status=sensor_right->Init(&sensor_address);
- if(status)
- {
- printf("Sensor right not present\n\r");
- if (sensor_right !=NULL) { delete sensor_right; sensor_right=NULL; }
- }
- else
- {
- printf("Sensor right present\n\r");
- n_dev++;
- }
- if(n_dev==0)
- return 1;
- else
- return 0;
-}
-
-
--- a/x_nucleo_6180xa1.h Fri Mar 03 15:06:18 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-/**
- ******************************************************************************
- * @file x_nucleo_6180xa1.h
- * @author AST / EST
- * @version V0.0.1
- * @date 13-April-2015
- * @brief Header file for class X_NUCLEO_6180XA1 representing a X-NUCLEO-6180XA1
- * expansion board
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-/* Define to prevent from recursive inclusion --------------------------------*/
-#ifndef __X_NUCLEO_6180XA1_H
-#define __X_NUCLEO_6180XA1_H
-
-/* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
-#include "vl6180x_class.h"
-#include "Display_class.h"
-#include "stmpe1600_class.h"
-#include "DevI2C.h"
-#include "Switch_class.h"
-
-/** New device addresses */
-#define NEW_SENSOR_TOP_ADDRESS 0x10
-#define NEW_SENSOR_BOTTOM_ADDRESS 0x11
-#define NEW_SENSOR_LEFT_ADDRESS 0x12
-#define NEW_SENSOR_RIGHT_ADDRESS 0x13
-
-/* Classes--------------------------------------------------------------------*/
-
-/* Classes -------------------------------------------------------------------*/
-/** Class representing the X-NUCLEO-VL6180XA1 expansion board singleton obj
- */
-class X_NUCLEO_6180XA1
-{
-protected:
- /** Constructor 1
- * @brief x_nucleo_6180xa1 board Constructor. Default the INT gpio \
- * configuration as the electrical schematic. Self sensing for optional \
- * expansion sensors (L/B/R).
- * @param[in] &i2c device I2C to be used for communication
- */
- X_NUCLEO_6180XA1(DevI2C *ext_i2c) : dev_i2c(ext_i2c)
- {
- stmpe1600 = new STMPE1600(*ext_i2c);
- stmpe1600->writeSYS_CTRL (SOFT_RESET);
- Switch = new SWITCH (*stmpe1600, GPIO_11);
- display = new Display(*stmpe1600);
-
- gpio0_top=new STMPE1600DigiOut(*dev_i2c, GPIO_12);
- sensor_top=new VL6180X(*dev_i2c, *gpio0_top, A3);
-
- gpio0_bottom=new STMPE1600DigiOut(*dev_i2c, GPIO_13);
- sensor_bottom=new VL6180X(*dev_i2c, *gpio0_bottom, A2);
-
- gpio0_left=new STMPE1600DigiOut(*dev_i2c, GPIO_14);
- sensor_left=new VL6180X(*dev_i2c, *gpio0_left, D13);
-
- gpio0_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15);
- sensor_right=new VL6180X(*dev_i2c, *gpio0_right, D2);
-
- if (InitBoard()) { // init failed
- printf ("ERROR Init X-NUCLEO-6180XA1 Board\n\r");
- }
- }
-
- /** Constructor 2
- * @param[in] &i2c device I2C to be used for communication
- * @param[in] PinName gpio1_top Mbed DigitalOut pin name to be used as a top sensor GPIO_1 INT
- * @param[in] PinName gpio1_bottom Mbed DigitalOut pin name to be used as a bottom sensor GPIO_1 INT
- * @param[in] PinName gpio1_left Mbed DigitalOut pin name to be used as a left sensor GPIO_1 INT
- * @param[in] PinName gpio1_right Mbed DigitalOut pin name to be used as a right sensor GPIO_1 INT
- */
- 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);
-
- gpio0_top=new STMPE1600DigiOut(*dev_i2c, GPIO_12);
- sensor_top=new VL6180X(*dev_i2c, *gpio0_top, gpio1_top);
-
- gpio0_bottom=new STMPE1600DigiOut(*dev_i2c, GPIO_13);
- sensor_bottom=new VL6180X(*dev_i2c, *gpio0_bottom, gpio1_bottom);
-
- gpio0_left=new STMPE1600DigiOut(*dev_i2c, GPIO_14);
- sensor_left=new VL6180X(*dev_i2c, *gpio0_left, gpio1_left);
-
- gpio0_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15);
- sensor_right=new VL6180X(*dev_i2c, *gpio0_right, gpio1_right);
- }
-
- /**
- * @brief Override default copy constructor as empty
- * @param[in] &X_NUCLEO_6180XA1 singleton object reference
- * @return
- */
- X_NUCLEO_6180XA1() {};
-
- /**
- * @brief Override default assignement operator to avoid multiple singletons
- * @param[in] &X_NUCLEO_6180XA1 singleton object reference
- * @return
- */
- void operator = (const X_NUCLEO_6180XA1&);
-
-public:
- /**
- * @brief Creates a singleton object instance
- * @param[in] &i2c device I2C to be used for communication
- * @return Pointer to the object instance
- */
- static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c);
-
- /**
- * @brief Creates a singleton object instance
- * @param[in] &i2c device I2C to be used for communication
- * @param[in] PinName gpio1_top the pin connected to top sensor INT
- * @param[in] PinName gpio1_bottem the pin connected to bottom sensor INT
- * @param[in] PinName gpio1_left the pin connected to left sensor INT
- * @param[in] PinName gpio1_right the pin connected to right sensor INT
- * @return Pointer to the object instance
- */
- static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c, PinName gpio1_top, PinName gpio1_bottom,
- PinName gpio1_left, PinName gpio1_right);
-
- /**
- * @brief Initialize the board and sensors with deft values
- * @return 0 on success
- */
- int InitBoard();
-
- /**
- * @brief Read the on board red slider switch
- * @return 0 or 1 according to switch position
- */
- bool RdSwitch () {
- return Switch->RdSwitch();
- }
-
- /**
- * @brief Check the presence of sensor top. To be called after InitBoard
- * @return true is present, false if absent
- */
- bool isSensorTopPresent() {
- if (sensor_top) return true;
- return false;
- }
-
- /**
- * @brief Check the presence of sensor bottom. To be called after InitBoard
- * @return true is present, false if absent
- */
- bool isSensorBottomPresent() {
- if (sensor_bottom) return true;
- return false;
- }
-
- /**
- * @brief Check the presence of sensor left. To be called after InitBoard
- * @return true is present, false if absent
- */
- bool isSensorLeftPresent() {
- if (sensor_left) return true;
- return false;
- }
-
- /**
- * @brief Check the presence of sensor right. To be called after InitBoard
- * @return true is present, false if absent
- */
- bool isSensorRightPresent() {
- if (sensor_right) return true;
- return false;
- }
-
- DevI2C *dev_i2c;
- VL6180X *sensor_top;
- VL6180X *sensor_bottom;
- VL6180X *sensor_left;
- VL6180X *sensor_right;
- STMPE1600 * stmpe1600;
- SWITCH * Switch;
- Display *display;
-
-private:
- STMPE1600DigiOut *gpio0_top;
- STMPE1600DigiOut *gpio0_bottom;
- STMPE1600DigiOut *gpio0_left;
- STMPE1600DigiOut *gpio0_right;
- static X_NUCLEO_6180XA1 *_instance;
-};
-
-#endif /* __X_NUCLEO_6180XA1_H */

X-NUCLEO-6180XA1 Proximity and Ambient Light Sensor