Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Committer:
mbriggs_vortex
Date:
Wed Nov 29 13:54:36 2017 -0700
Revision:
100:0882cf295f8e
Parent:
98:3609f600c2f5
Adding relaese bin to repo

Who changed what in which revision?

UserRevisionLine numberNew 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
mbriggs_vortex 98:3609f600c2f5 48 // Hold for seeding new values
mbriggs_vortex 98:3609f600c2f5 49 bool mSaveIsCCNO;
mbriggs_vortex 98:3609f600c2f5 50 bool mSaveIsTx;
mbriggs_vortex 98:3609f600c2f5 51 uint8_t mSaveRot1;
mbriggs_vortex 98:3609f600c2f5 52
Matt Briggs 75:600cb3a9f126 53 bool inputMainPage(char in);
Matt Briggs 75:600cb3a9f126 54 void printMainScreen();
Matt Briggs 75:600cb3a9f126 55 void inputGenInfo (char in);
Matt Briggs 75:600cb3a9f126 56 void printGenInfo();
mbriggs_vortex 98:3609f600c2f5 57 void inputSettings (char in);
mbriggs_vortex 98:3609f600c2f5 58 void printSettings();
mbriggs_vortex 98:3609f600c2f5 59 void seedSaveSettings();
mbriggs_vortex 98:3609f600c2f5 60 void applySaveSettings();
Matt Briggs 76:d1b20a259d8f 61 void inputEnterProgMode (char in);
Matt Briggs 76:d1b20a259d8f 62 void printEnterProgMode();
Matt Briggs 76:d1b20a259d8f 63 bool xmodem2Flash();
mbriggs_vortex 78:43f074baac34 64 void writeBootloaderCtrlPage(uint32_t nBytes);
Matt Briggs 75:600cb3a9f126 65 public:
Matt Briggs 77:176e3eb8f712 66 SerialTermMgr(BaseboardIO *bbio, WinbondSPIFlash *flash, float fwVersion);
Matt Briggs 77:176e3eb8f712 67 void regSerial (BufferedSerial *pc) {
Matt Briggs 75:600cb3a9f126 68 mPc = pc;
Matt Briggs 75:600cb3a9f126 69 }
Matt Briggs 75:600cb3a9f126 70 ScreenId getCurrentScreenId() {
Matt Briggs 75:600cb3a9f126 71 return mCurrScreen;
Matt Briggs 75:600cb3a9f126 72 }
Matt Briggs 75:600cb3a9f126 73 void printScreen();
Matt Briggs 75:600cb3a9f126 74 bool input();
Matt Briggs 75:600cb3a9f126 75 };
Matt Briggs 75:600cb3a9f126 76
Matt Briggs 75:600cb3a9f126 77 #endif /* XDOTBRIDGE_INC_SERIALTERMMGR_H_ */