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
00001 // BaseEmuISP.h 2016/3/25 00002 #pragma once 00003 #include <stdint.h> 00004 #include "myvector.h" 00005 #include "mystring.h" 00006 00007 typedef myvector<char*> vec_charPtr_t; 00008 typedef myvector<int> vec_int_t; 00009 typedef myvector<uint8_t> vec_byte_t; 00010 typedef mystring string_t; 00011 00012 enum Mode_t { 00013 M_RESET = 0, 00014 M_SYNC, 00015 M_CMD, 00016 M_CMD_W_DATA, 00017 M_CMD_R_DATA, 00018 M_CMD_J, 00019 M_CMD_K, 00020 M_CMD_N, 00021 M_CMD_S, 00022 }; 00023 00024 enum ReturnCode_t { 00025 CMD_SUCCESS = 0, 00026 INVALID_COMMAND = 1, 00027 SRC_ADDR_ERROR = 2, 00028 DST_ADDR_ERROR = 3, 00029 SRC_ADDR_NOT_MAPPED = 4, 00030 DST_ADDR_NOT_MAPPED = 5, 00031 COUNT_ERROR = 6, 00032 INVALID_SECTOR = 7, 00033 SECTOR_NOT_BLANK = 8, 00034 SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION = 9, 00035 COMPARE_ERROR = 10, 00036 BUSY = 11, 00037 PARAM_ERROR = 12, 00038 ADDR_ERROR = 13, 00039 ADDR_NOT_MAPPED = 14, 00040 CMD_LOCKED = 15, 00041 INVALID_CODE = 16, 00042 INVALID_BAUD_RATE = 17, 00043 INVALID_STOP_BIT = 18, 00044 CODE_READ_PROTECTIN_ENABLED = 19, 00045 }; 00046 00047 class BaseEmuISP { 00048 public: 00049 void Reset(); 00050 void Poll(); 00051 00052 protected: 00053 virtual int BootCodeVersion() { return 4<<8|13; } // 4.13 00054 virtual int PartID() { return 0x00008100; } // LPC810M021FN8 00055 virtual bool UuencodeMode() { return false; } 00056 virtual bool WriteData(int addr, int c) { return false; } 00057 virtual int ReadData(int addr) { return 0; } 00058 virtual bool CopyData(int dst, int src, int count) { return false; } 00059 virtual bool Compare(int addr1, int addr2, int count) { return true; } 00060 virtual bool Prepare(int sector) { return true; } 00061 virtual bool Erase(int sector) { return true; } 00062 virtual bool Blank(int sector) { return true; } 00063 virtual int Getch() = 0; 00064 virtual void Putch(int c) = 0; 00065 virtual void DebugPutch(int c) { return; } 00066 00067 private: 00068 bool sync(); 00069 ReturnCode_t cmd(const char* s); 00070 ReturnCode_t cmd_u(vec_int_t ¶m); 00071 ReturnCode_t cmd_b(vec_int_t ¶m); 00072 ReturnCode_t cmd_a(vec_int_t ¶m); 00073 ReturnCode_t cmd_w(vec_int_t ¶m); 00074 ReturnCode_t cmd_r(vec_int_t ¶m); 00075 ReturnCode_t cmd_p(vec_int_t ¶m); 00076 ReturnCode_t cmd_c(vec_int_t ¶m); 00077 ReturnCode_t cmd_g(vec_int_t ¶m); 00078 ReturnCode_t cmd_e(vec_int_t ¶m); 00079 ReturnCode_t cmd_i(vec_int_t ¶m); 00080 ReturnCode_t cmd_j(vec_int_t ¶m); 00081 ReturnCode_t cmd_k(vec_int_t ¶m); 00082 ReturnCode_t cmd_m(vec_int_t ¶m); 00083 ReturnCode_t cmd_n(vec_int_t ¶m); 00084 ReturnCode_t cmd_s(vec_int_t ¶m); 00085 bool cmd_w_data(); 00086 bool cmd_r_data(); 00087 void putln(const char *s); 00088 void debugPrintf(const char *format, ...); 00089 Mode_t mode; 00090 int seq; 00091 bool echoFlag; 00092 bool lockFlag; 00093 string_t line; 00094 bool lineProc(); 00095 int freq; 00096 int addr; 00097 struct { 00098 vec_byte_t Buf; 00099 int Line; 00100 int Count; 00101 int Current; 00102 int Cksum; 00103 } data; 00104 struct { 00105 uint8_t Major; 00106 uint8_t Minor; 00107 } version; 00108 }; 00109
Generated on Wed Jan 17 2024 08:13:46 by
1.7.2