Library for MAX7300 GPIO Expander
max7300.h@7:e75913818f75, 2016-05-12 (annotated)
- Committer:
- j3
- Date:
- Thu May 12 23:35:32 2016 +0000
- Revision:
- 7:e75913818f75
- Parent:
- 2:fd2de5d21702
updated docs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 0:350a850a7191 | 1 | /******************************************************************//** |
j3 | 0:350a850a7191 | 2 | * @file max7300.h |
j3 | 0:350a850a7191 | 3 | * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved. |
j3 | 0:350a850a7191 | 4 | * |
j3 | 0:350a850a7191 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
j3 | 0:350a850a7191 | 6 | * copy of this software and associated documentation files (the "Software"), |
j3 | 0:350a850a7191 | 7 | * to deal in the Software without restriction, including without limitation |
j3 | 0:350a850a7191 | 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
j3 | 0:350a850a7191 | 9 | * and/or sell copies of the Software, and to permit persons to whom the |
j3 | 0:350a850a7191 | 10 | * Software is furnished to do so, subject to the following conditions: |
j3 | 0:350a850a7191 | 11 | * |
j3 | 0:350a850a7191 | 12 | * The above copyright notice and this permission notice shall be included |
j3 | 0:350a850a7191 | 13 | * in all copies or substantial portions of the Software. |
j3 | 0:350a850a7191 | 14 | * |
j3 | 0:350a850a7191 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
j3 | 0:350a850a7191 | 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
j3 | 0:350a850a7191 | 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
j3 | 0:350a850a7191 | 18 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
j3 | 0:350a850a7191 | 19 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
j3 | 0:350a850a7191 | 20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
j3 | 0:350a850a7191 | 21 | * OTHER DEALINGS IN THE SOFTWARE. |
j3 | 0:350a850a7191 | 22 | * |
j3 | 0:350a850a7191 | 23 | * Except as contained in this notice, the name of Maxim Integrated |
j3 | 0:350a850a7191 | 24 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
j3 | 0:350a850a7191 | 25 | * Products, Inc. Branding Policy. |
j3 | 0:350a850a7191 | 26 | * |
j3 | 0:350a850a7191 | 27 | * The mere transfer of this software does not imply any licenses |
j3 | 0:350a850a7191 | 28 | * of trade secrets, proprietary technology, copyrights, patents, |
j3 | 0:350a850a7191 | 29 | * trademarks, maskwork rights, or any other form of intellectual |
j3 | 0:350a850a7191 | 30 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
j3 | 0:350a850a7191 | 31 | * ownership rights. |
j3 | 0:350a850a7191 | 32 | **********************************************************************/ |
j3 | 0:350a850a7191 | 33 | |
j3 | 0:350a850a7191 | 34 | |
j3 | 0:350a850a7191 | 35 | #ifndef MAX7300_H |
j3 | 0:350a850a7191 | 36 | #define MAX7300_H |
j3 | 0:350a850a7191 | 37 | |
j3 | 0:350a850a7191 | 38 | #include "mbed.h" |
j3 | 0:350a850a7191 | 39 | |
j3 | 0:350a850a7191 | 40 | |
j3 | 7:e75913818f75 | 41 | /** |
j3 | 7:e75913818f75 | 42 | * @brief 2-Wire-Interfaced, 2.5V to 5.5V, 20-Port or 28-Port I/O |
j3 | 7:e75913818f75 | 43 | * Expander |
j3 | 7:e75913818f75 | 44 | * |
j3 | 7:e75913818f75 | 45 | * @details The MAX7300 compact, serial-interfaced, I/O expansion |
j3 | 7:e75913818f75 | 46 | * peripheral provides microprocessors with up to 28 ports. Each port |
j3 | 7:e75913818f75 | 47 | * is individually user configurable to either a logic input or logic |
j3 | 7:e75913818f75 | 48 | * output. |
j3 | 7:e75913818f75 | 49 | * @code |
j3 | 7:e75913818f75 | 50 | * #include "mbed.h" |
j3 | 7:e75913818f75 | 51 | * #include "max7300.h" |
j3 | 7:e75913818f75 | 52 | * |
j3 | 7:e75913818f75 | 53 | * int main (void) |
j3 | 7:e75913818f75 | 54 | * { |
j3 | 7:e75913818f75 | 55 | * I2C i2c_bus(D14, D15); |
j3 | 7:e75913818f75 | 56 | * |
j3 | 7:e75913818f75 | 57 | * Max7300 io_expander(&i2c_bus, Max7300::MAX7300_I2C_ADRS0); |
j3 | 7:e75913818f75 | 58 | * |
j3 | 7:e75913818f75 | 59 | * for(uint8_t idx = 0; idx < 10; idx++) |
j3 | 7:e75913818f75 | 60 | * { |
j3 | 7:e75913818f75 | 61 | * //configure ports 12 - 21 as outputs |
j3 | 7:e75913818f75 | 62 | * io_expander.config_port((Max7300::max7300_port_number_t) (idx+12), Max7300::MAX7300_PORT_OUTPUT); |
j3 | 7:e75913818f75 | 63 | * |
j3 | 7:e75913818f75 | 64 | * //configure ports 22 - 31 as inputs |
j3 | 7:e75913818f75 | 65 | * io_expander.config_port((Max7300::max7300_port_number_t) (idx+22), Max7300::MAX7300_PORT_INPUT); |
j3 | 7:e75913818f75 | 66 | * } |
j3 | 7:e75913818f75 | 67 | * |
j3 | 7:e75913818f75 | 68 | * io_expander.enable_ports(); |
j3 | 7:e75913818f75 | 69 | * |
j3 | 7:e75913818f75 | 70 | * //rest of application... |
j3 | 7:e75913818f75 | 71 | * } |
j3 | 7:e75913818f75 | 72 | * @endcode |
j3 | 7:e75913818f75 | 73 | */ |
j3 | 0:350a850a7191 | 74 | class Max7300 |
j3 | 0:350a850a7191 | 75 | { |
j3 | 0:350a850a7191 | 76 | public: |
j3 | 0:350a850a7191 | 77 | |
j3 | 7:e75913818f75 | 78 | /** |
j3 | 7:e75913818f75 | 79 | * @brief Valid 7-bit I2C addresses |
j3 | 7:e75913818f75 | 80 | * @details 16 valid I2C addresses are possible through the |
j3 | 7:e75913818f75 | 81 | * connection od AD0 and AD1 to Vcc, GND, SDA, or SCL. |
j3 | 7:e75913818f75 | 82 | */ |
j3 | 0:350a850a7191 | 83 | typedef enum |
j3 | 0:350a850a7191 | 84 | { |
j3 | 0:350a850a7191 | 85 | MAX7300_I2C_ADRS0 = 0x40, |
j3 | 0:350a850a7191 | 86 | MAX7300_I2C_ADRS1, |
j3 | 0:350a850a7191 | 87 | MAX7300_I2C_ADRS2, |
j3 | 0:350a850a7191 | 88 | MAX7300_I2C_ADRS3, |
j3 | 0:350a850a7191 | 89 | MAX7300_I2C_ADRS4, |
j3 | 0:350a850a7191 | 90 | MAX7300_I2C_ADRS5, |
j3 | 0:350a850a7191 | 91 | MAX7300_I2C_ADRS6, |
j3 | 0:350a850a7191 | 92 | MAX7300_I2C_ADRS7, |
j3 | 0:350a850a7191 | 93 | MAX7300_I2C_ADRS8, |
j3 | 0:350a850a7191 | 94 | MAX7300_I2C_ADRS9, |
j3 | 0:350a850a7191 | 95 | MAX7300_I2C_ADRS10, |
j3 | 0:350a850a7191 | 96 | MAX7300_I2C_ADRS11, |
j3 | 0:350a850a7191 | 97 | MAX7300_I2C_ADRS12, |
j3 | 0:350a850a7191 | 98 | MAX7300_I2C_ADRS13, |
j3 | 0:350a850a7191 | 99 | MAX7300_I2C_ADRS14, |
j3 | 0:350a850a7191 | 100 | MAX7300_I2C_ADRS15 |
j3 | 0:350a850a7191 | 101 | }max7300_i2c_adrs_t; |
j3 | 0:350a850a7191 | 102 | |
j3 | 0:350a850a7191 | 103 | |
j3 | 7:e75913818f75 | 104 | /** |
j3 | 7:e75913818f75 | 105 | * @brief Valid port configurations |
j3 | 7:e75913818f75 | 106 | * @details Valid port configurations for the MAX7300 are; |
j3 | 7:e75913818f75 | 107 | * push-pull GPO, schmitt GPI, schmitt GPI with pull-up. |
j3 | 7:e75913818f75 | 108 | */ |
j3 | 0:350a850a7191 | 109 | typedef enum |
j3 | 0:350a850a7191 | 110 | { |
j3 | 0:350a850a7191 | 111 | MAX7300_PORT_OUTPUT = 1, |
j3 | 0:350a850a7191 | 112 | MAX7300_PORT_INPUT, |
j3 | 0:350a850a7191 | 113 | MAX7300_PORT_INPUT_PULLUP |
j3 | 0:350a850a7191 | 114 | }max7300_port_type_t; |
j3 | 0:350a850a7191 | 115 | |
j3 | 0:350a850a7191 | 116 | |
j3 | 7:e75913818f75 | 117 | /** |
j3 | 7:e75913818f75 | 118 | * @brief Valid port numbers |
j3 | 7:e75913818f75 | 119 | * @details Simple enumeration of port numbers |
j3 | 7:e75913818f75 | 120 | */ |
j3 | 0:350a850a7191 | 121 | typedef enum |
j3 | 0:350a850a7191 | 122 | { |
j3 | 0:350a850a7191 | 123 | MAX7300_PORT_04 = 4, |
j3 | 0:350a850a7191 | 124 | MAX7300_PORT_05, |
j3 | 0:350a850a7191 | 125 | MAX7300_PORT_06, |
j3 | 0:350a850a7191 | 126 | MAX7300_PORT_07, |
j3 | 0:350a850a7191 | 127 | MAX7300_PORT_08, |
j3 | 0:350a850a7191 | 128 | MAX7300_PORT_09, |
j3 | 0:350a850a7191 | 129 | MAX7300_PORT_10, |
j3 | 0:350a850a7191 | 130 | MAX7300_PORT_11, |
j3 | 0:350a850a7191 | 131 | MAX7300_PORT_12, |
j3 | 0:350a850a7191 | 132 | MAX7300_PORT_13, |
j3 | 0:350a850a7191 | 133 | MAX7300_PORT_14, |
j3 | 0:350a850a7191 | 134 | MAX7300_PORT_15, |
j3 | 0:350a850a7191 | 135 | MAX7300_PORT_16, |
j3 | 0:350a850a7191 | 136 | MAX7300_PORT_17, |
j3 | 0:350a850a7191 | 137 | MAX7300_PORT_18, |
j3 | 0:350a850a7191 | 138 | MAX7300_PORT_19, |
j3 | 0:350a850a7191 | 139 | MAX7300_PORT_20, |
j3 | 0:350a850a7191 | 140 | MAX7300_PORT_21, |
j3 | 0:350a850a7191 | 141 | MAX7300_PORT_22, |
j3 | 0:350a850a7191 | 142 | MAX7300_PORT_23, |
j3 | 0:350a850a7191 | 143 | MAX7300_PORT_24, |
j3 | 0:350a850a7191 | 144 | MAX7300_PORT_25, |
j3 | 0:350a850a7191 | 145 | MAX7300_PORT_26, |
j3 | 0:350a850a7191 | 146 | MAX7300_PORT_27, |
j3 | 0:350a850a7191 | 147 | MAX7300_PORT_28, |
j3 | 0:350a850a7191 | 148 | MAX7300_PORT_29, |
j3 | 0:350a850a7191 | 149 | MAX7300_PORT_30, |
j3 | 0:350a850a7191 | 150 | MAX7300_PORT_31 |
j3 | 0:350a850a7191 | 151 | }max7300_port_number_t; |
j3 | 0:350a850a7191 | 152 | |
j3 | 0:350a850a7191 | 153 | |
j3 | 0:350a850a7191 | 154 | /**********************************************************//** |
j3 | 0:350a850a7191 | 155 | * @brief Constructor for Max7300 Class. |
j3 | 0:350a850a7191 | 156 | * |
j3 | 0:350a850a7191 | 157 | * @details Allows user to use existing I2C object |
j3 | 0:350a850a7191 | 158 | * |
j3 | 0:350a850a7191 | 159 | * On Entry: |
j3 | 0:350a850a7191 | 160 | * @param[in] i2c_bus - pointer to existing I2C object |
j3 | 0:350a850a7191 | 161 | * @param[in] i2c_adrs - 7-bit slave address of MAX7300 |
j3 | 0:350a850a7191 | 162 | * |
j3 | 0:350a850a7191 | 163 | * On Exit: |
j3 | 7:e75913818f75 | 164 | * |
j3 | 7:e75913818f75 | 165 | * @return None |
j3 | 0:350a850a7191 | 166 | **************************************************************/ |
j3 | 0:350a850a7191 | 167 | Max7300(I2C *i2c_bus, max7300_i2c_adrs_t i2c_adrs); |
j3 | 0:350a850a7191 | 168 | |
j3 | 0:350a850a7191 | 169 | |
j3 | 0:350a850a7191 | 170 | /**********************************************************//** |
j3 | 0:350a850a7191 | 171 | * @brief Constructor for Max7300 Class. |
j3 | 0:350a850a7191 | 172 | * |
j3 | 0:350a850a7191 | 173 | * @details Allows user to create a new I2C object if not |
j3 | 0:350a850a7191 | 174 | * already using one |
j3 | 0:350a850a7191 | 175 | * |
j3 | 0:350a850a7191 | 176 | * On Entry: |
j3 | 0:350a850a7191 | 177 | * @param[in] sda - sda pin of I2C bus |
j3 | 0:350a850a7191 | 178 | * @param[in] scl - scl pin of I2C bus |
j3 | 0:350a850a7191 | 179 | * @param[in] i2c_adrs - 7-bit slave address of MAX7300 |
j3 | 0:350a850a7191 | 180 | * |
j3 | 0:350a850a7191 | 181 | * On Exit: |
j3 | 7:e75913818f75 | 182 | * |
j3 | 7:e75913818f75 | 183 | * @return None |
j3 | 0:350a850a7191 | 184 | **************************************************************/ |
j3 | 0:350a850a7191 | 185 | Max7300(PinName sda, PinName scl, max7300_i2c_adrs_t i2c_adrs); |
j3 | 0:350a850a7191 | 186 | |
j3 | 0:350a850a7191 | 187 | |
j3 | 0:350a850a7191 | 188 | /**********************************************************//** |
j3 | 0:350a850a7191 | 189 | * @brief Default destructor for Max7300 Class. |
j3 | 0:350a850a7191 | 190 | * |
j3 | 0:350a850a7191 | 191 | * @details Destroys I2C object if owner |
j3 | 0:350a850a7191 | 192 | * |
j3 | 0:350a850a7191 | 193 | * On Entry: |
j3 | 0:350a850a7191 | 194 | * |
j3 | 0:350a850a7191 | 195 | * On Exit: |
j3 | 7:e75913818f75 | 196 | * |
j3 | 7:e75913818f75 | 197 | * @return None |
j3 | 0:350a850a7191 | 198 | **************************************************************/ |
j3 | 0:350a850a7191 | 199 | ~Max7300(); |
j3 | 0:350a850a7191 | 200 | |
j3 | 0:350a850a7191 | 201 | |
j3 | 0:350a850a7191 | 202 | /**********************************************************//** |
j3 | 0:350a850a7191 | 203 | * @brief Enables MAX7300 GPIO Ports |
j3 | 0:350a850a7191 | 204 | * |
j3 | 0:350a850a7191 | 205 | * @details Sets 'S' bit of configuration register |
j3 | 0:350a850a7191 | 206 | * |
j3 | 0:350a850a7191 | 207 | * On Entry: |
j3 | 0:350a850a7191 | 208 | * |
j3 | 0:350a850a7191 | 209 | * On Exit: |
j3 | 7:e75913818f75 | 210 | * |
j3 | 7:e75913818f75 | 211 | * @return 0 on success, non-0 on failure |
j3 | 0:350a850a7191 | 212 | **************************************************************/ |
j3 | 0:350a850a7191 | 213 | int16_t enable_ports(void); |
j3 | 0:350a850a7191 | 214 | |
j3 | 0:350a850a7191 | 215 | |
j3 | 0:350a850a7191 | 216 | /**********************************************************//** |
j3 | 0:350a850a7191 | 217 | * @brief Disables MAX7300 GPIO Ports |
j3 | 0:350a850a7191 | 218 | * |
j3 | 0:350a850a7191 | 219 | * @details Clears 'S' bit of configuration register |
j3 | 0:350a850a7191 | 220 | * |
j3 | 0:350a850a7191 | 221 | * On Entry: |
j3 | 0:350a850a7191 | 222 | * |
j3 | 0:350a850a7191 | 223 | * On Exit: |
j3 | 7:e75913818f75 | 224 | * |
j3 | 7:e75913818f75 | 225 | * @return 0 on success, non-0 on failure |
j3 | 0:350a850a7191 | 226 | **************************************************************/ |
j3 | 0:350a850a7191 | 227 | int16_t disable_ports(void); |
j3 | 0:350a850a7191 | 228 | |
j3 | 0:350a850a7191 | 229 | |
j3 | 0:350a850a7191 | 230 | /**********************************************************//** |
j3 | 1:e1ee2549a047 | 231 | * @brief Enables Transition Detection |
j3 | 1:e1ee2549a047 | 232 | * |
j3 | 1:e1ee2549a047 | 233 | * @details Sets 'M' bit of configuration register |
j3 | 1:e1ee2549a047 | 234 | * |
j3 | 1:e1ee2549a047 | 235 | * On Entry: |
j3 | 1:e1ee2549a047 | 236 | * |
j3 | 1:e1ee2549a047 | 237 | * On Exit: |
j3 | 7:e75913818f75 | 238 | * |
j3 | 7:e75913818f75 | 239 | * @return 0 on success, non-0 on failure |
j3 | 1:e1ee2549a047 | 240 | **************************************************************/ |
j3 | 1:e1ee2549a047 | 241 | int16_t enable_transition_detection(void); |
j3 | 1:e1ee2549a047 | 242 | |
j3 | 1:e1ee2549a047 | 243 | |
j3 | 1:e1ee2549a047 | 244 | /**********************************************************//** |
j3 | 1:e1ee2549a047 | 245 | * @brief Disables Transition Detection |
j3 | 1:e1ee2549a047 | 246 | * |
j3 | 1:e1ee2549a047 | 247 | * @details Clears 'M' bit of configuration register |
j3 | 1:e1ee2549a047 | 248 | * |
j3 | 1:e1ee2549a047 | 249 | * On Entry: |
j3 | 1:e1ee2549a047 | 250 | * |
j3 | 1:e1ee2549a047 | 251 | * On Exit: |
j3 | 7:e75913818f75 | 252 | * |
j3 | 7:e75913818f75 | 253 | * @return 0 on success, non-0 on failure |
j3 | 1:e1ee2549a047 | 254 | **************************************************************/ |
j3 | 1:e1ee2549a047 | 255 | int16_t disable_transition_detection(void); |
j3 | 1:e1ee2549a047 | 256 | |
j3 | 1:e1ee2549a047 | 257 | |
j3 | 1:e1ee2549a047 | 258 | /**********************************************************//** |
j3 | 0:350a850a7191 | 259 | * @brief Configures a single MAX7300 GPIO port |
j3 | 0:350a850a7191 | 260 | * |
j3 | 0:350a850a7191 | 261 | * @details Configures MAX7300 GPIO port as either an output, |
j3 | 0:350a850a7191 | 262 | * input, or input with pullup. |
j3 | 0:350a850a7191 | 263 | * |
j3 | 0:350a850a7191 | 264 | * On Entry: |
j3 | 0:350a850a7191 | 265 | * @param[in] port_num - GPIO port to configure |
j3 | 0:350a850a7191 | 266 | * @param[in] port_type - One of the following port types |
j3 | 0:350a850a7191 | 267 | * MAX7300_PORT_OUTPUT |
j3 | 0:350a850a7191 | 268 | * MAX7300_PORT_INPUT |
j3 | 0:350a850a7191 | 269 | * MAX7300_PORT_INPUT_PULLUP |
j3 | 0:350a850a7191 | 270 | * |
j3 | 0:350a850a7191 | 271 | * On Exit: |
j3 | 7:e75913818f75 | 272 | * |
j3 | 7:e75913818f75 | 273 | * @return 0 on success, non-0 on failure |
j3 | 0:350a850a7191 | 274 | **************************************************************/ |
j3 | 0:350a850a7191 | 275 | int16_t config_port(max7300_port_number_t port_num, max7300_port_type_t port_type); |
j3 | 0:350a850a7191 | 276 | |
j3 | 0:350a850a7191 | 277 | |
j3 | 0:350a850a7191 | 278 | /**********************************************************//** |
j3 | 0:350a850a7191 | 279 | * @brief Configure 4 MAX7300 GPIO ports |
j3 | 0:350a850a7191 | 280 | * |
j3 | 0:350a850a7191 | 281 | * @details Allows user to configure 4 ports at a time |
j3 | 0:350a850a7191 | 282 | * |
j3 | 0:350a850a7191 | 283 | * On Entry: |
j3 | 1:e1ee2549a047 | 284 | * @param[in] low_port - lowest of 4 ports to configure, |
j3 | 1:e1ee2549a047 | 285 | * on 4 port boundaries as in datasheet |
j3 | 0:350a850a7191 | 286 | * |
j3 | 0:350a850a7191 | 287 | * @param[in] data - Byte with each ports desired type with |
j3 | 0:350a850a7191 | 288 | * the following format - xx|xx|xx|xx |
j3 | 0:350a850a7191 | 289 | * |
j3 | 0:350a850a7191 | 290 | * On Exit: |
j3 | 7:e75913818f75 | 291 | * |
j3 | 7:e75913818f75 | 292 | * @return 0 on success, non-0 on failure |
j3 | 0:350a850a7191 | 293 | **************************************************************/ |
j3 | 1:e1ee2549a047 | 294 | int16_t config_4_ports(max7300_port_number_t low_port, uint8_t data); |
j3 | 1:e1ee2549a047 | 295 | |
j3 | 1:e1ee2549a047 | 296 | |
j3 | 1:e1ee2549a047 | 297 | /**********************************************************//** |
j3 | 1:e1ee2549a047 | 298 | * @brief Configures all MAX7300 GPIO ports |
j3 | 1:e1ee2549a047 | 299 | * |
j3 | 1:e1ee2549a047 | 300 | * @details Allows user to configure all ports to a single type |
j3 | 1:e1ee2549a047 | 301 | * |
j3 | 1:e1ee2549a047 | 302 | * On Entry: |
j3 | 1:e1ee2549a047 | 303 | * @param[in] port_type - One of the following port types |
j3 | 1:e1ee2549a047 | 304 | * MAX7300_PORT_OUTPUT |
j3 | 1:e1ee2549a047 | 305 | * MAX7300_PORT_INPUT |
j3 | 1:e1ee2549a047 | 306 | * MAX7300_PORT_INPUT_PULLUP |
j3 | 1:e1ee2549a047 | 307 | * |
j3 | 1:e1ee2549a047 | 308 | * On Exit: |
j3 | 7:e75913818f75 | 309 | * |
j3 | 7:e75913818f75 | 310 | * @return 0 on success, non-0 on failure |
j3 | 1:e1ee2549a047 | 311 | **************************************************************/ |
j3 | 1:e1ee2549a047 | 312 | int16_t config_all_ports(max7300_port_type_t port_type); |
j3 | 0:350a850a7191 | 313 | |
j3 | 0:350a850a7191 | 314 | |
j3 | 0:350a850a7191 | 315 | /**********************************************************//** |
j3 | 0:350a850a7191 | 316 | * @brief Read a single MAX7300 GPIO port |
j3 | 0:350a850a7191 | 317 | * |
j3 | 0:350a850a7191 | 318 | * @details |
j3 | 0:350a850a7191 | 319 | * |
j3 | 0:350a850a7191 | 320 | * On Entry: |
j3 | 1:e1ee2549a047 | 321 | * @param[in] port_num - MAX7300 port number to read |
j3 | 0:350a850a7191 | 322 | * |
j3 | 0:350a850a7191 | 323 | * On Exit: |
j3 | 7:e75913818f75 | 324 | * |
j3 | 7:e75913818f75 | 325 | * @return State of port, or -1 on failure |
j3 | 0:350a850a7191 | 326 | **************************************************************/ |
j3 | 0:350a850a7191 | 327 | int16_t read_port(max7300_port_number_t port_num); |
j3 | 0:350a850a7191 | 328 | |
j3 | 0:350a850a7191 | 329 | |
j3 | 0:350a850a7191 | 330 | /**********************************************************//** |
j3 | 0:350a850a7191 | 331 | * @brief Write a single MAX7300 GPIO port |
j3 | 0:350a850a7191 | 332 | * |
j3 | 0:350a850a7191 | 333 | * @details |
j3 | 0:350a850a7191 | 334 | * |
j3 | 0:350a850a7191 | 335 | * On Entry: |
j3 | 1:e1ee2549a047 | 336 | * @param[in] port_num - MAX7300 port to write |
j3 | 1:e1ee2549a047 | 337 | * @param[in] data - lsb of byte is written to port |
j3 | 0:350a850a7191 | 338 | * |
j3 | 0:350a850a7191 | 339 | * On Exit: |
j3 | 7:e75913818f75 | 340 | * |
j3 | 7:e75913818f75 | 341 | * @return 0 on success, non-0 on failure |
j3 | 0:350a850a7191 | 342 | **************************************************************/ |
j3 | 0:350a850a7191 | 343 | int16_t write_port(max7300_port_number_t port_num, uint8_t data); |
j3 | 0:350a850a7191 | 344 | |
j3 | 0:350a850a7191 | 345 | |
j3 | 0:350a850a7191 | 346 | /**********************************************************//** |
j3 | 0:350a850a7191 | 347 | * @brief Read 8 MAX7300 GPIO ports |
j3 | 0:350a850a7191 | 348 | * |
j3 | 0:350a850a7191 | 349 | * @details |
j3 | 0:350a850a7191 | 350 | * |
j3 | 0:350a850a7191 | 351 | * On Entry: |
j3 | 1:e1ee2549a047 | 352 | * @param[in] low_port - lowest port of 8 ports to read, |
j3 | 1:e1ee2549a047 | 353 | * on 8 port boundaries as in datasheet. |
j3 | 1:e1ee2549a047 | 354 | * Max is port 24 |
j3 | 0:350a850a7191 | 355 | * |
j3 | 0:350a850a7191 | 356 | * On Exit: |
j3 | 7:e75913818f75 | 357 | * |
j3 | 7:e75913818f75 | 358 | * @return State of ports, or -1 on failure |
j3 | 0:350a850a7191 | 359 | **************************************************************/ |
j3 | 1:e1ee2549a047 | 360 | int16_t read_8_ports(max7300_port_number_t low_port); |
j3 | 0:350a850a7191 | 361 | |
j3 | 0:350a850a7191 | 362 | |
j3 | 0:350a850a7191 | 363 | /**********************************************************//** |
j3 | 0:350a850a7191 | 364 | * @brief Write 8 MAX7300 GPIO ports |
j3 | 0:350a850a7191 | 365 | * |
j3 | 0:350a850a7191 | 366 | * @details |
j3 | 0:350a850a7191 | 367 | * |
j3 | 0:350a850a7191 | 368 | * On Entry: |
j3 | 1:e1ee2549a047 | 369 | * @param[in] low_port - lowest port of 8 ports to write, |
j3 | 1:e1ee2549a047 | 370 | * on 8 port boundaries as in datasheet. |
j3 | 1:e1ee2549a047 | 371 | * Max is port 24 |
j3 | 1:e1ee2549a047 | 372 | * |
j3 | 1:e1ee2549a047 | 373 | * @param[in] data - Data is written to ports |
j3 | 0:350a850a7191 | 374 | * |
j3 | 0:350a850a7191 | 375 | * On Exit: |
j3 | 7:e75913818f75 | 376 | * |
j3 | 7:e75913818f75 | 377 | * @return 0 on success, non-0 on failure |
j3 | 0:350a850a7191 | 378 | **************************************************************/ |
j3 | 1:e1ee2549a047 | 379 | int16_t write_8_ports(max7300_port_number_t low_port, uint8_t data); |
j3 | 1:e1ee2549a047 | 380 | |
j3 | 1:e1ee2549a047 | 381 | |
j3 | 1:e1ee2549a047 | 382 | /**********************************************************//** |
j3 | 1:e1ee2549a047 | 383 | * @brief Read transition detection mask register |
j3 | 1:e1ee2549a047 | 384 | * |
j3 | 1:e1ee2549a047 | 385 | * @details See page 11 of DS, right hand side column, paragraph 2 |
j3 | 1:e1ee2549a047 | 386 | * for details on one-shot event. |
j3 | 1:e1ee2549a047 | 387 | * |
j3 | 1:e1ee2549a047 | 388 | * On Entry: |
j3 | 1:e1ee2549a047 | 389 | * @param[in] enable_snapshot - true to re-enable transition |
j3 | 1:e1ee2549a047 | 390 | * detection |
j3 | 1:e1ee2549a047 | 391 | * |
j3 | 1:e1ee2549a047 | 392 | * On Exit: |
j3 | 7:e75913818f75 | 393 | * |
j3 | 7:e75913818f75 | 394 | * @return 0 on success, non-0 on failure |
j3 | 1:e1ee2549a047 | 395 | **************************************************************/ |
j3 | 1:e1ee2549a047 | 396 | int16_t read_mask_register(bool enable_snapshot); |
j3 | 0:350a850a7191 | 397 | |
j3 | 0:350a850a7191 | 398 | |
j3 | 0:350a850a7191 | 399 | /**********************************************************//** |
j3 | 1:e1ee2549a047 | 400 | * @brief Write transition detection mask register |
j3 | 0:350a850a7191 | 401 | * |
j3 | 1:e1ee2549a047 | 402 | * @details Enables transition detection on Ports 30-24 |
j3 | 1:e1ee2549a047 | 403 | * |
j3 | 0:350a850a7191 | 404 | * |
j3 | 0:350a850a7191 | 405 | * On Entry: |
j3 | 1:e1ee2549a047 | 406 | * @param[in] data - Bits to set |
j3 | 0:350a850a7191 | 407 | * |
j3 | 0:350a850a7191 | 408 | * On Exit: |
j3 | 7:e75913818f75 | 409 | * |
j3 | 7:e75913818f75 | 410 | * @return 0 on success, non-0 on failure |
j3 | 0:350a850a7191 | 411 | **************************************************************/ |
j3 | 1:e1ee2549a047 | 412 | int16_t write_mask_register(uint8_t data); |
j3 | 1:e1ee2549a047 | 413 | |
j3 | 0:350a850a7191 | 414 | |
j3 | 0:350a850a7191 | 415 | private: |
j3 | 0:350a850a7191 | 416 | |
j3 | 0:350a850a7191 | 417 | I2C *_p_i2c; |
j3 | 0:350a850a7191 | 418 | bool _i2c_owner; |
j3 | 0:350a850a7191 | 419 | uint8_t _w_adrs; |
j3 | 0:350a850a7191 | 420 | uint8_t _r_adrs; |
j3 | 1:e1ee2549a047 | 421 | |
j3 | 2:fd2de5d21702 | 422 | int16_t write_config_register(bool set_clear, uint8_t data); |
j3 | 1:e1ee2549a047 | 423 | |
j3 | 0:350a850a7191 | 424 | }; |
j3 | 0:350a850a7191 | 425 | #endif /* MAX7300_H*/ |