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-23
- Revision:
- 4:05f33cc747fd
- Parent:
- 3:ccc673a10485
- Child:
- 5:e2c275b33bbf
File content as of revision 4:05f33cc747fd:
// BaseEmuISP.h 2016/3/23 #pragma once #include <stdint.h> #include "myvector.h" typedef myvector<int> vint_t; typedef myvector<uint8_t> vbyte_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 BootCodeVersion() { return 4<<8|13; } // 4.13 virtual int PartID() { return 0x00008100; } // LPC810M021FN8 virtual bool UuencodeMode() { return false; } virtual bool WriteData(int addr, int c) { return false; } virtual int ReadData(int addr) { return 0; } virtual bool CopyData(int dst, int src, int count) { return false; } 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); bool cmd_w_data(); bool cmd_r_data(); void putln(const char *s); void debugPrintf(const char *format, ...); Mode_t mode; int seq; bool echoFlag; bool lockFlag; bool line_proc(); struct { void Clear() { pos = 0; } size_t Size() { return pos; } const char *C_str() {return buf; } void operator +=(int c) { if (pos < sizeof(buf)-2) buf[pos++] = c; buf[pos] = '\0'; } bool operator ==(const char* s) { return strcmp(buf, s) == 0; } bool operator ==(int n) { return atoi(buf) == n; } size_t pos; char buf[64]; } line; int freq; int addr; int dataLine; int dataCount; int dataCurrent; int dataCksum; struct { uint8_t Major; uint8_t Minor; } version; };