Support for debugging strings, closer to a clean MSP430X2 implementation.
[goodfet] / firmware / include / command.h
1 // Command handling functions.
2
3 //! Global data buffer.
4 extern unsigned char cmddata[256];
5 #define cmddataword ((unsigned int*) cmddata)
6 #define cmddatalong ((unsigned long*) cmddata)
7 #define memorybyte ((unsigned char*) 0)
8 #define memoryword ((unsigned int*) 0)
9
10 // Global Commands
11 #define READ  0x00
12 #define WRITE 0x01
13 #define PEEK  0x02
14 #define POKE  0x03
15 #define SETUP 0x10
16 #define START 0x20
17 #define STOP  0x21
18 #define NOK   0x7E
19 #define OK    0x7F
20
21 #define DEBUGSTR 0xFF
22
23 // Monitor Commands
24 #define MONITOR_CHANGE_BAUD 0x80
25 #define MONITOR_RAM_PATTERN 0x90
26 #define MONITOR_RAM_DEPTH 0x91
27
28 #define MONITOR_DIR 0xA0
29 #define MONITOR_OUT 0xA1
30 #define MONITOR_IN  0xA2
31
32 //CHIPCON commands
33 #define CC_CHIP_ERASE 0x80
34 #define CC_WR_CONFIG 0x81
35 #define CC_RD_CONFIG 0x82
36 #define CC_GET_PC 0x83
37 #define CC_READ_STATUS 0x84
38 #define CC_SET_HW_BRKPNT 0x85
39 #define CC_HALT 0x86
40 #define CC_RESUME 0x87
41 #define CC_DEBUG_INSTR 0x88
42 #define CC_STEP_INSTR 0x89
43 #define CC_STEP_REPLACE 0x8a
44 #define CC_GET_CHIP_ID 0x8b
45 //CHIPCON macros
46 #define CC_READ_CODE_MEMORY 0x90
47 #define CC_READ_XDATA_MEMORY 0x91
48 #define CC_WRITE_XDATA_MEMORY 0x92
49 #define CC_SET_PC 0x93
50 #define CC_CLOCK_INIT 0x94
51 #define CC_WRITE_FLASH_PAGE 0x95
52 #define CC_READ_FLASH_PAGE 0x96
53 #define CC_MASS_ERASE_FLASH 0x97
54 #define CC_PROGRAM_FLASH 0x98
55
56 //JTAG commands
57 #define JTAG_IR_SHIFT 0x80
58 #define JTAG_DR_SHIFT 0x81
59 #define JTAG_DR_SHIFT20 0x91
60
61 //SPI commands
62 #define SPI_JEDEC 0x80
63 #define SPI_ERASE 0x81
64
65 //OCT commands
66 #define OCT_CMP 0x90
67 #define OCT_RES 0x91
68
69 //JTAG430 commands
70 #define JTAG430_HALTCPU 0xA0
71 #define JTAG430_RELEASECPU 0xA1
72 #define JTAG430_SETINSTRFETCH 0xC1
73 #define JTAG430_SETPC 0xC2
74 #define JTAG430_WRITEMEM 0xE0
75 #define JTAG430_WRITEFLASH 0xE1
76 #define JTAG430_READMEM 0xE2
77 #define JTAG430_ERASEFLASH 0xE3
78 #define JTAG430_ERASECHECK 0xE4
79 #define JTAG430_VERIFYMEM 0xE5
80 #define JTAG430_BLOWFUSE 0xE6
81 #define JTAG430_ISFUSEBLOWN 0xE7
82 #define JTAG430_COREIP_ID 0xF0
83 #define JTAG430_DEVICE_ID 0xF1
84
85 //! Handle a command.  Defined in goodfet.c
86 void handle(unsigned char app,
87             unsigned char verb,
88             unsigned  char len);
89
90 //! Transmit data.
91 void txdata(unsigned char app,
92             unsigned char verb,
93             unsigned char len);
94 //! Transmit a string.
95 void txstring(unsigned char app,
96               unsigned char verb,
97               const char *str);
98 //! Transmit a debug string.
99 void debugstr(const char *str);
100
101 //! Delay
102 void delay(unsigned int count);
103 //! MSDelay
104 void msdelay(unsigned int ms);
105
106
107 void monitorhandle(unsigned char, unsigned char, unsigned char);
108 void spihandle(unsigned char, unsigned char, unsigned char);
109 void i2chandle(unsigned char, unsigned char, unsigned char);
110 void cchandle(unsigned char, unsigned char, unsigned char);
111 void jtaghandle(unsigned char, unsigned char, unsigned char);
112 void jtag430handle(unsigned char, unsigned char, unsigned char);
113 void jtag430x2handle(unsigned char app, unsigned char verb,
114                      unsigned char len);
115