Now you can use NC as InterruptIn

Dependencies:   X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

Committer:
licio.mapelli@st.com
Date:
Tue Nov 17 17:15:47 2015 +0100
Revision:
33:1573db91352c
Parent:
27:22c6f69967d9
Child:
36:f6278b3e7c82
Added Switch class, added self contained Display class, added STMPE1600 component
and modified X_NUCLEO_6180XA1 class accordingly

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gallonm 0:1fb1f010ac84 1 /**
gallonm 0:1fb1f010ac84 2 ******************************************************************************
gallonm 0:1fb1f010ac84 3 * @file x_nucleo_6180xa1.h
gallonm 0:1fb1f010ac84 4 * @author AST / EST
gallonm 0:1fb1f010ac84 5 * @version V0.0.1
gallonm 0:1fb1f010ac84 6 * @date 13-April-2015
gallonm 0:1fb1f010ac84 7 * @brief Header file for class X_NUCLEO_6180XA1 representing a X-NUCLEO-6180XA1
gallonm 0:1fb1f010ac84 8 * expansion board
gallonm 0:1fb1f010ac84 9 ******************************************************************************
gallonm 0:1fb1f010ac84 10 * @attention
gallonm 0:1fb1f010ac84 11 *
gallonm 0:1fb1f010ac84 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
gallonm 0:1fb1f010ac84 13 *
gallonm 0:1fb1f010ac84 14 * Redistribution and use in source and binary forms, with or without modification,
gallonm 0:1fb1f010ac84 15 * are permitted provided that the following conditions are met:
gallonm 0:1fb1f010ac84 16 * 1. Redistributions of source code must retain the above copyright notice,
gallonm 0:1fb1f010ac84 17 * this list of conditions and the following disclaimer.
gallonm 0:1fb1f010ac84 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
gallonm 0:1fb1f010ac84 19 * this list of conditions and the following disclaimer in the documentation
gallonm 0:1fb1f010ac84 20 * and/or other materials provided with the distribution.
gallonm 0:1fb1f010ac84 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
gallonm 0:1fb1f010ac84 22 * may be used to endorse or promote products derived from this software
gallonm 0:1fb1f010ac84 23 * without specific prior written permission.
gallonm 0:1fb1f010ac84 24 *
gallonm 0:1fb1f010ac84 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
gallonm 0:1fb1f010ac84 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
gallonm 0:1fb1f010ac84 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
gallonm 0:1fb1f010ac84 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
gallonm 0:1fb1f010ac84 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
gallonm 0:1fb1f010ac84 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
gallonm 0:1fb1f010ac84 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
gallonm 0:1fb1f010ac84 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
gallonm 0:1fb1f010ac84 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
gallonm 0:1fb1f010ac84 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gallonm 0:1fb1f010ac84 35 *
gallonm 0:1fb1f010ac84 36 ******************************************************************************
gallonm 0:1fb1f010ac84 37 */
gallonm 0:1fb1f010ac84 38
gallonm 0:1fb1f010ac84 39 /* Define to prevent from recursive inclusion --------------------------------*/
gallonm 0:1fb1f010ac84 40 #ifndef __X_NUCLEO_6180XA1_H
gallonm 0:1fb1f010ac84 41 #define __X_NUCLEO_6180XA1_H
gallonm 0:1fb1f010ac84 42
gallonm 0:1fb1f010ac84 43 /* Includes ------------------------------------------------------------------*/
gallonm 0:1fb1f010ac84 44 #include "mbed.h"
gallonm 0:1fb1f010ac84 45 #include "vl6180x_class.h"
gallonm 16:0d4776564733 46 #include "Display_class.h"
gallonm 18:c98aa73dc4a5 47 #include "stmpe1600_class.h"
gallonm 0:1fb1f010ac84 48 #include "DevI2C.h"
licio.mapelli@st.com 33:1573db91352c 49 #include "Switch_class.h"
gallonm 0:1fb1f010ac84 50
gallonm 15:454710d17358 51 /** New device addresses */
gallonm 10:4954b09b72d8 52 #define NEW_SENSOR_TOP_ADDRESS 0x10
gallonm 15:454710d17358 53 #define NEW_SENSOR_BOTTOM_ADDRESS 0x11
gallonm 15:454710d17358 54 #define NEW_SENSOR_LEFT_ADDRESS 0x12
gallonm 15:454710d17358 55 #define NEW_SENSOR_RIGHT_ADDRESS 0x13
gallonm 10:4954b09b72d8 56
gallonm 4:a5abf7757947 57 /* Classes--------------------------------------------------------------------*/
gallonm 0:1fb1f010ac84 58
gallonm 10:4954b09b72d8 59 class X_NUCLEO_6180XA1
gallonm 4:a5abf7757947 60 {
gallonm 16:0d4776564733 61 public:
gallonm 16:0d4776564733 62 X_NUCLEO_6180XA1(DevI2C *ext_i2c) : dev_i2c(ext_i2c)
gallonm 10:4954b09b72d8 63 {
licio.mapelli@st.com 33:1573db91352c 64 stmpe1600 = new STMPE1600(*ext_i2c);
licio.mapelli@st.com 33:1573db91352c 65 stmpe1600->writeSYS_CTRL (SOFT_RESET);
licio.mapelli@st.com 33:1573db91352c 66 Switch = new SWITCH (*stmpe1600, GPIO_11);
licio.mapelli@st.com 33:1573db91352c 67 display = new Display(*stmpe1600);
licio.mapelli@st.com 33:1573db91352c 68
licio.mapelli@st.com 33:1573db91352c 69 /*digit1=new STMPE1600DigiOut(*dev_i2c, GPIO_7);
gallonm 16:0d4776564733 70 digit2=new STMPE1600DigiOut(*dev_i2c, GPIO_8);
gallonm 16:0d4776564733 71 digit3=new STMPE1600DigiOut(*dev_i2c, GPIO_9);
gallonm 16:0d4776564733 72 digit4=new STMPE1600DigiOut(*dev_i2c, GPIO_10);
gallonm 16:0d4776564733 73
gallonm 16:0d4776564733 74 dispA=new STMPE1600DigiOut(*dev_i2c, GPIO_0);
gallonm 16:0d4776564733 75 dispB=new STMPE1600DigiOut(*dev_i2c, GPIO_1);
gallonm 16:0d4776564733 76 dispC=new STMPE1600DigiOut(*dev_i2c, GPIO_2);
gallonm 16:0d4776564733 77 dispD=new STMPE1600DigiOut(*dev_i2c, GPIO_3);
gallonm 16:0d4776564733 78 dispE=new STMPE1600DigiOut(*dev_i2c, GPIO_4);
gallonm 16:0d4776564733 79 dispF=new STMPE1600DigiOut(*dev_i2c, GPIO_5);
licio.mapelli@st.com 33:1573db91352c 80 dispG=new STMPE1600DigiOut(*dev_i2c, GPIO_6);*/
gallonm 16:0d4776564733 81 //display=new Display(*digit1,*digit2,*digit3,*digit4,*dispA,*dispB,*dispC,*dispD,*dispE,*dispF,*dispG);
licio.mapelli@st.com 33:1573db91352c 82 //display=new Display(*ext_i2c);
gallonm 16:0d4776564733 83
gallonm 16:0d4776564733 84 gpio0_top=new STMPE1600DigiOut(*dev_i2c, GPIO_12);
gallonm 16:0d4776564733 85 sensor_top=new VL6180X(*dev_i2c, *gpio0_top, PB_0);
gallonm 16:0d4776564733 86
gallonm 16:0d4776564733 87 gpio0_bottom=new STMPE1600DigiOut(*dev_i2c, GPIO_13);
gallonm 16:0d4776564733 88 sensor_bottom=new VL6180X(*dev_i2c, *gpio0_bottom, PA_4);
gallonm 16:0d4776564733 89
gallonm 16:0d4776564733 90 gpio0_left=new STMPE1600DigiOut(*dev_i2c, GPIO_14);
gallonm 16:0d4776564733 91 sensor_left=new VL6180X(*dev_i2c, *gpio0_left, PA_5);
gallonm 16:0d4776564733 92
gallonm 16:0d4776564733 93 gpio0_right=new STMPE1600DigiOut(*dev_i2c, GPIO_15);
gallonm 16:0d4776564733 94 sensor_right=new VL6180X(*dev_i2c, *gpio0_right, PA_10);
gallonm 16:0d4776564733 95 }
gallonm 4:a5abf7757947 96
gallonm 16:0d4776564733 97 ~X_NUCLEO_6180XA1()
gallonm 10:4954b09b72d8 98 {
gallonm 16:0d4776564733 99 if(gpio0_top!=NULL)
gallonm 16:0d4776564733 100 {
gallonm 16:0d4776564733 101 delete gpio0_top;
gallonm 16:0d4776564733 102 gpio0_top=NULL;
gallonm 16:0d4776564733 103 }
gallonm 16:0d4776564733 104 if(sensor_top!=NULL)
gallonm 16:0d4776564733 105 {
gallonm 16:0d4776564733 106 delete sensor_top;
licio.mapelli@st.com 33:1573db91352c 107 sensor_top=NULL;
gallonm 16:0d4776564733 108 }
gallonm 16:0d4776564733 109 if(gpio0_bottom!=NULL)
gallonm 16:0d4776564733 110 {
gallonm 16:0d4776564733 111 delete gpio0_bottom;
gallonm 16:0d4776564733 112 gpio0_bottom=NULL;
gallonm 16:0d4776564733 113 }
gallonm 16:0d4776564733 114 if(sensor_bottom!=NULL)
gallonm 16:0d4776564733 115 {
gallonm 16:0d4776564733 116 delete sensor_bottom;
licio.mapelli@st.com 33:1573db91352c 117 sensor_bottom=NULL;
gallonm 16:0d4776564733 118 }
gallonm 16:0d4776564733 119 if(gpio0_left!=NULL)
gallonm 16:0d4776564733 120 {
gallonm 16:0d4776564733 121 delete gpio0_left;
gallonm 16:0d4776564733 122 gpio0_left=NULL;
gallonm 16:0d4776564733 123 }
gallonm 16:0d4776564733 124 if(sensor_left!=NULL)
gallonm 16:0d4776564733 125 {
gallonm 16:0d4776564733 126 delete sensor_left;
licio.mapelli@st.com 33:1573db91352c 127 sensor_left=NULL;
gallonm 16:0d4776564733 128 }
gallonm 16:0d4776564733 129 if(gpio0_right!=NULL)
gallonm 16:0d4776564733 130 {
gallonm 16:0d4776564733 131 delete gpio0_right;
gallonm 16:0d4776564733 132 gpio0_right=NULL;
gallonm 16:0d4776564733 133 }
gallonm 16:0d4776564733 134 if(sensor_right!=NULL)
gallonm 16:0d4776564733 135 {
gallonm 16:0d4776564733 136 delete sensor_right;
licio.mapelli@st.com 33:1573db91352c 137 sensor_right=NULL;
gallonm 16:0d4776564733 138 }
licio.mapelli@st.com 33:1573db91352c 139 /*delete digit1;
gallonm 22:1a6327e9a7e6 140 delete digit2;
gallonm 22:1a6327e9a7e6 141 delete digit3;
gallonm 22:1a6327e9a7e6 142 delete digit4;
gallonm 22:1a6327e9a7e6 143 delete dispA;
gallonm 22:1a6327e9a7e6 144 delete dispB;
gallonm 22:1a6327e9a7e6 145 delete dispC;
gallonm 22:1a6327e9a7e6 146 delete dispD;
gallonm 22:1a6327e9a7e6 147 delete dispE;
gallonm 22:1a6327e9a7e6 148 delete dispF;
licio.mapelli@st.com 33:1573db91352c 149 delete dispG;*/
licio.mapelli@st.com 33:1573db91352c 150 delete stmpe1600;
licio.mapelli@st.com 33:1573db91352c 151 delete Switch;
licio.mapelli@st.com 33:1573db91352c 152 delete display;
gallonm 27:22c6f69967d9 153 _instance=NULL;
gallonm 16:0d4776564733 154 }
licio.mapelli@st.com 33:1573db91352c 155
licio.mapelli@st.com 33:1573db91352c 156 bool RdSwitch () {
licio.mapelli@st.com 33:1573db91352c 157 return Switch->RdSwitch();
licio.mapelli@st.com 33:1573db91352c 158 }
licio.mapelli@st.com 33:1573db91352c 159
gallonm 16:0d4776564733 160 DevI2C *dev_i2c;
gallonm 16:0d4776564733 161
gallonm 16:0d4776564733 162 VL6180X *sensor_top;
gallonm 16:0d4776564733 163 VL6180X *sensor_bottom;
gallonm 16:0d4776564733 164 VL6180X *sensor_left;
gallonm 16:0d4776564733 165 VL6180X *sensor_right;
licio.mapelli@st.com 33:1573db91352c 166
licio.mapelli@st.com 33:1573db91352c 167 STMPE1600 * stmpe1600;
licio.mapelli@st.com 33:1573db91352c 168 SWITCH * Switch;
licio.mapelli@st.com 33:1573db91352c 169
gallonm 16:0d4776564733 170 STMPE1600DigiOut *gpio0_top;
gallonm 16:0d4776564733 171 STMPE1600DigiOut *gpio0_bottom;
gallonm 16:0d4776564733 172 STMPE1600DigiOut *gpio0_left;
gallonm 16:0d4776564733 173 STMPE1600DigiOut *gpio0_right;
gallonm 16:0d4776564733 174
gallonm 16:0d4776564733 175 STMPE1600DigiOut *digit1;
gallonm 16:0d4776564733 176 STMPE1600DigiOut *digit2;
gallonm 16:0d4776564733 177 STMPE1600DigiOut *digit3;
gallonm 16:0d4776564733 178 STMPE1600DigiOut *digit4;
gallonm 10:4954b09b72d8 179
gallonm 16:0d4776564733 180 STMPE1600DigiOut *dispA;
gallonm 16:0d4776564733 181 STMPE1600DigiOut *dispB;
gallonm 16:0d4776564733 182 STMPE1600DigiOut *dispC;
gallonm 16:0d4776564733 183 STMPE1600DigiOut *dispD;
gallonm 16:0d4776564733 184 STMPE1600DigiOut *dispE;
gallonm 16:0d4776564733 185 STMPE1600DigiOut *dispF;
gallonm 16:0d4776564733 186 STMPE1600DigiOut *dispG;
gallonm 16:0d4776564733 187
gallonm 16:0d4776564733 188 Display *display;
gallonm 4:a5abf7757947 189
gallonm 16:0d4776564733 190 static X_NUCLEO_6180XA1 *Instance(DevI2C *ext_i2c);
gallonm 16:0d4776564733 191
gallonm 16:0d4776564733 192 int InitBoard();
gallonm 16:0d4776564733 193
gallonm 16:0d4776564733 194 private:
gallonm 16:0d4776564733 195 static X_NUCLEO_6180XA1 *_instance;
gallonm 10:4954b09b72d8 196 };
gallonm 0:1fb1f010ac84 197
gallonm 7:2dc81120c917 198 #endif /* __X_NUCLEO_6180XA1_H */