Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: BaseEmuISP.h
- Revision:
- 2:e3c085ac77f1
- Parent:
- 1:4ff199bddbc1
- Child:
- 3:ccc673a10485
--- a/BaseEmuISP.h Tue Mar 08 12:03:48 2016 +0900 +++ b/BaseEmuISP.h Sat Mar 12 09:34:38 2016 +0900 @@ -1,38 +1,44 @@ -// BaseEmuISP.h 2016/3/8 +// BaseEmuISP.h 2016/3/10 #pragma once #include <string> #include <vector> -#define M_RESET 0 -#define M_SYNC 1 -#define M_CMD 2 -#define M_CMD_W_DATA 3 -#define M_CMD_R_DATA 4 -#define M_CMD_J 5 -#define M_CMD_K 6 -#define M_CMD_N 7 +typedef std::vector<int> vint_t; + +enum Mode_t { + M_RESET = 0, + M_SYNC, + M_CMD, + M_CMD_W_DATA, + M_CMD_R_DATA, + M_CMD_J, + M_CMD_K, + M_CMD_N, + M_CMD_S, +}; -// Return Code -#define CMD_SUCCESS 0 -#define INVALID_COMMAND 1 -#define SRC_ADDR_ERROR 2 -#define DST_ADDR_ERROR 3 -#define SRC_ADDR_NOT_MAPPED 4 -#define DST_ADDR_NOT_MAPPED 5 -#define COUNT_ERROR 6 -#define INVALID_SECTOR 7 -#define SECTOR_NOT_BLANK 8 -#define SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 9 -#define COMPARE_ERROR 10 -#define BUSY 11 -#define PARAM_ERROR 12 -#define ADDR_ERROR 13 -#define ADDR_NOT_MAPPED 14 -#define CMD_LOCKED 15 -#define INVALID_CODE 16 -#define INVALID_BAUD_RATE 17 -#define INVALID_STOP_BIT 18 -#define CODE_READ_PROTECTIN_ENABLED 19 +enum ReturnCode_t { + CMD_SUCCESS = 0, + INVALID_COMMAND = 1, + SRC_ADDR_ERROR = 2, + DST_ADDR_ERROR = 3, + SRC_ADDR_NOT_MAPPED = 4, + DST_ADDR_NOT_MAPPED = 5, + COUNT_ERROR = 6, + INVALID_SECTOR = 7, + SECTOR_NOT_BLANK = 8, + SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION = 9, + COMPARE_ERROR = 10, + BUSY = 11, + PARAM_ERROR = 12, + ADDR_ERROR = 13, + ADDR_NOT_MAPPED = 14, + CMD_LOCKED = 15, + INVALID_CODE = 16, + INVALID_BAUD_RATE = 17, + INVALID_STOP_BIT = 18, + CODE_READ_PROTECTIN_ENABLED = 19, +}; class BaseEmuISP { public: @@ -40,37 +46,40 @@ void Poll(); protected: - virtual int Part() { return 0; } + virtual int PartID() { return 0x00008100; } // LPC810M021FN8 virtual void WriteData(int addr, int c) {} virtual int ReadData(int addr) { return 0; } virtual void CopyData(int dst, int src, int count) {} - virtual bool SectorExist(int sector) { return true; } + virtual bool Compare(int addr1, int addr2, int count) { return true; } + virtual bool Prepare(int sector) { return true; } + virtual bool Erase(int sector) { return true; } + virtual bool Blank(int sector) { return true; } virtual int Getch() = 0; virtual void Putch(int c) = 0; virtual void DebugPutch(int c) { return; } private: bool sync(); - int cmd(const char* s); - int cmd_u(int arg, int p1); - int cmd_b(int arg, int p1, int p2); - int cmd_a(int arg, int p1); - int cmd_w(int arg, int p1, int p2); - int cmd_r(int arg, int p1, int p2); - int cmd_p(int arg, int p1, int p2); - int cmd_c(int arg, int p1, int p2, int p3); - int cmd_g(int arg, int p1, int p2); - int cmd_e(int arg, int p1, int p2); - int cmd_i(int arg, int p1, int p2); - int cmd_j(int arg); - int cmd_k(int arg); - int cmd_m(int arg, int p1, int p2, int p3); - int cmd_n(int arg); - int cmd_s(int arg, int p1, int p2); + ReturnCode_t cmd(const char* s); + ReturnCode_t cmd_u(vint_t ¶m); + ReturnCode_t cmd_b(vint_t ¶m); + ReturnCode_t cmd_a(vint_t ¶m); + ReturnCode_t cmd_w(vint_t ¶m); + ReturnCode_t cmd_r(vint_t ¶m); + ReturnCode_t cmd_p(vint_t ¶m); + ReturnCode_t cmd_c(vint_t ¶m); + ReturnCode_t cmd_g(vint_t ¶m); + ReturnCode_t cmd_e(vint_t ¶m); + ReturnCode_t cmd_i(vint_t ¶m); + ReturnCode_t cmd_j(vint_t ¶m); + ReturnCode_t cmd_k(vint_t ¶m); + ReturnCode_t cmd_m(vint_t ¶m); + ReturnCode_t cmd_n(vint_t ¶m); + ReturnCode_t cmd_s(vint_t ¶m); void putln(const char *s); bool line_proc(); void debugPrintf(const char *format, ...); - int mode; + Mode_t mode; int seq; bool echoFlag; bool lockFlag;