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.
BaseEmuISP.h
- Committer:
- va009039
- Date:
- 2016-03-12
- Revision:
- 2:e3c085ac77f1
- Parent:
- 1:4ff199bddbc1
- Child:
- 3:ccc673a10485
File content as of revision 2:e3c085ac77f1:
// BaseEmuISP.h 2016/3/10
#pragma once
#include <string>
#include <vector>
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,
};
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:
void Reset();
void Poll();
protected:
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 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();
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, ...);
Mode_t mode;
int seq;
bool echoFlag;
bool lockFlag;
std::string line;
int freq;
int addr;
int count;
};