Removed NOP for loop that breaks GCC4.
[goodfet] / firmware / include / command.h
1 /*! \file command.h
2   \author Travis Goodspeed
3   \brief Command codes and buffers.
4 */
5
6
7 #ifndef COMMAND_H
8 #define COMMAND_H
9
10 #include <stdint.h>
11
12 //Types
13 #define u8 unsigned char
14 #define u16 unsigned int
15 #define u32 unsigned long
16
17
18 #ifdef msp430x2274
19 //256 bytes, plus overhead
20 //For chips with very little RAM.
21 #define CMDDATALEN 0x104
22 //#warning Very little RAM.
23 #endif
24
25 #ifndef CMDDATALEN
26 //512 bytes
27 #define CMDDATALEN 0x204
28 //4k
29 //#define CMDDATALEN 0x1004
30 #endif
31
32 //! Global data buffer.
33 extern unsigned char cmddata[CMDDATALEN];
34 extern unsigned char silent;
35
36 #define cmddataword ((unsigned int*) cmddata)
37 #define cmddatalong ((unsigned long*) cmddata)
38 #define memorybyte ((char*)  0)
39 //#define memoryword ((unsigned int*)  0))
40
41 // Global Commands
42 #define READ  0x00
43 #define WRITE 0x01
44 #define PEEK  0x02
45 #define POKE  0x03
46 #define SETUP 0x10
47 #define START 0x20
48 #define STOP  0x21
49 #define CALL  0x30
50 #define EXEC  0x31
51 #define NOK   0x7E
52 #define OK    0x7F
53
54 #define DEBUGSTR 0xFF
55
56
57
58 //SPI commands
59 #define SPI_JEDEC 0x80
60 #define SPI_ERASE 0x81
61 #define SPI_RW_EM260 0x82
62
63 //OCT commands
64 #define OCT_CMP 0x90
65 #define OCT_RES 0x91
66
67 #ifdef GCC
68 #define WEAKDEF __attribute__ ((weak))
69 #else
70 //Compiler doesn't support weak linking. :(
71 #define WEAKDEF
72 #endif
73
74 //! Handle a command.  Defined in goodfet.c
75 void handle(uint8_t const app,
76                         uint8_t const verb,
77                         uint32_t const len);
78 //! Transmit a header.
79 void txhead(unsigned char app,
80             unsigned char verb,
81             unsigned long len);
82 //! Transmit data.
83 void txdata(unsigned char app,
84             unsigned char verb,
85             unsigned long len);
86 //! Transmit a string.
87 void txstring(unsigned char app,
88               unsigned char verb,
89               const char *str);
90
91 //! Receive a long.
92 unsigned long rxlong();
93 //! Receive a word.
94 unsigned int rxword();
95
96 //! Transmit a long.
97 void txlong(unsigned long l);
98 //! Transmit a word.
99 void txword(unsigned int l);
100
101 //! Transmit a debug sequence of bytes
102 void debugbytes(const char *bytes, unsigned int len);
103 //! Transmit a debug string.
104 void debugstr(const char *str);
105 //! brief Debug a hex word string.
106 void debughex(u16 v);
107 //! brief Debug a hex long string.
108 void debughex32(u32 v);
109
110 //! Delay for a count.
111 void delay(unsigned int count);
112 //! MSDelay
113 void msdelay(unsigned int ms);
114
115
116 //! Prepare Timer B; call before using delay_ms or delay_us.
117 void prep_timer();
118
119 //! Delay for specified number of milliseconds (given 16 MHz clock)
120 void delay_ms( unsigned int ms );
121
122 //! Delay for specified number of microseconds (given 16 MHz clock)
123 void delay_us( unsigned int us );
124
125 //! Delay for specified number of clock ticks (16 MHz clock implies 62.5 ns per tick).
126 void delay_ticks( unsigned int num_ticks );
127
128 #endif // COMMAND_H