Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
xDotBridge/inc/BaseboardIO.h@50:e89647e77fd5, 2017-02-17 (annotated)
- Committer:
- Matt Briggs
- Date:
- Fri Feb 17 11:58:40 2017 -0700
- Revision:
- 50:e89647e77fd5
- Parent:
- 49:18f1354f9e51
- Child:
- 55:79ab0bbc5008
Added retries in ds2408 lib and started updating main to make static wireless bridge
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Matt Briggs | 40:2ec4be320961 | 1 | /* |
Matt Briggs | 40:2ec4be320961 | 2 | * baseboardIO.h |
Matt Briggs | 40:2ec4be320961 | 3 | * |
Matt Briggs | 40:2ec4be320961 | 4 | * Created on: Jan 25, 2017 |
Matt Briggs | 40:2ec4be320961 | 5 | * Author: mbriggs |
Matt Briggs | 40:2ec4be320961 | 6 | */ |
Matt Briggs | 40:2ec4be320961 | 7 | #include "DS2408.h" |
Matt Briggs | 40:2ec4be320961 | 8 | |
Matt Briggs | 40:2ec4be320961 | 9 | #ifndef BASEBOARDIO_H_ |
Matt Briggs | 40:2ec4be320961 | 10 | #define BASEBOARDIO_H_ |
Matt Briggs | 40:2ec4be320961 | 11 | |
Matt Briggs | 40:2ec4be320961 | 12 | /** |
Matt Briggs | 40:2ec4be320961 | 13 | * @class BaseboardIO |
Matt Briggs | 40:2ec4be320961 | 14 | * @brief This class abstracts utilizing the IO mostly found on the baseboard |
Matt Briggs | 40:2ec4be320961 | 15 | * this includes IO which is implemented via portExpanders. This API currently |
Matt Briggs | 40:2ec4be320961 | 16 | * does not implement interfaces for communications like UART or for memory like |
Matt Briggs | 40:2ec4be320961 | 17 | * flash devices. |
Matt Briggs | 40:2ec4be320961 | 18 | */ |
Matt Briggs | 40:2ec4be320961 | 19 | class BaseboardIO |
Matt Briggs | 40:2ec4be320961 | 20 | { |
Matt Briggs | 40:2ec4be320961 | 21 | public: |
Matt Briggs | 40:2ec4be320961 | 22 | /** |
Matt Briggs | 40:2ec4be320961 | 23 | * @brief BaseboardIO constructor |
Matt Briggs | 40:2ec4be320961 | 24 | * |
Matt Briggs | 40:2ec4be320961 | 25 | * @details Just initialized internal variables does not configure devices. |
Matt Briggs | 40:2ec4be320961 | 26 | * Should call init before other functions are called. |
Matt Briggs | 40:2ec4be320961 | 27 | * |
Matt Briggs | 40:2ec4be320961 | 28 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 29 | * |
Matt Briggs | 40:2ec4be320961 | 30 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 31 | * Internal variables are set to a known state but futher initialziation is required |
Matt Briggs | 40:2ec4be320961 | 32 | * |
Matt Briggs | 40:2ec4be320961 | 33 | * @return |
Matt Briggs | 40:2ec4be320961 | 34 | */ |
Matt Briggs | 40:2ec4be320961 | 35 | BaseboardIO(); |
Matt Briggs | 40:2ec4be320961 | 36 | |
Matt Briggs | 40:2ec4be320961 | 37 | /** |
Matt Briggs | 40:2ec4be320961 | 38 | * @brief Initialize IO to current values |
Matt Briggs | 40:2ec4be320961 | 39 | * |
Matt Briggs | 40:2ec4be320961 | 40 | * @details Initialize IO to current state and ensure that class variables |
Matt Briggs | 40:2ec4be320961 | 41 | * are updated to latest values. The following are initialized. |
Matt Briggs | 40:2ec4be320961 | 42 | * 1. PortExpanders are setup are read |
Matt Briggs | 40:2ec4be320961 | 43 | * 2. Relay is forced to known state |
Matt Briggs | 40:2ec4be320961 | 44 | * 3. Interrupts are setup |
Matt Briggs | 40:2ec4be320961 | 45 | * |
Matt Briggs | 40:2ec4be320961 | 46 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 47 | * |
Matt Briggs | 40:2ec4be320961 | 48 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 49 | * Either IO is configured or an error is returned |
Matt Briggs | 40:2ec4be320961 | 50 | * |
Matt Briggs | 40:2ec4be320961 | 51 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 52 | */ |
Matt Briggs | 40:2ec4be320961 | 53 | CmdResult init(); |
Matt Briggs | 40:2ec4be320961 | 54 | |
Matt Briggs | 40:2ec4be320961 | 55 | //////////////////////////////// |
Matt Briggs | 40:2ec4be320961 | 56 | // Registering for interrupts // |
Matt Briggs | 40:2ec4be320961 | 57 | //////////////////////////////// |
Matt Briggs | 40:2ec4be320961 | 58 | /** |
Matt Briggs | 40:2ec4be320961 | 59 | * @brief Register for contact closure interrupt |
Matt Briggs | 40:2ec4be320961 | 60 | * |
Matt Briggs | 40:2ec4be320961 | 61 | * @details Pass function pointer which will be called when interrupt occurs. |
Matt Briggs | 40:2ec4be320961 | 62 | * |
Matt Briggs | 40:2ec4be320961 | 63 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 64 | * |
Matt Briggs | 40:2ec4be320961 | 65 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 66 | * Callback registered |
Matt Briggs | 40:2ec4be320961 | 67 | * |
Matt Briggs | 40:2ec4be320961 | 68 | * @return |
Matt Briggs | 40:2ec4be320961 | 69 | */ |
Matt Briggs | 44:ece6330e9b57 | 70 | void regCCInInt(Callback<void()> func); |
Matt Briggs | 40:2ec4be320961 | 71 | |
Matt Briggs | 40:2ec4be320961 | 72 | /** |
Matt Briggs | 40:2ec4be320961 | 73 | * @brief Register for tamper interrupt |
Matt Briggs | 40:2ec4be320961 | 74 | * |
Matt Briggs | 40:2ec4be320961 | 75 | * @details Pass function pointer which will be called when interrupt occurs. |
Matt Briggs | 40:2ec4be320961 | 76 | * |
Matt Briggs | 40:2ec4be320961 | 77 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 78 | * |
Matt Briggs | 40:2ec4be320961 | 79 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 80 | * Callback registered |
Matt Briggs | 40:2ec4be320961 | 81 | * |
Matt Briggs | 40:2ec4be320961 | 82 | * @return |
Matt Briggs | 40:2ec4be320961 | 83 | */ |
Matt Briggs | 44:ece6330e9b57 | 84 | void regTamperInt(Callback<void()> func); |
Matt Briggs | 40:2ec4be320961 | 85 | |
Matt Briggs | 40:2ec4be320961 | 86 | /** |
Matt Briggs | 40:2ec4be320961 | 87 | * @brief Register for pair button interrupt |
Matt Briggs | 40:2ec4be320961 | 88 | * |
Matt Briggs | 40:2ec4be320961 | 89 | * @details Pass function pointer which will be called when interrupt occurs. Note |
Matt Briggs | 40:2ec4be320961 | 90 | * there is a hardware switch which can prevent the tamper sensor from pulling the line |
Matt Briggs | 40:2ec4be320961 | 91 | * down. If this switch deasserted there is no way in software to reconfigure this. |
Matt Briggs | 40:2ec4be320961 | 92 | * |
Matt Briggs | 40:2ec4be320961 | 93 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 94 | * |
Matt Briggs | 40:2ec4be320961 | 95 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 96 | * Callback registered |
Matt Briggs | 40:2ec4be320961 | 97 | * |
Matt Briggs | 40:2ec4be320961 | 98 | * @return |
Matt Briggs | 40:2ec4be320961 | 99 | */ |
Matt Briggs | 44:ece6330e9b57 | 100 | void regPairBtnInt(Callback<void()> func); |
Matt Briggs | 40:2ec4be320961 | 101 | |
Matt Briggs | 40:2ec4be320961 | 102 | /////////// |
Matt Briggs | 40:2ec4be320961 | 103 | // Input // |
Matt Briggs | 40:2ec4be320961 | 104 | /////////// |
Matt Briggs | 40:2ec4be320961 | 105 | /** |
Matt Briggs | 40:2ec4be320961 | 106 | * @brief samples current IO including port expanders |
Matt Briggs | 40:2ec4be320961 | 107 | * |
Matt Briggs | 40:2ec4be320961 | 108 | * @details Samples values and stores them so that IO accessors can execute quicker. |
Matt Briggs | 40:2ec4be320961 | 109 | * |
Matt Briggs | 40:2ec4be320961 | 110 | * Future: |
Matt Briggs | 40:2ec4be320961 | 111 | * Add some detail about how robust the values displayed here are. |
Matt Briggs | 40:2ec4be320961 | 112 | * It might be a good idea to add a timestamp for this IO |
Matt Briggs | 40:2ec4be320961 | 113 | * |
Matt Briggs | 40:2ec4be320961 | 114 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 115 | * |
Matt Briggs | 40:2ec4be320961 | 116 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 117 | * Internal class variables are updated or error is returned. |
Matt Briggs | 40:2ec4be320961 | 118 | * |
Matt Briggs | 40:2ec4be320961 | 119 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 120 | */ |
Matt Briggs | 40:2ec4be320961 | 121 | CmdResult sampleUserSwitches(); |
Matt Briggs | 40:2ec4be320961 | 122 | |
Matt Briggs | 40:2ec4be320961 | 123 | /** |
Matt Briggs | 40:2ec4be320961 | 124 | * @brief Returns the current state of the pair button |
Matt Briggs | 40:2ec4be320961 | 125 | * |
Matt Briggs | 40:2ec4be320961 | 126 | * @details This just simply uses the last sample of the IO to return a bool. |
Matt Briggs | 40:2ec4be320961 | 127 | * If the button is depressed than true is returned other wise false |
Matt Briggs | 40:2ec4be320961 | 128 | * |
Matt Briggs | 40:2ec4be320961 | 129 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 130 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 131 | * |
Matt Briggs | 40:2ec4be320961 | 132 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 133 | * |
Matt Briggs | 40:2ec4be320961 | 134 | * @return bool |
Matt Briggs | 40:2ec4be320961 | 135 | */ |
Matt Briggs | 40:2ec4be320961 | 136 | bool isPairBtn(); |
Matt Briggs | 40:2ec4be320961 | 137 | |
Matt Briggs | 40:2ec4be320961 | 138 | /** |
Matt Briggs | 40:2ec4be320961 | 139 | * @brief Returns the current state of the NO/NC switch |
Matt Briggs | 40:2ec4be320961 | 140 | * |
Matt Briggs | 40:2ec4be320961 | 141 | * @details This just simply uses the last sample of the IO to return a bool. |
Matt Briggs | 40:2ec4be320961 | 142 | * If the switch is in asserted position that the devices is normally closed (NC) |
Matt Briggs | 40:2ec4be320961 | 143 | * therefore false is returned. Otherwise device is normally open (NO) and therefore |
Matt Briggs | 40:2ec4be320961 | 144 | * returns true. |
Matt Briggs | 40:2ec4be320961 | 145 | * |
Matt Briggs | 40:2ec4be320961 | 146 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 147 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 148 | * |
Matt Briggs | 40:2ec4be320961 | 149 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 150 | * |
Matt Briggs | 40:2ec4be320961 | 151 | * @return bool |
Matt Briggs | 40:2ec4be320961 | 152 | */ |
Matt Briggs | 48:bab9f747d9ed | 153 | bool isCCNO(); |
Matt Briggs | 40:2ec4be320961 | 154 | |
Matt Briggs | 40:2ec4be320961 | 155 | /** |
Matt Briggs | 40:2ec4be320961 | 156 | * @brief Returns the current state of the NO/NC switch |
Matt Briggs | 40:2ec4be320961 | 157 | * |
Matt Briggs | 40:2ec4be320961 | 158 | * @details This just simply uses the last sample of the IO to return a bool. |
Matt Briggs | 40:2ec4be320961 | 159 | * If the switch is in asserted position that the devices is normally closed (NC) |
Matt Briggs | 40:2ec4be320961 | 160 | * therefore true is returned. Otherwise device is normally open (NO) and therefore |
Matt Briggs | 40:2ec4be320961 | 161 | * returns false. |
Matt Briggs | 40:2ec4be320961 | 162 | * |
Matt Briggs | 40:2ec4be320961 | 163 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 164 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 165 | * |
Matt Briggs | 40:2ec4be320961 | 166 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 167 | * |
Matt Briggs | 40:2ec4be320961 | 168 | * @return bool |
Matt Briggs | 40:2ec4be320961 | 169 | */ |
Matt Briggs | 49:18f1354f9e51 | 170 | bool isCCNC() {return !isCCNO();} |
Matt Briggs | 40:2ec4be320961 | 171 | |
Matt Briggs | 40:2ec4be320961 | 172 | /** |
Matt Briggs | 40:2ec4be320961 | 173 | * @brief Returns the current state of the Rx/Tx switch |
Matt Briggs | 40:2ec4be320961 | 174 | * |
Matt Briggs | 40:2ec4be320961 | 175 | * @details This just simply uses the last sample of the IO to return a bool. |
Matt Briggs | 40:2ec4be320961 | 176 | * If the switch is in asserted position that the devices is transmitter (Tx) |
Matt Briggs | 40:2ec4be320961 | 177 | * therefore false is returned. Otherwise device is a receiver(Rx) and therefore |
Matt Briggs | 40:2ec4be320961 | 178 | * returns true. |
Matt Briggs | 40:2ec4be320961 | 179 | * |
Matt Briggs | 40:2ec4be320961 | 180 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 181 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 182 | * |
Matt Briggs | 40:2ec4be320961 | 183 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 184 | * |
Matt Briggs | 40:2ec4be320961 | 185 | * @return bool |
Matt Briggs | 40:2ec4be320961 | 186 | */ |
Matt Briggs | 40:2ec4be320961 | 187 | bool isRx(); |
Matt Briggs | 40:2ec4be320961 | 188 | |
Matt Briggs | 40:2ec4be320961 | 189 | /** |
Matt Briggs | 40:2ec4be320961 | 190 | * @brief Returns the current state of the Rx/Tx switch |
Matt Briggs | 40:2ec4be320961 | 191 | * |
Matt Briggs | 40:2ec4be320961 | 192 | * @details This just simply uses the last sample of the IO to return a bool. |
Matt Briggs | 40:2ec4be320961 | 193 | * If the switch is in asserted position that the devices is transmitter (Tx) |
Matt Briggs | 40:2ec4be320961 | 194 | * therefore true is returned. Otherwise device is a receiver(Rx) and therefore |
Matt Briggs | 40:2ec4be320961 | 195 | * returns false. |
Matt Briggs | 40:2ec4be320961 | 196 | * |
Matt Briggs | 40:2ec4be320961 | 197 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 198 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 199 | * |
Matt Briggs | 40:2ec4be320961 | 200 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 201 | * |
Matt Briggs | 40:2ec4be320961 | 202 | * @return bool |
Matt Briggs | 40:2ec4be320961 | 203 | */ |
Matt Briggs | 40:2ec4be320961 | 204 | bool isTx() {return !isRx();} |
Matt Briggs | 40:2ec4be320961 | 205 | |
Matt Briggs | 40:2ec4be320961 | 206 | /** |
Matt Briggs | 40:2ec4be320961 | 207 | * @brief Returns the current state of the LoRaWAN switch |
Matt Briggs | 40:2ec4be320961 | 208 | * |
Matt Briggs | 40:2ec4be320961 | 209 | * @details This just simply uses the last sample of the IO to return a bool. |
Matt Briggs | 40:2ec4be320961 | 210 | * If the switch is in asserted position that the device is will report via LoRaWAN |
Matt Briggs | 40:2ec4be320961 | 211 | * otherwise the device will use peer-to-peer mode. |
Matt Briggs | 40:2ec4be320961 | 212 | * |
Matt Briggs | 40:2ec4be320961 | 213 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 214 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 215 | * |
Matt Briggs | 40:2ec4be320961 | 216 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 217 | * |
Matt Briggs | 40:2ec4be320961 | 218 | * @return bool |
Matt Briggs | 40:2ec4be320961 | 219 | */ |
Matt Briggs | 40:2ec4be320961 | 220 | bool isLoRaWANMode(); |
Matt Briggs | 40:2ec4be320961 | 221 | |
Matt Briggs | 40:2ec4be320961 | 222 | /** |
Matt Briggs | 50:e89647e77fd5 | 223 | * @brief Returns the current state of the serial switch |
Matt Briggs | 50:e89647e77fd5 | 224 | * |
Matt Briggs | 50:e89647e77fd5 | 225 | * @details This just simply uses the last sample of the IO to return a bool. |
Matt Briggs | 50:e89647e77fd5 | 226 | * If enabled then the serial chip will be listening for traffic at least in |
Matt Briggs | 50:e89647e77fd5 | 227 | * the case of a TX. |
Matt Briggs | 50:e89647e77fd5 | 228 | * |
Matt Briggs | 50:e89647e77fd5 | 229 | * On Entry: |
Matt Briggs | 50:e89647e77fd5 | 230 | * IO should be sampled recently |
Matt Briggs | 50:e89647e77fd5 | 231 | * |
Matt Briggs | 50:e89647e77fd5 | 232 | * On Exit: |
Matt Briggs | 50:e89647e77fd5 | 233 | * |
Matt Briggs | 50:e89647e77fd5 | 234 | * @return bool |
Matt Briggs | 50:e89647e77fd5 | 235 | */ |
Matt Briggs | 50:e89647e77fd5 | 236 | bool isSerialEnabled(); |
Matt Briggs | 50:e89647e77fd5 | 237 | |
Matt Briggs | 50:e89647e77fd5 | 238 | /** |
Matt Briggs | 40:2ec4be320961 | 239 | * @brief Returns value of a rotary switch (TODO give board location) |
Matt Briggs | 40:2ec4be320961 | 240 | * |
Matt Briggs | 40:2ec4be320961 | 241 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 242 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 243 | * |
Matt Briggs | 40:2ec4be320961 | 244 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 245 | * |
Matt Briggs | 40:2ec4be320961 | 246 | * @return uint8_t |
Matt Briggs | 40:2ec4be320961 | 247 | */ |
Matt Briggs | 40:2ec4be320961 | 248 | uint8_t rotarySwitch1(); |
Matt Briggs | 40:2ec4be320961 | 249 | |
Matt Briggs | 40:2ec4be320961 | 250 | /** |
Matt Briggs | 40:2ec4be320961 | 251 | * @brief Returns value of a rotary switch (TODO give board location) |
Matt Briggs | 40:2ec4be320961 | 252 | * |
Matt Briggs | 40:2ec4be320961 | 253 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 254 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 255 | * |
Matt Briggs | 40:2ec4be320961 | 256 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 257 | * |
Matt Briggs | 40:2ec4be320961 | 258 | * @return uint8_t |
Matt Briggs | 40:2ec4be320961 | 259 | */ |
Matt Briggs | 40:2ec4be320961 | 260 | uint8_t rotarySwitch2(); |
Matt Briggs | 40:2ec4be320961 | 261 | |
Matt Briggs | 40:2ec4be320961 | 262 | //////////// |
Matt Briggs | 40:2ec4be320961 | 263 | // Output // |
Matt Briggs | 40:2ec4be320961 | 264 | //////////// |
Matt Briggs | 40:2ec4be320961 | 265 | /** |
Matt Briggs | 40:2ec4be320961 | 266 | * @brief Turns LED on |
Matt Briggs | 40:2ec4be320961 | 267 | * |
Matt Briggs | 40:2ec4be320961 | 268 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 269 | */ |
Matt Briggs | 40:2ec4be320961 | 270 | CmdResult ledOn(); |
Matt Briggs | 40:2ec4be320961 | 271 | |
Matt Briggs | 40:2ec4be320961 | 272 | /** |
Matt Briggs | 40:2ec4be320961 | 273 | * @brief Turns LED off |
Matt Briggs | 40:2ec4be320961 | 274 | * |
Matt Briggs | 40:2ec4be320961 | 275 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 276 | */ |
Matt Briggs | 40:2ec4be320961 | 277 | CmdResult ledOff(); |
Matt Briggs | 40:2ec4be320961 | 278 | |
Matt Briggs | 40:2ec4be320961 | 279 | /** |
Matt Briggs | 40:2ec4be320961 | 280 | * @brief Changes state of relay to alert |
Matt Briggs | 40:2ec4be320961 | 281 | * |
Matt Briggs | 40:2ec4be320961 | 282 | * @details If the configured as normally open then the relay closes and |
Matt Briggs | 40:2ec4be320961 | 283 | * vice versa for normally closed. |
Matt Briggs | 40:2ec4be320961 | 284 | * |
Matt Briggs | 40:2ec4be320961 | 285 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 286 | */ |
Matt Briggs | 40:2ec4be320961 | 287 | CmdResult relayAlert(); |
Matt Briggs | 40:2ec4be320961 | 288 | |
Matt Briggs | 40:2ec4be320961 | 289 | /** |
Matt Briggs | 40:2ec4be320961 | 290 | * @brief Changes state of relay to normal |
Matt Briggs | 40:2ec4be320961 | 291 | * |
Matt Briggs | 40:2ec4be320961 | 292 | * @details If the configured as normally open then the relay opens and |
Matt Briggs | 40:2ec4be320961 | 293 | * vice versa for normally closed. |
Matt Briggs | 40:2ec4be320961 | 294 | * |
Matt Briggs | 40:2ec4be320961 | 295 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 296 | */ |
Matt Briggs | 40:2ec4be320961 | 297 | CmdResult relayNormal(); |
Matt Briggs | 40:2ec4be320961 | 298 | |
Matt Briggs | 40:2ec4be320961 | 299 | /** |
Matt Briggs | 40:2ec4be320961 | 300 | * @brief Enables/disables serial chip |
Matt Briggs | 40:2ec4be320961 | 301 | * |
Matt Briggs | 40:2ec4be320961 | 302 | * @details This controls IO to ON/~OFF pin of RS232 chip. If transmitting |
Matt Briggs | 40:2ec4be320961 | 303 | * ensure serialTx is called as well. |
Matt Briggs | 40:2ec4be320961 | 304 | * |
Matt Briggs | 40:2ec4be320961 | 305 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 306 | */ |
Matt Briggs | 40:2ec4be320961 | 307 | CmdResult serialRx(bool enable); |
Matt Briggs | 40:2ec4be320961 | 308 | |
Matt Briggs | 40:2ec4be320961 | 309 | /** |
Matt Briggs | 40:2ec4be320961 | 310 | * @brief Controls serial chip transmission |
Matt Briggs | 40:2ec4be320961 | 311 | * |
Matt Briggs | 40:2ec4be320961 | 312 | * @details This controls IO to Tx_DIS pin of RS232 chip. Note calling this function will |
Matt Briggs | 40:2ec4be320961 | 313 | * also enable serialRx. |
Matt Briggs | 40:2ec4be320961 | 314 | * |
Matt Briggs | 40:2ec4be320961 | 315 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 316 | */ |
Matt Briggs | 40:2ec4be320961 | 317 | CmdResult serialTx(bool enable); |
Matt Briggs | 40:2ec4be320961 | 318 | |
Matt Briggs | 40:2ec4be320961 | 319 | private: |
Matt Briggs | 44:ece6330e9b57 | 320 | // Initialized during constructor |
Matt Briggs | 44:ece6330e9b57 | 321 | OneWire mOWMaster; |
Matt Briggs | 44:ece6330e9b57 | 322 | InterruptIn mCCIn; |
Matt Briggs | 44:ece6330e9b57 | 323 | InterruptIn mTamper; |
Matt Briggs | 44:ece6330e9b57 | 324 | InterruptIn mPairBtn; |
Matt Briggs | 44:ece6330e9b57 | 325 | DigitalOut mLed; |
Matt Briggs | 44:ece6330e9b57 | 326 | DigitalOut mSwitchedIOCtrl; |
Matt Briggs | 40:2ec4be320961 | 327 | |
Matt Briggs | 44:ece6330e9b57 | 328 | // Initialized during init() |
Matt Briggs | 44:ece6330e9b57 | 329 | // void (*mCCInIntCallback) (void); |
Matt Briggs | 44:ece6330e9b57 | 330 | // void (*mTamperIntCallback) (void); |
Matt Briggs | 44:ece6330e9b57 | 331 | // void (*mPairBtnIntCallback) (void); |
Matt Briggs | 44:ece6330e9b57 | 332 | |
Matt Briggs | 44:ece6330e9b57 | 333 | uint8_t mPortExpanderROM0[8]; |
Matt Briggs | 44:ece6330e9b57 | 334 | uint8_t mPortExpanderVal0; |
Matt Briggs | 44:ece6330e9b57 | 335 | uint8_t mPortExpanderROM1[8]; |
Matt Briggs | 44:ece6330e9b57 | 336 | uint8_t mPortExpanderVal1; |
Matt Briggs | 44:ece6330e9b57 | 337 | |
Matt Briggs | 44:ece6330e9b57 | 338 | DS2408 *mPortEx0; |
Matt Briggs | 44:ece6330e9b57 | 339 | DS2408 *mPortEx1; |
Matt Briggs | 40:2ec4be320961 | 340 | |
Matt Briggs | 49:18f1354f9e51 | 341 | void enableSwitchedIO () { |
Matt Briggs | 49:18f1354f9e51 | 342 | mSwitchedIOCtrl = 0; // assert since PMOS |
Matt Briggs | 49:18f1354f9e51 | 343 | } |
Matt Briggs | 49:18f1354f9e51 | 344 | void disableSwitchedIO () { |
Matt Briggs | 49:18f1354f9e51 | 345 | mSwitchedIOCtrl = 1; // deassertted since PMOS |
Matt Briggs | 49:18f1354f9e51 | 346 | // mSwitchedIOCtrl = 0; // FIXME |
Matt Briggs | 49:18f1354f9e51 | 347 | } |
Matt Briggs | 49:18f1354f9e51 | 348 | |
Matt Briggs | 40:2ec4be320961 | 349 | /** |
Matt Briggs | 40:2ec4be320961 | 350 | * @brief Reads baseboard information from non-volatile memory (NVM) |
Matt Briggs | 40:2ec4be320961 | 351 | * |
Matt Briggs | 40:2ec4be320961 | 352 | * @details This data is read from the xDot's internal EEPROM. This |
Matt Briggs | 40:2ec4be320961 | 353 | * method is called from init(). The following |
Matt Briggs | 40:2ec4be320961 | 354 | * is stored: |
Matt Briggs | 40:2ec4be320961 | 355 | * 1. Storage code word |
Matt Briggs | 40:2ec4be320961 | 356 | * 2. 8-bit Baseboard configuration data |
Matt Briggs | 40:2ec4be320961 | 357 | * 3. 8-bit Baseboard revision data |
Matt Briggs | 40:2ec4be320961 | 358 | * 4. 16-bit Baseboard serial number |
Matt Briggs | 40:2ec4be320961 | 359 | * 5. 2 x 64-bit OneWire ROM port expander addresses |
Matt Briggs | 40:2ec4be320961 | 360 | * |
Matt Briggs | 40:2ec4be320961 | 361 | * TODO add memory map information |
Matt Briggs | 40:2ec4be320961 | 362 | * |
Matt Briggs | 40:2ec4be320961 | 363 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 364 | */ |
Matt Briggs | 40:2ec4be320961 | 365 | CmdResult readInfoFromNVM(); |
Matt Briggs | 40:2ec4be320961 | 366 | |
Matt Briggs | 40:2ec4be320961 | 367 | /** |
Matt Briggs | 40:2ec4be320961 | 368 | * @brief Stores baseboard information to non-volatile memory (NVM) |
Matt Briggs | 40:2ec4be320961 | 369 | * |
Matt Briggs | 40:2ec4be320961 | 370 | * @details This method is called during special configuration events like first time boot or factory reset. |
Matt Briggs | 40:2ec4be320961 | 371 | * |
Matt Briggs | 40:2ec4be320961 | 372 | * TODO add memory map information |
Matt Briggs | 40:2ec4be320961 | 373 | * |
Matt Briggs | 40:2ec4be320961 | 374 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 375 | */ |
Matt Briggs | 40:2ec4be320961 | 376 | CmdResult writeInfoToNVM(); |
Matt Briggs | 40:2ec4be320961 | 377 | |
Matt Briggs | 40:2ec4be320961 | 378 | /** |
Matt Briggs | 40:2ec4be320961 | 379 | * @brief Scans OneWire bus for port expanders and attempts to identify each. |
Matt Briggs | 40:2ec4be320961 | 380 | * |
Matt Briggs | 40:2ec4be320961 | 381 | * @details For this method to succeed switches must be in factory reset positions. |
Matt Briggs | 44:ece6330e9b57 | 382 | * Rotary 1 and 2 should be at 0 |
Matt Briggs | 44:ece6330e9b57 | 383 | * DIP Switches should be fully closed |
Matt Briggs | 40:2ec4be320961 | 384 | * |
Matt Briggs | 40:2ec4be320961 | 385 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 386 | */ |
Matt Briggs | 40:2ec4be320961 | 387 | CmdResult identifyPortExpanders(); |
Matt Briggs | 44:ece6330e9b57 | 388 | |
Matt Briggs | 44:ece6330e9b57 | 389 | /** |
Matt Briggs | 44:ece6330e9b57 | 390 | * @brief Forces relay to closed state |
Matt Briggs | 44:ece6330e9b57 | 391 | * |
Matt Briggs | 44:ece6330e9b57 | 392 | * @details Note coil assertion timing is done here |
Matt Briggs | 44:ece6330e9b57 | 393 | * |
Matt Briggs | 44:ece6330e9b57 | 394 | * @return CmdResult |
Matt Briggs | 44:ece6330e9b57 | 395 | */ |
Matt Briggs | 44:ece6330e9b57 | 396 | CmdResult closeRelay(); |
Matt Briggs | 44:ece6330e9b57 | 397 | |
Matt Briggs | 44:ece6330e9b57 | 398 | /** |
Matt Briggs | 44:ece6330e9b57 | 399 | * @brief Forces relay to open state |
Matt Briggs | 44:ece6330e9b57 | 400 | * |
Matt Briggs | 44:ece6330e9b57 | 401 | * @details Note coil assertion timing is done here |
Matt Briggs | 44:ece6330e9b57 | 402 | * |
Matt Briggs | 44:ece6330e9b57 | 403 | * @return CmdResult |
Matt Briggs | 44:ece6330e9b57 | 404 | */ |
Matt Briggs | 44:ece6330e9b57 | 405 | CmdResult openRelay(); |
Matt Briggs | 40:2ec4be320961 | 406 | }; |
Matt Briggs | 40:2ec4be320961 | 407 | |
Matt Briggs | 40:2ec4be320961 | 408 | #endif /* BASEBOARDIO_BASEBOARDIO_H_ */ |