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:
Matt Briggs
Date:
Wed May 17 16:41:56 2017 -0600
Revision:
77:176e3eb8f712
Parent:
76:d1b20a259d8f
Child:
78:43f074baac34
Added serial terminal and Buffered lib

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