Atmel JEDEC info for SPI Flash.
[goodfet] / firmware / lib / command.c
1 /*! \file command.c
2   \author Travis Goodspeed
3   \brief These functions manage command interpretation.
4 */
5
6 #include "command.h"
7 #include "platform.h"
8 #include <string.h>
9
10 unsigned char cmddata[256];
11
12 //! Transmit a string.
13 void txstring(unsigned char app,
14               unsigned char verb,
15               const char *str){
16   unsigned char len=strlen(str);
17   serial_tx(app);
18   serial_tx(verb);
19   serial_tx(len);
20   while(len--)
21     serial_tx(*(str++));
22 }
23
24 /*! \brief Transmit a debug string.
25   
26   Transmits a debugging string that is to be printed
27   out of line by the client.  This is just for record-keeping;
28   it is not considered a proper reply to a query.
29  */
30 void debugstr(const char *str){
31   txstring(0xFF,0xFF,str);
32 }
33
34
35 //! Transmit data.
36 void txdata(unsigned char app,
37             unsigned char verb,
38             unsigned char len){
39   unsigned int i=0;
40   serial_tx(app);
41   serial_tx(verb);
42   serial_tx(len);
43   for(i=0;i<len;i++){
44     serial_tx(cmddata[i]);
45   }
46 }
47
48 //Be very careful changing delay().
49 //It was chosen poorly by trial and error.
50
51 //! Delay for a count.
52 void delay(unsigned int count){
53   volatile unsigned int i=count;
54   while(i--) asm("nop");
55 }
56 //! MSDelay
57 void msdelay(unsigned int ms){
58   volatile unsigned int i,j;
59   i=100;
60   while(i--){
61     j=ms;
62     while(j--) asm("nop");
63   }
64   //Using TimerA might be cleaner.
65 }