![](/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/SerialTermMgr.h@92:1f86edb14cbe, 2017-11-21 (annotated)
- Committer:
- mbriggs_vortex
- Date:
- Tue Nov 21 16:07:54 2017 -0700
- Revision:
- 92:1f86edb14cbe
- Parent:
- 91:8196900df6fe
- Child:
- 98:3609f600c2f5
Added updated bootloader with blink. Added key check at end of update.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Matt Briggs | 75:600cb3a9f126 | 1 | /* |
Matt Briggs | 75:600cb3a9f126 | 2 | * SerialTermMgr.h |
Matt Briggs | 75:600cb3a9f126 | 3 | * |
Matt Briggs | 75:600cb3a9f126 | 4 | * Created on: May 8, 2017 |
Matt Briggs | 75:600cb3a9f126 | 5 | * Author: mbriggs |
Matt Briggs | 75:600cb3a9f126 | 6 | */ |
Matt Briggs | 75:600cb3a9f126 | 7 | |
Matt Briggs | 75:600cb3a9f126 | 8 | #ifndef XDOTBRIDGE_INC_SERIALTERMMGR_H_ |
Matt Briggs | 75:600cb3a9f126 | 9 | #define XDOTBRIDGE_INC_SERIALTERMMGR_H_ |
Matt Briggs | 75:600cb3a9f126 | 10 | |
Matt Briggs | 75:600cb3a9f126 | 11 | #include "mbed.h" |
Matt Briggs | 77:176e3eb8f712 | 12 | #include "BufferedSerial.h" |
Matt Briggs | 77:176e3eb8f712 | 13 | #include "WinbondSPIFlash.h" |
Matt Briggs | 75:600cb3a9f126 | 14 | #include "BaseboardIO.h" |
Matt Briggs | 75:600cb3a9f126 | 15 | |
Matt Briggs | 76:d1b20a259d8f | 16 | const uint32_t TERM_BAUD = 115200; |
Matt Briggs | 75:600cb3a9f126 | 17 | const uint8_t TERM_TIMEOUT = 30; // In seconds |
Matt Briggs | 75:600cb3a9f126 | 18 | |
Matt Briggs | 76:d1b20a259d8f | 19 | const float XMODEM_TIMEOUT = 10.0; |
mbriggs_vortex | 78:43f074baac34 | 20 | const unsigned char MAX_TIMEOUTS = 6; // multiple by TIMEOUT above. 60 total seconds |
Matt Briggs | 77:176e3eb8f712 | 21 | const uint16_t FLASH_BIN_OFFSET = 256; // Skip first flash page |
Matt Briggs | 77:176e3eb8f712 | 22 | const uint16_t XMODEM_PACKET_SIZE = 128; |
mbriggs_vortex | 91:8196900df6fe | 23 | const char NEW_CODE [] = "NEWCODE0"; |
mbriggs_vortex | 91:8196900df6fe | 24 | const char END0LINE [] = "END0LINE"; |
mbriggs_vortex | 92:1f86edb14cbe | 25 | const char VORTEX_UPDATE_KEY [] = "V0RT3XUPDATE"; |
Matt Briggs | 76:d1b20a259d8f | 26 | |
Matt Briggs | 75:600cb3a9f126 | 27 | enum ScreenId { |
Matt Briggs | 75:600cb3a9f126 | 28 | mainScreenId, |
Matt Briggs | 75:600cb3a9f126 | 29 | genInfoScreenId, |
Matt Briggs | 75:600cb3a9f126 | 30 | settingsScreenId, |
Matt Briggs | 75:600cb3a9f126 | 31 | statsScreenId, |
Matt Briggs | 75:600cb3a9f126 | 32 | errorLogScreenId, |
Matt Briggs | 75:600cb3a9f126 | 33 | liveLogScreenId, |
Matt Briggs | 75:600cb3a9f126 | 34 | enterSerialBridgeScreenId, |
Matt Briggs | 75:600cb3a9f126 | 35 | enterProgModeScreenId |
Matt Briggs | 75:600cb3a9f126 | 36 | }; |
Matt Briggs | 75:600cb3a9f126 | 37 | |
Matt Briggs | 75:600cb3a9f126 | 38 | |
Matt Briggs | 75:600cb3a9f126 | 39 | class SerialTermMgr |
Matt Briggs | 75:600cb3a9f126 | 40 | { |
Matt Briggs | 75:600cb3a9f126 | 41 | private: |
Matt Briggs | 75:600cb3a9f126 | 42 | ScreenId mCurrScreen; // Current selection |
Matt Briggs | 75:600cb3a9f126 | 43 | float mFwVersion; |
Matt Briggs | 75:600cb3a9f126 | 44 | BaseboardIO *mBbio; // Handle for reading states |
Matt Briggs | 77:176e3eb8f712 | 45 | BufferedSerial *mPc; |
Matt Briggs | 77:176e3eb8f712 | 46 | WinbondSPIFlash *mFlash; |
Matt Briggs | 75:600cb3a9f126 | 47 | |
Matt Briggs | 75:600cb3a9f126 | 48 | bool inputMainPage(char in); |
Matt Briggs | 75:600cb3a9f126 | 49 | void printMainScreen(); |
Matt Briggs | 75:600cb3a9f126 | 50 | void inputGenInfo (char in); |
Matt Briggs | 75:600cb3a9f126 | 51 | void printGenInfo(); |
Matt Briggs | 76:d1b20a259d8f | 52 | void inputEnterProgMode (char in); |
Matt Briggs | 76:d1b20a259d8f | 53 | void printEnterProgMode(); |
Matt Briggs | 76:d1b20a259d8f | 54 | bool xmodem2Flash(); |
mbriggs_vortex | 78:43f074baac34 | 55 | void writeBootloaderCtrlPage(uint32_t nBytes); |
Matt Briggs | 75:600cb3a9f126 | 56 | public: |
Matt Briggs | 77:176e3eb8f712 | 57 | SerialTermMgr(BaseboardIO *bbio, WinbondSPIFlash *flash, float fwVersion); |
Matt Briggs | 77:176e3eb8f712 | 58 | void regSerial (BufferedSerial *pc) { |
Matt Briggs | 75:600cb3a9f126 | 59 | mPc = pc; |
Matt Briggs | 75:600cb3a9f126 | 60 | } |
Matt Briggs | 75:600cb3a9f126 | 61 | ScreenId getCurrentScreenId() { |
Matt Briggs | 75:600cb3a9f126 | 62 | return mCurrScreen; |
Matt Briggs | 75:600cb3a9f126 | 63 | } |
Matt Briggs | 75:600cb3a9f126 | 64 | void printScreen(); |
Matt Briggs | 75:600cb3a9f126 | 65 | bool input(); |
Matt Briggs | 75:600cb3a9f126 | 66 | }; |
Matt Briggs | 75:600cb3a9f126 | 67 | |
Matt Briggs | 75:600cb3a9f126 | 68 | #endif /* XDOTBRIDGE_INC_SERIALTERMMGR_H_ */ |