![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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@44:ece6330e9b57, 2017-02-01 (annotated)
- Committer:
- Matt Briggs
- Date:
- Wed Feb 01 15:20:45 2017 -0700
- Revision:
- 44:ece6330e9b57
- Parent:
- 40:2ec4be320961
- Child:
- 48:bab9f747d9ed
First cut at BaseboardIO class implementation.
Minior cleanup in main and CommProtocolPeerBrute
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 | 40:2ec4be320961 | 153 | bool isCCOutNO(); |
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 | 40:2ec4be320961 | 170 | bool isCCOutNC() {return isCCOutNO();} |
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 | 40:2ec4be320961 | 223 | * @brief Returns value of a rotary switch (TODO give board location) |
Matt Briggs | 40:2ec4be320961 | 224 | * |
Matt Briggs | 40:2ec4be320961 | 225 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 226 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 227 | * |
Matt Briggs | 40:2ec4be320961 | 228 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 229 | * |
Matt Briggs | 40:2ec4be320961 | 230 | * @return uint8_t |
Matt Briggs | 40:2ec4be320961 | 231 | */ |
Matt Briggs | 40:2ec4be320961 | 232 | uint8_t rotarySwitch1(); |
Matt Briggs | 40:2ec4be320961 | 233 | |
Matt Briggs | 40:2ec4be320961 | 234 | /** |
Matt Briggs | 40:2ec4be320961 | 235 | * @brief Returns value of a rotary switch (TODO give board location) |
Matt Briggs | 40:2ec4be320961 | 236 | * |
Matt Briggs | 40:2ec4be320961 | 237 | * On Entry: |
Matt Briggs | 40:2ec4be320961 | 238 | * IO should be sampled recently |
Matt Briggs | 40:2ec4be320961 | 239 | * |
Matt Briggs | 40:2ec4be320961 | 240 | * On Exit: |
Matt Briggs | 40:2ec4be320961 | 241 | * |
Matt Briggs | 40:2ec4be320961 | 242 | * @return uint8_t |
Matt Briggs | 40:2ec4be320961 | 243 | */ |
Matt Briggs | 40:2ec4be320961 | 244 | uint8_t rotarySwitch2(); |
Matt Briggs | 40:2ec4be320961 | 245 | |
Matt Briggs | 40:2ec4be320961 | 246 | //////////// |
Matt Briggs | 40:2ec4be320961 | 247 | // Output // |
Matt Briggs | 40:2ec4be320961 | 248 | //////////// |
Matt Briggs | 40:2ec4be320961 | 249 | /** |
Matt Briggs | 40:2ec4be320961 | 250 | * @brief Turns LED on |
Matt Briggs | 40:2ec4be320961 | 251 | * |
Matt Briggs | 40:2ec4be320961 | 252 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 253 | */ |
Matt Briggs | 40:2ec4be320961 | 254 | CmdResult ledOn(); |
Matt Briggs | 40:2ec4be320961 | 255 | |
Matt Briggs | 40:2ec4be320961 | 256 | /** |
Matt Briggs | 40:2ec4be320961 | 257 | * @brief Turns LED off |
Matt Briggs | 40:2ec4be320961 | 258 | * |
Matt Briggs | 40:2ec4be320961 | 259 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 260 | */ |
Matt Briggs | 40:2ec4be320961 | 261 | CmdResult ledOff(); |
Matt Briggs | 40:2ec4be320961 | 262 | |
Matt Briggs | 40:2ec4be320961 | 263 | /** |
Matt Briggs | 40:2ec4be320961 | 264 | * @brief Changes state of relay to alert |
Matt Briggs | 40:2ec4be320961 | 265 | * |
Matt Briggs | 40:2ec4be320961 | 266 | * @details If the configured as normally open then the relay closes and |
Matt Briggs | 40:2ec4be320961 | 267 | * vice versa for normally closed. |
Matt Briggs | 40:2ec4be320961 | 268 | * |
Matt Briggs | 40:2ec4be320961 | 269 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 270 | */ |
Matt Briggs | 40:2ec4be320961 | 271 | CmdResult relayAlert(); |
Matt Briggs | 40:2ec4be320961 | 272 | |
Matt Briggs | 40:2ec4be320961 | 273 | /** |
Matt Briggs | 40:2ec4be320961 | 274 | * @brief Changes state of relay to normal |
Matt Briggs | 40:2ec4be320961 | 275 | * |
Matt Briggs | 40:2ec4be320961 | 276 | * @details If the configured as normally open then the relay opens and |
Matt Briggs | 40:2ec4be320961 | 277 | * vice versa for normally closed. |
Matt Briggs | 40:2ec4be320961 | 278 | * |
Matt Briggs | 40:2ec4be320961 | 279 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 280 | */ |
Matt Briggs | 40:2ec4be320961 | 281 | CmdResult relayNormal(); |
Matt Briggs | 40:2ec4be320961 | 282 | |
Matt Briggs | 40:2ec4be320961 | 283 | /** |
Matt Briggs | 40:2ec4be320961 | 284 | * @brief Enables/disables serial chip |
Matt Briggs | 40:2ec4be320961 | 285 | * |
Matt Briggs | 40:2ec4be320961 | 286 | * @details This controls IO to ON/~OFF pin of RS232 chip. If transmitting |
Matt Briggs | 40:2ec4be320961 | 287 | * ensure serialTx is called as well. |
Matt Briggs | 40:2ec4be320961 | 288 | * |
Matt Briggs | 40:2ec4be320961 | 289 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 290 | */ |
Matt Briggs | 40:2ec4be320961 | 291 | CmdResult serialRx(bool enable); |
Matt Briggs | 40:2ec4be320961 | 292 | |
Matt Briggs | 40:2ec4be320961 | 293 | /** |
Matt Briggs | 40:2ec4be320961 | 294 | * @brief Controls serial chip transmission |
Matt Briggs | 40:2ec4be320961 | 295 | * |
Matt Briggs | 40:2ec4be320961 | 296 | * @details This controls IO to Tx_DIS pin of RS232 chip. Note calling this function will |
Matt Briggs | 40:2ec4be320961 | 297 | * also enable serialRx. |
Matt Briggs | 40:2ec4be320961 | 298 | * |
Matt Briggs | 40:2ec4be320961 | 299 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 300 | */ |
Matt Briggs | 40:2ec4be320961 | 301 | CmdResult serialTx(bool enable); |
Matt Briggs | 40:2ec4be320961 | 302 | |
Matt Briggs | 40:2ec4be320961 | 303 | private: |
Matt Briggs | 44:ece6330e9b57 | 304 | // Initialized during constructor |
Matt Briggs | 44:ece6330e9b57 | 305 | OneWire mOWMaster; |
Matt Briggs | 44:ece6330e9b57 | 306 | InterruptIn mCCIn; |
Matt Briggs | 44:ece6330e9b57 | 307 | InterruptIn mTamper; |
Matt Briggs | 44:ece6330e9b57 | 308 | InterruptIn mPairBtn; |
Matt Briggs | 44:ece6330e9b57 | 309 | DigitalOut mLed; |
Matt Briggs | 44:ece6330e9b57 | 310 | DigitalOut mSwitchedIOCtrl; |
Matt Briggs | 40:2ec4be320961 | 311 | |
Matt Briggs | 44:ece6330e9b57 | 312 | // Initialized during init() |
Matt Briggs | 44:ece6330e9b57 | 313 | // void (*mCCInIntCallback) (void); |
Matt Briggs | 44:ece6330e9b57 | 314 | // void (*mTamperIntCallback) (void); |
Matt Briggs | 44:ece6330e9b57 | 315 | // void (*mPairBtnIntCallback) (void); |
Matt Briggs | 44:ece6330e9b57 | 316 | |
Matt Briggs | 44:ece6330e9b57 | 317 | uint8_t mPortExpanderROM0[8]; |
Matt Briggs | 44:ece6330e9b57 | 318 | uint8_t mPortExpanderVal0; |
Matt Briggs | 44:ece6330e9b57 | 319 | uint8_t mPortExpanderROM1[8]; |
Matt Briggs | 44:ece6330e9b57 | 320 | uint8_t mPortExpanderVal1; |
Matt Briggs | 44:ece6330e9b57 | 321 | |
Matt Briggs | 44:ece6330e9b57 | 322 | DS2408 *mPortEx0; |
Matt Briggs | 44:ece6330e9b57 | 323 | DS2408 *mPortEx1; |
Matt Briggs | 40:2ec4be320961 | 324 | |
Matt Briggs | 40:2ec4be320961 | 325 | /** |
Matt Briggs | 40:2ec4be320961 | 326 | * @brief Reads baseboard information from non-volatile memory (NVM) |
Matt Briggs | 40:2ec4be320961 | 327 | * |
Matt Briggs | 40:2ec4be320961 | 328 | * @details This data is read from the xDot's internal EEPROM. This |
Matt Briggs | 40:2ec4be320961 | 329 | * method is called from init(). The following |
Matt Briggs | 40:2ec4be320961 | 330 | * is stored: |
Matt Briggs | 40:2ec4be320961 | 331 | * 1. Storage code word |
Matt Briggs | 40:2ec4be320961 | 332 | * 2. 8-bit Baseboard configuration data |
Matt Briggs | 40:2ec4be320961 | 333 | * 3. 8-bit Baseboard revision data |
Matt Briggs | 40:2ec4be320961 | 334 | * 4. 16-bit Baseboard serial number |
Matt Briggs | 40:2ec4be320961 | 335 | * 5. 2 x 64-bit OneWire ROM port expander addresses |
Matt Briggs | 40:2ec4be320961 | 336 | * |
Matt Briggs | 40:2ec4be320961 | 337 | * TODO add memory map information |
Matt Briggs | 40:2ec4be320961 | 338 | * |
Matt Briggs | 40:2ec4be320961 | 339 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 340 | */ |
Matt Briggs | 40:2ec4be320961 | 341 | CmdResult readInfoFromNVM(); |
Matt Briggs | 40:2ec4be320961 | 342 | |
Matt Briggs | 40:2ec4be320961 | 343 | /** |
Matt Briggs | 40:2ec4be320961 | 344 | * @brief Stores baseboard information to non-volatile memory (NVM) |
Matt Briggs | 40:2ec4be320961 | 345 | * |
Matt Briggs | 40:2ec4be320961 | 346 | * @details This method is called during special configuration events like first time boot or factory reset. |
Matt Briggs | 40:2ec4be320961 | 347 | * |
Matt Briggs | 40:2ec4be320961 | 348 | * TODO add memory map information |
Matt Briggs | 40:2ec4be320961 | 349 | * |
Matt Briggs | 40:2ec4be320961 | 350 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 351 | */ |
Matt Briggs | 40:2ec4be320961 | 352 | CmdResult writeInfoToNVM(); |
Matt Briggs | 40:2ec4be320961 | 353 | |
Matt Briggs | 40:2ec4be320961 | 354 | /** |
Matt Briggs | 40:2ec4be320961 | 355 | * @brief Scans OneWire bus for port expanders and attempts to identify each. |
Matt Briggs | 40:2ec4be320961 | 356 | * |
Matt Briggs | 40:2ec4be320961 | 357 | * @details For this method to succeed switches must be in factory reset positions. |
Matt Briggs | 44:ece6330e9b57 | 358 | * Rotary 1 and 2 should be at 0 |
Matt Briggs | 44:ece6330e9b57 | 359 | * DIP Switches should be fully closed |
Matt Briggs | 40:2ec4be320961 | 360 | * |
Matt Briggs | 40:2ec4be320961 | 361 | * @return CmdResult |
Matt Briggs | 40:2ec4be320961 | 362 | */ |
Matt Briggs | 40:2ec4be320961 | 363 | CmdResult identifyPortExpanders(); |
Matt Briggs | 44:ece6330e9b57 | 364 | |
Matt Briggs | 44:ece6330e9b57 | 365 | /** |
Matt Briggs | 44:ece6330e9b57 | 366 | * @brief Forces relay to closed state |
Matt Briggs | 44:ece6330e9b57 | 367 | * |
Matt Briggs | 44:ece6330e9b57 | 368 | * @details Note coil assertion timing is done here |
Matt Briggs | 44:ece6330e9b57 | 369 | * |
Matt Briggs | 44:ece6330e9b57 | 370 | * @return CmdResult |
Matt Briggs | 44:ece6330e9b57 | 371 | */ |
Matt Briggs | 44:ece6330e9b57 | 372 | CmdResult closeRelay(); |
Matt Briggs | 44:ece6330e9b57 | 373 | |
Matt Briggs | 44:ece6330e9b57 | 374 | /** |
Matt Briggs | 44:ece6330e9b57 | 375 | * @brief Forces relay to open state |
Matt Briggs | 44:ece6330e9b57 | 376 | * |
Matt Briggs | 44:ece6330e9b57 | 377 | * @details Note coil assertion timing is done here |
Matt Briggs | 44:ece6330e9b57 | 378 | * |
Matt Briggs | 44:ece6330e9b57 | 379 | * @return CmdResult |
Matt Briggs | 44:ece6330e9b57 | 380 | */ |
Matt Briggs | 44:ece6330e9b57 | 381 | CmdResult openRelay(); |
Matt Briggs | 40:2ec4be320961 | 382 | }; |
Matt Briggs | 40:2ec4be320961 | 383 | |
Matt Briggs | 40:2ec4be320961 | 384 | #endif /* BASEBOARDIO_BASEBOARDIO_H_ */ |