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:
Mon Nov 13 09:50:49 2017 -0700
Revision:
78:43f074baac34
Parent:
77:176e3eb8f712
Child:
91:8196900df6fe
Committing code so far for getting bootloader to work.

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 78:43f074baac34 23 //const char NEW_CODE [] = "NEWCODE0";
Matt Briggs 76:d1b20a259d8f 24
Matt Briggs 75:600cb3a9f126 25 enum ScreenId {
Matt Briggs 75:600cb3a9f126 26 mainScreenId,
Matt Briggs 75:600cb3a9f126 27 genInfoScreenId,
Matt Briggs 75:600cb3a9f126 28 settingsScreenId,
Matt Briggs 75:600cb3a9f126 29 statsScreenId,
Matt Briggs 75:600cb3a9f126 30 errorLogScreenId,
Matt Briggs 75:600cb3a9f126 31 liveLogScreenId,
Matt Briggs 75:600cb3a9f126 32 enterSerialBridgeScreenId,
Matt Briggs 75:600cb3a9f126 33 enterProgModeScreenId
Matt Briggs 75:600cb3a9f126 34 };
Matt Briggs 75:600cb3a9f126 35
Matt Briggs 75:600cb3a9f126 36
Matt Briggs 75:600cb3a9f126 37 class SerialTermMgr
Matt Briggs 75:600cb3a9f126 38 {
Matt Briggs 75:600cb3a9f126 39 private:
Matt Briggs 75:600cb3a9f126 40 ScreenId mCurrScreen; // Current selection
Matt Briggs 75:600cb3a9f126 41 float mFwVersion;
Matt Briggs 75:600cb3a9f126 42 BaseboardIO *mBbio; // Handle for reading states
Matt Briggs 77:176e3eb8f712 43 BufferedSerial *mPc;
Matt Briggs 77:176e3eb8f712 44 WinbondSPIFlash *mFlash;
Matt Briggs 75:600cb3a9f126 45
Matt Briggs 75:600cb3a9f126 46 bool inputMainPage(char in);
Matt Briggs 75:600cb3a9f126 47 void printMainScreen();
Matt Briggs 75:600cb3a9f126 48 void inputGenInfo (char in);
Matt Briggs 75:600cb3a9f126 49 void printGenInfo();
Matt Briggs 76:d1b20a259d8f 50 void inputEnterProgMode (char in);
Matt Briggs 76:d1b20a259d8f 51 void printEnterProgMode();
Matt Briggs 76:d1b20a259d8f 52 bool xmodem2Flash();
mbriggs_vortex 78:43f074baac34 53 void writeBootloaderCtrlPage(uint32_t nBytes);
Matt Briggs 75:600cb3a9f126 54 public:
Matt Briggs 77:176e3eb8f712 55 SerialTermMgr(BaseboardIO *bbio, WinbondSPIFlash *flash, float fwVersion);
Matt Briggs 77:176e3eb8f712 56 void regSerial (BufferedSerial *pc) {
Matt Briggs 75:600cb3a9f126 57 mPc = pc;
Matt Briggs 75:600cb3a9f126 58 }
Matt Briggs 75:600cb3a9f126 59 ScreenId getCurrentScreenId() {
Matt Briggs 75:600cb3a9f126 60 return mCurrScreen;
Matt Briggs 75:600cb3a9f126 61 }
Matt Briggs 75:600cb3a9f126 62 void printScreen();
Matt Briggs 75:600cb3a9f126 63 bool input();
Matt Briggs 75:600cb3a9f126 64 };
Matt Briggs 75:600cb3a9f126 65
Matt Briggs 75:600cb3a9f126 66 #endif /* XDOTBRIDGE_INC_SERIALTERMMGR_H_ */