SPI client refactoring and block read/write functions.
[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 // Monitor Commands
22 #define MONITOR_CHANGE_BAUD 0x80
23 #define MONITOR_RAM_PATTERN 0x90
24 #define MONITOR_RAM_DEPTH 0x91
25
26 //CHIPCON commands
27 #define CC_CHIP_ERASE 0x80
28 #define CC_WR_CONFIG 0x81
29 #define CC_RD_CONFIG 0x82
30 #define CC_GET_PC 0x83
31 #define CC_READ_STATUS 0x84
32 #define CC_SET_HW_BRKPNT 0x85
33 #define CC_HALT 0x86
34 #define CC_RESUME 0x87
35 #define CC_DEBUG_INSTR 0x88
36 #define CC_STEP_INSTR 0x89
37 #define CC_STEP_REPLACE 0x8a
38 #define CC_GET_CHIP_ID 0x8b
39 //CHIPCON macros
40 #define CC_READ_CODE_MEMORY 0x90
41 #define CC_READ_XDATA_MEMORY 0x91
42 #define CC_WRITE_XDATA_MEMORY 0x92
43 #define CC_SET_PC 0x93
44 #define CC_CLOCK_INIT 0x94
45 #define CC_WRITE_FLASH_PAGE 0x95
46 #define CC_READ_FLASH_PAGE 0x96
47 #define CC_MASS_ERASE_FLASH 0x97
48 #define CC_PROGRAM_FLASH 0x98
49
50 //JTAG commands
51 #define JTAG_IR_SHIFT 0x80
52 #define JTAG_DR_SHIFT 0x81
53 #define JTAG_DR_SHIFT20 0x91
54
55 //SPI commands
56 #define SPI_JEDEC 0x80
57 #define SPI_ERASE 0x81
58
59 //OCT commands
60 #define OCT_CMP 0x90
61 #define OCT_RES 0x91
62
63 //JTAG430 commands
64 #define JTAG430_HALTCPU 0xA0
65 #define JTAG430_RELEASECPU 0xA1
66 #define JTAG430_SETINSTRFETCH 0xC1
67 #define JTAG430_SETPC 0xC2
68 #define JTAG430_WRITEMEM 0xE0
69 #define JTAG430_WRITEFLASH 0xE1
70 #define JTAG430_READMEM 0xE2
71 #define JTAG430_ERASEFLASH 0xE3
72 #define JTAG430_ERASECHECK 0xE4
73 #define JTAG430_VERIFYMEM 0xE5
74 #define JTAG430_BLOWFUSE 0xE6
75 #define JTAG430_ISFUSEBLOWN 0xE7
76 #define JTAG430_COREIP_ID 0xF0
77 #define JTAG430_DEVICE_ID 0xF1
78
79 //! Handle a command.  Defined in goodfet.c
80 void handle(unsigned char app,
81             unsigned char verb,
82             unsigned  char len);
83
84 //! Transmit data.
85 void txdata(unsigned char app,
86             unsigned char verb,
87             unsigned char len);
88 //! Transmit a string.
89 void txstring(unsigned char app,
90               unsigned char verb,
91               const char *str);
92
93 //! Delay
94 void delay(unsigned int count);
95 //! MSDelay
96 void msdelay(unsigned int ms);
97
98
99 void monitorhandle(unsigned char, unsigned char, unsigned char);
100 void spihandle(unsigned char, unsigned char, unsigned char);
101 void i2chandle(unsigned char, unsigned char, unsigned char);
102 void cchandle(unsigned char, unsigned char, unsigned char);
103 void jtaghandle(unsigned char, unsigned char, unsigned char);
104 void jtag430handle(unsigned char, unsigned char, unsigned char);
105 void jtag430x2handle(unsigned char app, unsigned char verb,
106                      unsigned char len);
107