Trying to clean up port.
[goodfet] / firmware / include / command.h
1 /*! \file command.h
2   \author Travis Goodspeed
3   \brief Command codes and buffers.
4 */
5
6
7 //Types
8 #define u8 unsigned char
9 #define u16 unsigned int
10 #define u32 unsigned long
11
12
13 #ifdef msp430x2274
14 //256 bytes, plus overhead
15 //For chips with very little RAM.
16 #define CMDDATALEN 0x104
17 //#warning Very little RAM.
18 #endif
19
20 #ifndef CMDDATALEN
21 //512 bytes
22 #define CMDDATALEN 0x204
23 //4k
24 //#define CMDDATALEN 0x1004
25 #endif
26
27 //! Global data buffer.
28 extern unsigned char cmddata[CMDDATALEN];
29 extern unsigned char silent;
30
31 #define cmddataword ((unsigned int*) cmddata)
32 #define cmddatalong ((unsigned long*) cmddata)
33 #define memorybyte ((unsigned char*) 0)
34 #define memoryword ((unsigned int*) 0)
35
36 // Global Commands
37 #define READ  0x00
38 #define WRITE 0x01
39 #define PEEK  0x02
40 #define POKE  0x03
41 #define SETUP 0x10
42 #define START 0x20
43 #define STOP  0x21
44 #define CALL  0x30
45 #define EXEC  0x31
46 #define NOK   0x7E
47 #define OK    0x7F
48
49 #define DEBUGSTR 0xFF
50
51 // Monitor Commands
52 #define MONITOR_CHANGE_BAUD 0x80
53 #define MONITOR_RAM_PATTERN 0x90
54 #define MONITOR_RAM_DEPTH 0x91
55
56 #define MONITOR_DIR 0xA0
57 #define MONITOR_OUT 0xA1
58 #define MONITOR_IN  0xA2
59
60 #define MONITOR_SILENT 0xB0
61
62 #define MONITOR_READBUF 0xC0
63 #define MONITOR_WRITEBUF 0xC1
64 #define MONITOR_SIZEBUF 0xC2
65
66
67
68
69 //SPI commands
70 #define SPI_JEDEC 0x80
71 #define SPI_ERASE 0x81
72
73 //OCT commands
74 #define OCT_CMP 0x90
75 #define OCT_RES 0x91
76
77 #ifdef GCC
78 #define WEAKDEF __attribute__ ((weak))
79 #else
80 //Compiler doesn't support weak linking. :(
81 #define WEAKDEF
82 #endif
83
84 //! Handle a plugin, weak-linked to error.
85 extern int pluginhandle(unsigned char app,
86                         unsigned char verb,
87                         unsigned int len)
88   WEAKDEF;
89
90
91 //! Handle a command.  Defined in goodfet.c
92 void handle(unsigned char app,
93             unsigned char verb,
94             unsigned long len);
95 //! Transmit a header.
96 void txhead(unsigned char app,
97             unsigned char verb,
98             unsigned long len);
99 //! Transmit data.
100 void txdata(unsigned char app,
101             unsigned char verb,
102             unsigned long len);
103 //! Transmit a string.
104 void txstring(unsigned char app,
105               unsigned char verb,
106               const char *str);
107
108 //! Receive a long.
109 unsigned long rxlong();
110 //! Receive a word.
111 unsigned int rxword();
112
113 //! Transmit a long.
114 void txlong(unsigned long l);
115 //! Transmit a word.
116 void txword(unsigned int l);
117
118 //! Transmit a debug string.
119 void debugstr(const char *str);
120 //! brief Debug a hex word string.
121 void debughex(u16 v);
122
123 //! Delay for a count.
124 void delay(unsigned int count);
125 //! MSDelay
126 void msdelay(unsigned int ms);
127
128
129 void monitorhandle(unsigned char, unsigned char, unsigned long);
130 void spihandle(unsigned char, unsigned char, unsigned long);
131 void i2chandle(unsigned char, unsigned char, unsigned long) WEAKDEF;
132 void cchandle(unsigned char, unsigned char, unsigned long) WEAKDEF;
133 void jtaghandle(unsigned char, unsigned char, unsigned long);
134 void jtag430handle(unsigned char, unsigned char, unsigned long);
135 void ejtaghandle(unsigned char, unsigned char, unsigned long);
136
137 void jtag430x2handle(unsigned char app, unsigned char verb,
138                      unsigned long len);
139
140 void avrhandle(unsigned char app,
141                unsigned char verb,
142                unsigned long len);