Now you can use NC as InterruptIn

Dependencies:   X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

Committer:
mapellil
Date:
Tue Nov 24 16:04:41 2015 +0000
Revision:
36:f6278b3e7c82
Parent:
33:1573db91352c
Exposed GPIOs on constructor, code cleanup, doxy comment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gallonm 7:2dc81120c917 1 /**
gallonm 7:2dc81120c917 2 ******************************************************************************
mapellil 36:f6278b3e7c82 3 * @file stmpe1600_class.h
gallonm 7:2dc81120c917 4 * @author AST / EST
gallonm 7:2dc81120c917 5 * @version V0.0.1
gallonm 7:2dc81120c917 6 * @date 14-April-2015
mapellil 36:f6278b3e7c82 7 * @brief Header file for component stmpe1600
gallonm 7:2dc81120c917 8 ******************************************************************************
gallonm 7:2dc81120c917 9 * @attention
gallonm 7:2dc81120c917 10 *
gallonm 7:2dc81120c917 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
gallonm 7:2dc81120c917 12 *
gallonm 7:2dc81120c917 13 * Redistribution and use in source and binary forms, with or without modification,
gallonm 7:2dc81120c917 14 * are permitted provided that the following conditions are met:
gallonm 7:2dc81120c917 15 * 1. Redistributions of source code must retain the above copyright notice,
gallonm 7:2dc81120c917 16 * this list of conditions and the following disclaimer.
gallonm 7:2dc81120c917 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
gallonm 7:2dc81120c917 18 * this list of conditions and the following disclaimer in the documentation
gallonm 7:2dc81120c917 19 * and/or other materials provided with the distribution.
gallonm 7:2dc81120c917 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
gallonm 7:2dc81120c917 21 * may be used to endorse or promote products derived from this software
gallonm 7:2dc81120c917 22 * without specific prior written permission.
gallonm 7:2dc81120c917 23 *
gallonm 7:2dc81120c917 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
gallonm 7:2dc81120c917 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
gallonm 7:2dc81120c917 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
gallonm 7:2dc81120c917 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
gallonm 7:2dc81120c917 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
gallonm 7:2dc81120c917 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
gallonm 7:2dc81120c917 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
gallonm 7:2dc81120c917 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
gallonm 7:2dc81120c917 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
gallonm 7:2dc81120c917 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gallonm 7:2dc81120c917 34 *
gallonm 7:2dc81120c917 35 ******************************************************************************
gallonm 7:2dc81120c917 36 */
gallonm 7:2dc81120c917 37 #ifndef __STMPE1600_CLASS
gallonm 7:2dc81120c917 38 #define __STMPE1600_CLASS
gallonm 7:2dc81120c917 39 /* Includes ------------------------------------------------------------------*/
gallonm 10:4954b09b72d8 40 #include "DevI2C.h"
gallonm 7:2dc81120c917 41
licio.mapelli@st.com 8:f943a1fca15f 42 #define STMPE1600_DEF_DEVICE_ADDRESS (uint8_t)0x42*2
licio.mapelli@st.com 8:f943a1fca15f 43 #define STMPE1600_DEF_DIGIOUT_LVL 1
gallonm 7:2dc81120c917 44
gallonm 7:2dc81120c917 45 /** STMPE1600 registr map **/
licio.mapelli@st.com 33:1573db91352c 46 #define ChipID_0_7 (uint8_t)0x00
licio.mapelli@st.com 33:1573db91352c 47 #define ChipID_8_15 (uint8_t)0x01
gallonm 16:0d4776564733 48 #define VersionId (uint8_t)0x02
licio.mapelli@st.com 33:1573db91352c 49 #define SYS_CTRL (uint8_t)0x03
licio.mapelli@st.com 33:1573db91352c 50 #define IEGPIOR_0_7 (uint8_t)0x08
licio.mapelli@st.com 33:1573db91352c 51 #define IEGPIOR_8_15 (uint8_t)0x09
licio.mapelli@st.com 33:1573db91352c 52 #define ISGPIOR_0_7 (uint8_t)0x0A
licio.mapelli@st.com 33:1573db91352c 53 #define ISGPIOR_8_15 (uint8_t)0x0B
licio.mapelli@st.com 33:1573db91352c 54 #define GPMR_0_7 (uint8_t)0x10
licio.mapelli@st.com 33:1573db91352c 55 #define GPMR_8_15 (uint8_t)0x11
licio.mapelli@st.com 33:1573db91352c 56 #define GPSR_0_7 (uint8_t)0x12
licio.mapelli@st.com 33:1573db91352c 57 #define GPSR_8_15 (uint8_t)0x13
licio.mapelli@st.com 33:1573db91352c 58 #define GPDR_0_7 (uint8_t)0x14
licio.mapelli@st.com 33:1573db91352c 59 #define GPDR_8_15 (uint8_t)0x15
licio.mapelli@st.com 33:1573db91352c 60 #define GPIR_0_7 (uint8_t)0x16
licio.mapelli@st.com 33:1573db91352c 61 #define GPIR_8_15 (uint8_t)0x17
licio.mapelli@st.com 33:1573db91352c 62
licio.mapelli@st.com 33:1573db91352c 63 #define SOFT_RESET (uint8_t)0x80
gallonm 7:2dc81120c917 64
gallonm 7:2dc81120c917 65 typedef enum {
gallonm 7:2dc81120c917 66 // GPIO Expander pin names
gallonm 15:454710d17358 67 GPIO_0=0,
gallonm 7:2dc81120c917 68 GPIO_1,
gallonm 7:2dc81120c917 69 GPIO_2,
gallonm 7:2dc81120c917 70 GPIO_3,
gallonm 7:2dc81120c917 71 GPIO_4,
gallonm 7:2dc81120c917 72 GPIO_5,
gallonm 7:2dc81120c917 73 GPIO_6,
gallonm 7:2dc81120c917 74 GPIO_7,
gallonm 7:2dc81120c917 75 GPIO_8,
gallonm 7:2dc81120c917 76 GPIO_9,
gallonm 7:2dc81120c917 77 GPIO_10,
gallonm 7:2dc81120c917 78 GPIO_11,
gallonm 7:2dc81120c917 79 GPIO_12,
gallonm 7:2dc81120c917 80 GPIO_13,
gallonm 7:2dc81120c917 81 GPIO_14,
licio.mapelli@st.com 33:1573db91352c 82 GPIO_15,
mapellil 36:f6278b3e7c82 83 NOT_CON
gallonm 7:2dc81120c917 84 } ExpGpioPinName;
gallonm 7:2dc81120c917 85
gallonm 7:2dc81120c917 86 typedef enum {
gallonm 16:0d4776564733 87 INPUT = 0,
gallonm 7:2dc81120c917 88 OUTPUT,
gallonm 16:0d4776564733 89 NOT_CONNECTED
gallonm 7:2dc81120c917 90 }ExpGpioPinDirection;
gallonm 7:2dc81120c917 91
mapellil 36:f6278b3e7c82 92 /* Classes -------------------------------------------------------------------*/
mapellil 36:f6278b3e7c82 93 /** Class representing a single stmpe1600 GPIO expander output pin
mapellil 36:f6278b3e7c82 94 */
gallonm 7:2dc81120c917 95 class STMPE1600DigiOut {
gallonm 7:2dc81120c917 96
gallonm 7:2dc81120c917 97 public:
mapellil 36:f6278b3e7c82 98 /** Constructor
mapellil 36:f6278b3e7c82 99 * @param[in] &i2c device I2C to be used for communication
mapellil 36:f6278b3e7c82 100 * @param[in] outpinname the desired out pin name to be created
mapellil 36:f6278b3e7c82 101 * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
mapellil 36:f6278b3e7c82 102 * @param[in] lvl the default ot pin level
mapellil 36:f6278b3e7c82 103 */
gallonm 7:2dc81120c917 104 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)
gallonm 16:0d4776564733 105 {
gallonm 16:0d4776564733 106 uint8_t data[2];
licio.mapelli@st.com 33:1573db91352c 107 if (exppinname == NOT_CON) return;
gallonm 16:0d4776564733 108 /* set the exppinname as output */
gallonm 16:0d4776564733 109 dev_i2c.i2c_read(data, expdevaddr, GPDR_0_7, 1);
gallonm 16:0d4776564733 110 dev_i2c.i2c_read(&data[1], expdevaddr, GPDR_8_15, 1);
gallonm 16:0d4776564733 111 *(uint16_t*)data = *(uint16_t*)data | (1<<(uint16_t)exppinname); // set gpio as out
gallonm 16:0d4776564733 112 dev_i2c.i2c_write(data, expdevaddr, GPDR_0_7, 1);
gallonm 16:0d4776564733 113 dev_i2c.i2c_write(&data[1], expdevaddr, GPDR_8_15, 1);
gallonm 16:0d4776564733 114 write(lvl);
gallonm 23:dfb5ccc7b780 115 }
gallonm 7:2dc81120c917 116
mapellil 36:f6278b3e7c82 117 /**
mapellil 36:f6278b3e7c82 118 * @brief Write on the out pin
mapellil 36:f6278b3e7c82 119 * @param[in] lvl level to write
mapellil 36:f6278b3e7c82 120 * @return 0 on Success
mapellil 36:f6278b3e7c82 121 */
gallonm 23:dfb5ccc7b780 122 void write (int lvl)
gallonm 23:dfb5ccc7b780 123 {
gallonm 23:dfb5ccc7b780 124 uint8_t data[2];
licio.mapelli@st.com 33:1573db91352c 125 if (exppinname == NOT_CON) return;
gallonm 23:dfb5ccc7b780 126 /* set the exppinname state to lvl */
gallonm 23:dfb5ccc7b780 127 dev_i2c.i2c_read(data, expdevaddr, GPSR_0_7, 2);
gallonm 23:dfb5ccc7b780 128 *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(~(1<<(uint16_t)exppinname)); // set pin mask
gallonm 23:dfb5ccc7b780 129 if (lvl) *(uint16_t*)data = *(uint16_t*)data | (uint16_t)(1<<(uint16_t)exppinname);
gallonm 23:dfb5ccc7b780 130 dev_i2c.i2c_write(data, expdevaddr, GPSR_0_7, 2);
gallonm 23:dfb5ccc7b780 131 }
mapellil 36:f6278b3e7c82 132
mapellil 36:f6278b3e7c82 133 /**
mapellil 36:f6278b3e7c82 134 * @brief Overload assignement operator
mapellil 36:f6278b3e7c82 135 */
gallonm 16:0d4776564733 136 STMPE1600DigiOut& operator=(int lvl)
gallonm 16:0d4776564733 137 {
gallonm 16:0d4776564733 138 write (lvl);
gallonm 16:0d4776564733 139 return *this;
gallonm 16:0d4776564733 140 }
gallonm 7:2dc81120c917 141
gallonm 7:2dc81120c917 142 private:
gallonm 16:0d4776564733 143 DevI2C &dev_i2c;
gallonm 16:0d4776564733 144 uint8_t expdevaddr;
gallonm 16:0d4776564733 145 ExpGpioPinName exppinname;
gallonm 7:2dc81120c917 146 };
gallonm 7:2dc81120c917 147
mapellil 36:f6278b3e7c82 148 /* Classes -------------------------------------------------------------------*/
mapellil 36:f6278b3e7c82 149 /** Class representing a single stmpe1600 GPIO expander input pin
mapellil 36:f6278b3e7c82 150 */
gallonm 16:0d4776564733 151 class STMPE1600DigiIn
gallonm 16:0d4776564733 152 {
gallonm 7:2dc81120c917 153 public:
mapellil 36:f6278b3e7c82 154 /** Constructor
mapellil 36:f6278b3e7c82 155 * @param[in] &i2c device I2C to be used for communication
mapellil 36:f6278b3e7c82 156 * @param[in] inpinname the desired input pin name to be created
mapellil 36:f6278b3e7c82 157 * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
mapellil 36:f6278b3e7c82 158 */
gallonm 23:dfb5ccc7b780 159 STMPE1600DigiIn (DevI2C &i2c, ExpGpioPinName inpinname, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS): dev_i2c(i2c), expdevaddr(DevAddr), exppinname(inpinname)
gallonm 23:dfb5ccc7b780 160 {
gallonm 23:dfb5ccc7b780 161 uint8_t data[2];
licio.mapelli@st.com 33:1573db91352c 162 if (exppinname == NOT_CON) return;
gallonm 23:dfb5ccc7b780 163 /* set the exppinname as input pin direction */
gallonm 23:dfb5ccc7b780 164 dev_i2c.i2c_read(data, expdevaddr, GPDR_0_7, 2);
gallonm 23:dfb5ccc7b780 165 *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(~(1<<(uint16_t)exppinname)); // set gpio as in
gallonm 23:dfb5ccc7b780 166 dev_i2c.i2c_write(data, expdevaddr, GPDR_0_7, 2);
gallonm 23:dfb5ccc7b780 167 }
gallonm 7:2dc81120c917 168
mapellil 36:f6278b3e7c82 169 /**
mapellil 36:f6278b3e7c82 170 * @brief Read the input pin
mapellil 36:f6278b3e7c82 171 * @return The pin logical state 0 or 1
mapellil 36:f6278b3e7c82 172 */
gallonm 23:dfb5ccc7b780 173 bool read ()
gallonm 23:dfb5ccc7b780 174 {
gallonm 23:dfb5ccc7b780 175 uint8_t data[2];
licio.mapelli@st.com 33:1573db91352c 176 if (exppinname == NOT_CON) return 0;
gallonm 23:dfb5ccc7b780 177 /* read the exppinname */
gallonm 23:dfb5ccc7b780 178 dev_i2c.i2c_read(data, expdevaddr, GPMR_0_7, 2);
gallonm 23:dfb5ccc7b780 179 *(uint16_t*)data = *(uint16_t*)data & (uint16_t)(1<<(uint16_t)exppinname); // mask the in gpio
gallonm 23:dfb5ccc7b780 180 if (data[0] || data[1]) return 1;
gallonm 23:dfb5ccc7b780 181 return 0;
gallonm 23:dfb5ccc7b780 182 }
gallonm 7:2dc81120c917 183
gallonm 16:0d4776564733 184 operator int()
gallonm 16:0d4776564733 185 {
gallonm 16:0d4776564733 186 return read();
gallonm 16:0d4776564733 187 }
gallonm 7:2dc81120c917 188
gallonm 7:2dc81120c917 189 private:
gallonm 16:0d4776564733 190 DevI2C &dev_i2c;
gallonm 16:0d4776564733 191 uint8_t expdevaddr;
gallonm 16:0d4776564733 192 ExpGpioPinName exppinname;
gallonm 7:2dc81120c917 193 };
gallonm 7:2dc81120c917 194
mapellil 36:f6278b3e7c82 195 /* Classes -------------------------------------------------------------------*/
mapellil 36:f6278b3e7c82 196 /** Class representing a whole stmpe1600 component (16 gpio)
mapellil 36:f6278b3e7c82 197 */
gallonm 16:0d4776564733 198 class STMPE1600 {
gallonm 16:0d4776564733 199
gallonm 16:0d4776564733 200 public:
mapellil 36:f6278b3e7c82 201 /** Constructor
mapellil 36:f6278b3e7c82 202 * @param[in] &i2c device I2C to be used for communication
mapellil 36:f6278b3e7c82 203 * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
mapellil 36:f6278b3e7c82 204 */
licio.mapelli@st.com 33:1573db91352c 205 STMPE1600 (DevI2C &i2c, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS ) : dev_i2c(i2c)
gallonm 23:dfb5ccc7b780 206 {
gallonm 23:dfb5ccc7b780 207 dev_i2c = i2c;
gallonm 23:dfb5ccc7b780 208 expdevaddr = DevAddr;
licio.mapelli@st.com 33:1573db91352c 209 writeSYS_CTRL (SOFT_RESET);
licio.mapelli@st.com 33:1573db91352c 210
gallonm 23:dfb5ccc7b780 211 GPDR0_15 = (uint16_t)0; // gpio dir all IN
licio.mapelli@st.com 33:1573db91352c 212 write16bitReg (GPDR_0_7, &GPDR0_15);
gallonm 23:dfb5ccc7b780 213 GPSR0_15 = (uint16_t)0x0ffff; // gpio status all 1
licio.mapelli@st.com 33:1573db91352c 214 write16bitReg (GPSR_0_7, &GPSR0_15);
gallonm 23:dfb5ccc7b780 215 }
licio.mapelli@st.com 33:1573db91352c 216
mapellil 36:f6278b3e7c82 217 /**
mapellil 36:f6278b3e7c82 218 * @brief Write the SYS_CTRL register
mapellil 36:f6278b3e7c82 219 * @param[in] Data to be written (bit fields)
mapellil 36:f6278b3e7c82 220 */
licio.mapelli@st.com 33:1573db91352c 221 void writeSYS_CTRL (uint8_t data) // data = SOFT_RESET reset the device
gallonm 23:dfb5ccc7b780 222 {
licio.mapelli@st.com 33:1573db91352c 223 dev_i2c.i2c_write((uint8_t*)SYS_CTRL, expdevaddr, data, 1);
gallonm 23:dfb5ccc7b780 224 }
mapellil 36:f6278b3e7c82 225
mapellil 36:f6278b3e7c82 226 /**
mapellil 36:f6278b3e7c82 227 * @brief Set the out pin
mapellil 36:f6278b3e7c82 228 * @param[in] The pin name
mapellil 36:f6278b3e7c82 229 * @return 0 on Success
mapellil 36:f6278b3e7c82 230 */
mapellil 36:f6278b3e7c82 231 bool setGPIO (ExpGpioPinName PinName)
mapellil 36:f6278b3e7c82 232 {
mapellil 36:f6278b3e7c82 233 if (PinName == NOT_CON) return true;
mapellil 36:f6278b3e7c82 234 GPSR0_15 = GPSR0_15 | ((uint16_t)0x0001<<PinName);
mapellil 36:f6278b3e7c82 235 write16bitReg (GPSR_0_7 , &GPSR0_15);
mapellil 36:f6278b3e7c82 236 return false;
mapellil 36:f6278b3e7c82 237 }
mapellil 36:f6278b3e7c82 238
mapellil 36:f6278b3e7c82 239 /**
mapellil 36:f6278b3e7c82 240 * @brief Clear the out pin
mapellil 36:f6278b3e7c82 241 * @param[in] The pin name
mapellil 36:f6278b3e7c82 242 * @return 0 on Success
mapellil 36:f6278b3e7c82 243 */
mapellil 36:f6278b3e7c82 244 bool clrGPIO (ExpGpioPinName PinName)
mapellil 36:f6278b3e7c82 245 {
mapellil 36:f6278b3e7c82 246 if (PinName == NOT_CON) return true;
mapellil 36:f6278b3e7c82 247 GPSR0_15 = GPSR0_15 & (~((uint16_t)0x0001<<PinName));
mapellil 36:f6278b3e7c82 248 write16bitReg (GPSR_0_7 , &GPSR0_15);
mapellil 36:f6278b3e7c82 249 return false;
mapellil 36:f6278b3e7c82 250 }
mapellil 36:f6278b3e7c82 251
mapellil 36:f6278b3e7c82 252 /**
mapellil 36:f6278b3e7c82 253 * @brief Read the input pin
mapellil 36:f6278b3e7c82 254 * @param[in] The pin name
mapellil 36:f6278b3e7c82 255 * @return The logical pin level
mapellil 36:f6278b3e7c82 256 */
mapellil 36:f6278b3e7c82 257 bool rdGPIO (ExpGpioPinName PinName)
mapellil 36:f6278b3e7c82 258 {
mapellil 36:f6278b3e7c82 259 uint16_t gpmr0_15;
mapellil 36:f6278b3e7c82 260 if (PinName == NOT_CON) return true;
mapellil 36:f6278b3e7c82 261 read16bitReg (GPMR_0_7, &gpmr0_15);
mapellil 36:f6278b3e7c82 262 gpmr0_15 = gpmr0_15 & ((uint16_t)0x0001<<PinName);
mapellil 36:f6278b3e7c82 263 if (gpmr0_15) return true;
mapellil 36:f6278b3e7c82 264 return false;
mapellil 36:f6278b3e7c82 265 }
mapellil 36:f6278b3e7c82 266
mapellil 36:f6278b3e7c82 267 /**
mapellil 36:f6278b3e7c82 268 * @brief Set the pin direction
mapellil 36:f6278b3e7c82 269 * @param[in] The pin name
mapellil 36:f6278b3e7c82 270 * @param[in] The pin direction
mapellil 36:f6278b3e7c82 271 * @return 0 on success
mapellil 36:f6278b3e7c82 272 */
mapellil 36:f6278b3e7c82 273 bool setGPIOdir (ExpGpioPinName PinName, ExpGpioPinDirection PinDir)
mapellil 36:f6278b3e7c82 274 {
mapellil 36:f6278b3e7c82 275 if (PinName == NOT_CON || PinDir == NOT_CONNECTED) return true;
mapellil 36:f6278b3e7c82 276 GPDR0_15 = GPDR0_15 & (~((uint16_t)0x0001<<PinName)); // clear the Pin
mapellil 36:f6278b3e7c82 277 GPDR0_15 = GPDR0_15 | ((uint16_t)PinDir<<PinName);
mapellil 36:f6278b3e7c82 278 write16bitReg (GPDR_0_7 , &GPDR0_15);
mapellil 36:f6278b3e7c82 279 return false;
mapellil 36:f6278b3e7c82 280 }
licio.mapelli@st.com 33:1573db91352c 281
mapellil 36:f6278b3e7c82 282 /**
mapellil 36:f6278b3e7c82 283 * @brief Read a 16 bits register
mapellil 36:f6278b3e7c82 284 * @param[in] The register address
mapellil 36:f6278b3e7c82 285 * @param[in] The pointer to the read data
mapellil 36:f6278b3e7c82 286 */
licio.mapelli@st.com 33:1573db91352c 287 void read16bitReg (uint8_t Reg16Addr, uint16_t *Reg16Data)
licio.mapelli@st.com 33:1573db91352c 288 {
licio.mapelli@st.com 33:1573db91352c 289 dev_i2c.i2c_read((uint8_t*)Reg16Data, expdevaddr, Reg16Addr, 2);
licio.mapelli@st.com 33:1573db91352c 290 }
mapellil 36:f6278b3e7c82 291
mapellil 36:f6278b3e7c82 292 /**
mapellil 36:f6278b3e7c82 293 * @brief Write a 16 bits register
mapellil 36:f6278b3e7c82 294 * @param[in] The register address
mapellil 36:f6278b3e7c82 295 * @param[in] The pointer to the data to be written
mapellil 36:f6278b3e7c82 296 */
licio.mapelli@st.com 33:1573db91352c 297 void write16bitReg (uint8_t Reg16Addr, uint16_t *Reg16Data)
licio.mapelli@st.com 33:1573db91352c 298 {
licio.mapelli@st.com 33:1573db91352c 299 dev_i2c.i2c_write((uint8_t*)Reg16Data, expdevaddr, Reg16Addr, 2);
licio.mapelli@st.com 33:1573db91352c 300 }
licio.mapelli@st.com 33:1573db91352c 301
licio.mapelli@st.com 33:1573db91352c 302 private:
gallonm 23:dfb5ccc7b780 303 DevI2C &dev_i2c;
licio.mapelli@st.com 33:1573db91352c 304 uint16_t GPDR0_15; // local copy of bit direction reg
licio.mapelli@st.com 33:1573db91352c 305 uint16_t GPSR0_15; // local copy of bit status reg
licio.mapelli@st.com 33:1573db91352c 306 uint8_t expdevaddr; // expander device i2c addr
gallonm 23:dfb5ccc7b780 307 };
licio.mapelli@st.com 33:1573db91352c 308
gallonm 7:2dc81120c917 309 #endif // __STMPE1600_CLASS