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