| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#define MESSAGE_START 0x1b |
| 54 |
#define TOKEN 0x0e |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
#define MAX_MESSAGE 100000 |
| 65 |
|
| 66 |
|
| 67 |
#define CMND_CHIP_ERASE 0x13 |
| 68 |
#define CMND_CLEAR_EVENTS 0x22 |
| 69 |
#define CMND_CLR_BREAK 0x1A |
| 70 |
#define CMND_ENTER_PROGMODE 0x14 |
| 71 |
#define CMND_ERASEPAGE_SPM 0x0D |
| 72 |
#define CMND_FORCED_STOP 0x0A |
| 73 |
#define CMND_GET_BREAK 0x12 |
| 74 |
#define CMND_GET_PARAMETER 0x03 |
| 75 |
#define CMND_GET_SIGN_ON 0x01 |
| 76 |
#define CMND_GET_SYNC 0x0f |
| 77 |
#define CMND_GO 0x08 |
| 78 |
#define CMND_LEAVE_PROGMODE 0x15 |
| 79 |
#define CMND_READ_MEMORY 0x05 |
| 80 |
#define CMND_READ_PC 0x07 |
| 81 |
#define CMND_RESET 0x0B |
| 82 |
#define CMND_RESTORE_TARGET 0x23 |
| 83 |
#define CMND_RUN_TO_ADDR 0x1C |
| 84 |
#define CMND_SELFTEST 0x10 |
| 85 |
#define CMND_SET_BREAK 0x11 |
| 86 |
#define CMND_SET_DEVICE_DESCRIPTOR 0x0C |
| 87 |
#define CMND_SET_N_PARAMETERS 0x16 |
| 88 |
#define CMND_SET_PARAMETER 0x02 |
| 89 |
#define CMND_SIGN_OFF 0x00 |
| 90 |
#define CMND_SINGLE_STEP 0x09 |
| 91 |
#define CMND_SPI_CMD 0x1D |
| 92 |
#define CMND_WRITE_MEMORY 0x04 |
| 93 |
#define CMND_WRITE_PC 0x06 |
| 94 |
#define CMND_XMEGA_ERASE 0x34 |
| 95 |
|
| 96 |
|
| 97 |
#define RSP_DEBUGWIRE_SYNC_FAILED 0xAC |
| 98 |
#define RSP_FAILED 0xA0 |
| 99 |
#define RSP_GET_BREAK 0x83 |
| 100 |
#define RSP_ILLEGAL_BREAKPOINT 0xA8 |
| 101 |
#define RSP_ILLEGAL_COMMAND 0xAA |
| 102 |
#define RSP_ILLEGAL_EMULATOR_MODE 0xA4 |
| 103 |
#define RSP_ILLEGAL_JTAG_ID 0xA9 |
| 104 |
#define RSP_ILLEGAL_MCU_STATE 0xA5 |
| 105 |
#define RSP_ILLEGAL_MEMORY_TYPE 0xA2 |
| 106 |
#define RSP_ILLEGAL_MEMORY_RANGE 0xA3 |
| 107 |
#define RSP_ILLEGAL_PARAMETER 0xA1 |
| 108 |
#define RSP_ILLEGAL_POWER_STATE 0xAD |
| 109 |
#define RSP_ILLEGAL_VALUE 0xA6 |
| 110 |
#define RSP_MEMORY 0x82 |
| 111 |
#define RSP_NO_TARGET_POWER 0xAB |
| 112 |
#define RSP_OK 0x80 |
| 113 |
#define RSP_PARAMETER 0x81 |
| 114 |
#define RSP_PC 0x84 |
| 115 |
#define RSP_SELFTEST 0x85 |
| 116 |
#define RSP_SET_N_PARAMETERS 0xA7 |
| 117 |
#define RSP_SIGN_ON 0x86 |
| 118 |
#define RSP_SPI_DATA 0x88 |
| 119 |
|
| 120 |
|
| 121 |
#define EVT_BREAK 0xE0 |
| 122 |
#define EVT_DEBUG 0xE6 |
| 123 |
#define EVT_ERROR_PHY_FORCE_BREAK_TIMEOUT 0xE2 |
| 124 |
#define EVT_ERROR_PHY_MAX_BIT_LENGTH_DIFF 0xED |
| 125 |
#define EVT_ERROR_PHY_OPT_RECEIVE_TIMEOUT 0xF9 |
| 126 |
#define EVT_ERROR_PHY_OPT_RECEIVED_BREAK 0xFA |
| 127 |
#define EVT_ERROR_PHY_RECEIVED_BREAK 0xF8 |
| 128 |
#define EVT_ERROR_PHY_RECEIVE_TIMEOUT 0xF7 |
| 129 |
#define EVT_ERROR_PHY_RELEASE_BREAK_TIMEOUT 0xE3 |
| 130 |
#define EVT_ERROR_PHY_SYNC_OUT_OF_RANGE 0xF5 |
| 131 |
#define EVT_ERROR_PHY_SYNC_TIMEOUT 0xF0 |
| 132 |
#define EVT_ERROR_PHY_SYNC_TIMEOUT_BAUD 0xF4 |
| 133 |
#define EVT_ERROR_PHY_SYNC_WAIT_TIMEOUT 0xF6 |
| 134 |
#define EVT_RESULT_PHY_NO_ACTIVITY 0xFB |
| 135 |
#define EVT_EXT_RESET 0xE7 |
| 136 |
#define EVT_ICE_POWER_ERROR_STATE 0xEA |
| 137 |
#define EVT_ICE_POWER_OK 0xEB |
| 138 |
#define EVT_IDR_DIRTY 0xEC |
| 139 |
#define EVT_NONE 0xEF |
| 140 |
#define EVT_PDSB_BREAK 0xF2 |
| 141 |
#define EVT_PDSMB_BREAK 0xF3 |
| 142 |
#define EVT_PROGRAM_BREAK 0xF1 |
| 143 |
#define EVT_RUN 0xE1 |
| 144 |
#define EVT_TARGET_POWER_OFF 0xE5 |
| 145 |
#define EVT_TARGET_POWER_ON 0xE4 |
| 146 |
#define EVT_TARGET_SLEEP 0xE8 |
| 147 |
#define EVT_TARGET_WAKEUP 0xE9 |
| 148 |
|
| 149 |
|
| 150 |
#define MTYPE_IO_SHADOW 0x30 |
| 151 |
#define MTYPE_SRAM 0x20 |
| 152 |
#define MTYPE_EEPROM 0x22 |
| 153 |
#define MTYPE_EVENT 0x60 |
| 154 |
#define MTYPE_SPM 0xA0 |
| 155 |
#define MTYPE_FLASH_PAGE 0xB0 |
| 156 |
#define MTYPE_EEPROM_PAGE 0xB1 |
| 157 |
#define MTYPE_FUSE_BITS 0xB2 |
| 158 |
#define MTYPE_LOCK_BITS 0xB3 |
| 159 |
#define MTYPE_SIGN_JTAG 0xB4 |
| 160 |
#define MTYPE_OSCCAL_BYTE 0xB5 |
| 161 |
#define MTYPE_CAN 0xB6 |
| 162 |
|
| 163 |
|
| 164 |
#define PAR_HW_VERSION 0x01 |
| 165 |
#define PAR_FW_VERSION 0x02 |
| 166 |
#define PAR_EMULATOR_MODE 0x03 |
| 167 |
# define EMULATOR_MODE_DEBUGWIRE 0x00 |
| 168 |
# define EMULATOR_MODE_JTAG 0x01 |
| 169 |
# define EMULATOR_MODE_UNKNOWN 0x02 |
| 170 |
# define EMULATOR_MODE_SPI 0x03 |
| 171 |
#define PAR_IREG 0x04 |
| 172 |
#define PAR_BAUD_RATE 0x05 |
| 173 |
# define PAR_BAUD_2400 0x01 |
| 174 |
# define PAR_BAUD_4800 0x02 |
| 175 |
# define PAR_BAUD_9600 0x03 |
| 176 |
# define PAR_BAUD_19200 0x04 |
| 177 |
# define PAR_BAUD_38400 0x05 |
| 178 |
# define PAR_BAUD_57600 0x06 |
| 179 |
# define PAR_BAUD_115200 0x07 |
| 180 |
# define PAR_BAUD_14400 0x08 |
| 181 |
#define PAR_OCD_VTARGET 0x06 |
| 182 |
#define PAR_OCD_JTAG_CLK 0x07 |
| 183 |
#define PAR_OCD_BREAK_CAUSE 0x08 |
| 184 |
#define PAR_TIMERS_RUNNING 0x09 |
| 185 |
#define PAR_BREAK_ON_CHANGE_FLOW 0x0A |
| 186 |
#define PAR_BREAK_ADDR1 0x0B |
| 187 |
#define PAR_BREAK_ADDR2 0x0C |
| 188 |
#define PAR_COMBBREAKCTRL 0x0D |
| 189 |
#define PAR_JTAGID 0x0E |
| 190 |
#define PAR_UNITS_BEFORE 0x0F |
| 191 |
#define PAR_UNITS_AFTER 0x10 |
| 192 |
#define PAR_BIT_BEFORE 0x11 |
| 193 |
#define PAR_BIT_ATER 0x12 |
| 194 |
#define PAR_EXTERNAL_RESET 0x13 |
| 195 |
#define PAR_FLASH_PAGE_SIZE 0x14 |
| 196 |
#define PAR_EEPROM_PAGE_SIZE 0x15 |
| 197 |
#define PAR_UNUSED1 0x16 |
| 198 |
#define PAR_PSB0 0x17 |
| 199 |
#define PAR_PSB1 0x18 |
| 200 |
#define PAR_PROTOCOL_DEBUG_EVENT 0x19 |
| 201 |
#define PAR_MCU_STATE 0x1A |
| 202 |
# define STOPPED 0x00 |
| 203 |
# define RUNNING 0x01 |
| 204 |
# define PROGRAMMING 0x02 |
| 205 |
#define PAR_DAISY_CHAIN_INFO 0x1B |
| 206 |
#define PAR_BOOT_ADDRESS 0x1C |
| 207 |
#define PAR_TARGET_SIGNATURE 0x1D |
| 208 |
#define PAR_DEBUGWIRE_BAUDRATE 0x1E |
| 209 |
#define PAR_PROGRAM_ENTRY_POINT 0x1F |
| 210 |
#define PAR_PACKET_PARSING_ERRORS 0x40 |
| 211 |
#define PAR_VALID_PACKETS_RECEIVED 0x41 |
| 212 |
#define PAR_INTERCOMMUNICATION_TX_FAILURES 0x42 |
| 213 |
#define PAR_INTERCOMMUNICATION_RX_FAILURES 0x43 |
| 214 |
#define PAR_CRC_ERRORS 0x44 |
| 215 |
#define PAR_POWER_SOURCE 0x45 |
| 216 |
# define POWER_EXTERNAL 0x00 |
| 217 |
# define POWER_USB 0x01 |
| 218 |
#define PAR_CAN_FLAG 0x22 |
| 219 |
# define DONT_READ_CAN_MAILBOX 0x00 |
| 220 |
# define READ_CAN_MAILBOX 0x01 |
| 221 |
#define PAR_ENABLE_IDR_IN_RUN_MODE 0x23 |
| 222 |
# define ACCESS_OSCCAL 0x00 |
| 223 |
# define ACCESS_IDR 0x01 |
| 224 |
#define PAR_ALLOW_PAGEPROGRAMMING_IN_SCANCHAIN 0x24 |
| 225 |
# define PAGEPROG_NOT_ALLOWED 0x00 |
| 226 |
# define PAGEPROG_ALLOWED 0x01 |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
struct device_descriptor |
| 236 |
{ |
| 237 |
unsigned char ucReadIO[8]; |
| 238 |
unsigned char ucReadIOShadow[8]; |
| 239 |
unsigned char ucWriteIO[8]; |
| 240 |
unsigned char ucWriteIOShadow[8]; |
| 241 |
unsigned char ucReadExtIO[52]; |
| 242 |
unsigned char ucReadIOExtShadow[52]; |
| 243 |
unsigned char ucWriteExtIO[52]; |
| 244 |
unsigned char ucWriteIOExtShadow[52]; |
| 245 |
unsigned char ucIDRAddress; |
| 246 |
unsigned char ucSPMCRAddress; |
| 247 |
unsigned char ucRAMPZAddress; |
| 248 |
|
| 249 |
unsigned char uiFlashPageSize[2]; |
| 250 |
|
| 251 |
unsigned char ucEepromPageSize; |
| 252 |
unsigned char ulBootAddress[4]; |
| 253 |
unsigned char uiUpperExtIOLoc[2]; |
| 254 |
|
| 255 |
unsigned char ulFlashSize[4]; |
| 256 |
unsigned char ucEepromInst[20]; |
| 257 |
unsigned char ucFlashInst[3]; |
| 258 |
unsigned char ucSPHaddr; |
| 259 |
unsigned char ucSPLaddr; |
| 260 |
|
| 261 |
unsigned char uiFlashpages[2]; |
| 262 |
unsigned char ucDWDRAddress; |
| 263 |
unsigned char ucDWBasePC; |
| 264 |
|
| 265 |
unsigned char ucAllowFullPageBitstream; |
| 266 |
|
| 267 |
unsigned char uiStartSmallestBootLoaderSection[2]; |
| 268 |
|
| 269 |
unsigned char EnablePageProgramming; |
| 270 |
|
| 271 |
unsigned char ucCacheType; |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
unsigned char uiSramStartAddr[2]; |
| 276 |
unsigned char ucResetType; |
| 277 |
|
| 278 |
unsigned char ucPCMaskExtended; |
| 279 |
unsigned char ucPCMaskHigh; |
| 280 |
unsigned char ucEindAddress; |
| 281 |
|
| 282 |
unsigned char EECRAddress[2]; |
| 283 |
}; |