00001 #ifndef _COMMANDS_H_
00002 #define _COMMANDS_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #define MAX_PACKET_SIZE (13*8) // Maximum USB packet size - entire packet! - Limited by Z-Page RAM - multiple of 8 is nice
00047
00048
00049
00050
00051 #define CMD_OK 0 // deprecated
00052 #undef CMD_ERR_SUM // 1 deprecated, USB has CRC16 in place
00053 #define CMD_FAILED 2 // command execution failed (incorrect parameters,
00054
00055 #define CMD_UNKNOWN 3 // unknown command
00056
00057 #define CMD_DEBUG 8 // Debugging commands (parameter determines actual command)
00058 #define CMD_OPTION 10 // Set/clear various options (only has affect after next CMD_SET_TARGET)
00059
00060
00061 #undef CMD_GET_DESC // 10 deprecated
00062 #undef CMD_GET_SWSER // 11 deprecated
00063 #define CMD_GET_VER 12 // returns 16 bit HW/SW version number, (major & minor revision
00064
00065 #define CMD_GET_LAST_STATUS 13 // returns status of the previous command
00066 #define CMD_SET_BOOT 14 // request bootloader firmware upgrade on next power-up, parameters: 'B','O','O','T', returns: none
00067
00068
00069 #define CMD_SET_TARGET 30 // set target, 8bit parameter: 00=HC12/HCS12(default), 01=HCS08
00070 #define CMD_CONNECT 31 // try to connect to the target
00071 #undef CMD_READ_SPEED // 32 deprecated, speed has higher resolution now
00072 #define CMD_RESET 33 // 8bit parameter: 0=reset to Special Mode, 1=reset to Normal mode
00073 #define CMD_GET_STATUS 34 // returns 16bit status word:
00074
00075
00076
00077
00078
00079 #define CMD_READ_BD 35 // parameter: 16-bit address, returns 8-bit value read from address;
00080
00081 #define CMD_WRITE_BD 36 // parameter: 16-bit address, 8-bit value to write;
00082
00083
00084 #undef CMD_GO // deprecated
00085 #undef CMD_STEP // deprecated
00086 #define CMD_HALT 39 // stop the CPU and bring it into background mode
00087 #define CMD_SET_SPEED 40 // deprecated
00088 #define CMD_READ_SPEED1 41 // read speed of the target: returns 16-bit tick count
00089 #define CMD_GO1 42 // start code execution
00090 #define CMD_STEP1 44 // perform single step
00091 #define CMD_SET_SPEED1 46 // sets-up the BDM interface for a new bit rate & tries
00092
00093
00094
00095
00096 #define CMD_READ_8 50 // parameter 16bit address, returns 8bit value read from address
00097 #define CMD_READ_16 51 // parameter 16bit address, returns 16bit value read from address
00098 #undef CMD_READ_BLOCK // 52 deprecated
00099 #define CMD_READ_REGS 53 // reads registers, returns 16bit values:
00100
00101
00102 #undef CMD_READ_BLOCK_FAST // 54 deprecated
00103 #define CMD_READ_BLOCK1 55 // parameter 16bit address, 8bit count of bytes to read,
00104
00105
00106
00107 #define CMD_WRITE_8 60 // parameter 16bit address, 8bit value to write
00108 #define CMD_WRITE_16 61 // parameter 16bit address, 16bit value to write
00109 #undef CMD_WRITE_BLOCK // 62 deprecated
00110 #undef CMD_WRITE_REGS // 63 deprecated
00111 #undef CMD_WRITE_BLOCK_FAST // 64 deprecated
00112 #define CMD_WRITE_BLOCK1 65 // parameters: 16bit address, 8bit count of bytes,
00113
00114
00115
00116
00117
00118
00119
00120 #define CMD_WRITE_REG_PC 80 // parameter: 16-bit PC value
00121 #define CMD_WRITE_REG_SP 81 // parameter: 16-bit SP value
00122 #define CMD_WRITE_REG_X 82 // parameter: 16-bit IX (H:X) value
00123 #define CMD_WRITE_REG_Y 83 // parameter: 16-bit IY value
00124 #define CMD_WRITE_REG_D 84 // parameter: 16-bit B:A (x:A) value
00125 #define CMD_WRITE_REG_CCR 85 // parameter: 16-bit CCR (x:CCR) value
00126
00127
00128 #define CMD_CF_READ_CSR2 86
00129 #define CMD_CF_READ_CSR3 87
00130 #define CMD_CF_WRITE_CSR2 88
00131 #define CMD_CF_WRITE_CSR3 89
00132 #define CMD_CF_READ_REG 90
00133 #define CMD_CF_READ_CREG 91
00134 #define CMD_CF_READ_DREG 92
00135 #define CMD_CF_READ_XCSR 93
00136 #define CMD_CF_WRITE_REG 94
00137 #define CMD_CF_WRITE_CREG 95
00138 #define CMD_CF_WRITE_DREG 96
00139 #define CMD_CF_READ_MEM 97
00140 #define CMD_CF_WRITE_MEM 98
00141 #define CMD_CF_WRITE_XCSR 99
00142
00143
00144 #define CMD_READ_STATUS 100
00145 #define CMD_WRITE_CONTROL 101
00146 #define CMD_WRITE_BKPT 102
00147 #define CMD_READ_BKPT 103
00148
00149
00150 #define CMD_READ_SPC 104
00151 #define CMD_WRITE_SPC 105
00152 #define CMD_READ_CCR_PC 106
00153 #define CMD_WRITE_CCR_PC 107
00154 #define CMD_READ_BLOCK 108
00155 #define CMD_WRITE_BLOCK 109
00156 #define CMD_MASS_ERASE 110
00157 #define CMD_VPPOFF 111
00158 #define CMD_RS08_POG 112
00159 #define CMD_FLASH_DLSTART 113
00160 #define CMD_FLASH_DLEND 114
00161 #define TCMD_NEXT_DLDATA 115
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 enum {
00180 BDM_RC_OK = 0,
00181 BDM_RC_BUSY = 1,
00182 BDM_RC_OVERRUN = 2,
00183 BDM_RC_ILLEGAL_PARAMS = 3,
00184 BDM_RC_ILLEGAL_COMMAND = 4,
00185 BDM_RC_NO_CONNECTION = 5,
00186
00187 BDM_RC_UNKNOWN_TARGET = 11,
00188 BDM_RC_NO_TX_ROUTINE = 12,
00189 BDM_RC_NO_RX_ROUTINE = 13,
00190 BDM_RC_BDM_EN_FAILED = 14,
00191 BDM_RC_RESET_TIMEOUT = 15,
00192 BDM_RC_BKGD_TIMEOUT = 16,
00193 BDM_RC_SYNC_TIMEOUT = 17,
00194 BDM_RC_UNKNOWN_SPEED = 18,
00195 BDM_RC_WRONG_PROGRAMMING_MODE = 19,
00196 BDM_RC_FLASH_PROGRAMING_BUSY = 20,
00197 BDM_RC_VDD_NOT_REMOVED = 21,
00198 BDM_RC_VDD_NOT_PRESENT = 22,
00199 BDM_RC_VDD_WRONG_MODE = 23,
00200 };
00201
00202 #if (DEBUG&DEBUG_COMMANDS)
00203
00204 enum {
00205 BDM_DBG_ACKN = 0,
00206 BDM_DBG_SYNC = 1,
00207 BDM_DBG_TESTPORT = 2,
00208 BDM_DBG_USBDISCONNECT = 3,
00209 BDM_DBG_STACKSIZE = 4,
00210 BDM_DBG_VPP_OFF = 5,
00211 BDM_DBG_VPP_ON = 6,
00212 BDM_DBG_FLASH12V_OFF = 7,
00213 BDM_DBG_FLASH12V_ON = 8,
00214 BDM_DBG_VDD_OFF = 9,
00215 BDM_DBG_VDD3_ON = 10,
00216 BDM_DBG_VDD5_ON = 11,
00217 BDM_DBG_CYCLE_POWER = 12,
00218 BDM_DBG_MEASURE_VDD = 13,
00219 };
00220 #endif
00221
00222
00223
00224 enum {
00225 BDM_CAP_RESET = (1<<0),
00226 BDM_CAP_FLASH = (1<<1),
00227 BDM_CAP_VDDCONTROL = (1<<2),
00228 BDM_CAP_VDDSENSE = (1<<3),
00229 };
00230
00231
00232 #endif