2 \author Travis Goodspeed
3 \brief These functions manage command interpretation.
10 unsigned char cmddata[CMDDATALEN];
11 unsigned char silent=0;
13 //! Transmit a string.
14 void txstring(unsigned char app,
17 unsigned long len=strlen(str);
23 /*! \brief Transmit a debug string.
25 Transmits a debugging string that is to be printed
26 out of line by the client. This is just for record-keeping;
27 it is not considered a proper reply to a query.
29 void debugstr(const char *str){
30 txstring(0xFF,0xFF,str);
33 //! brief Debug a hex word string.
34 void debughex(u16 v) {
39 a[2]+=(a[2]>9)?('a'-10):'0';
42 a[3]+=(a[3]>9)?('a'-10):'0';
45 a[4]+=(a[4]>9)?('a'-10):'0';
48 a[5]+=(a[5]>9)?('a'-10):'0';
52 txstring(0xFF,0xFF,a);
55 /*! \brief Transmit debug bytes.
57 Transmits bytes for debugging.
59 void debugbytes(const char *bytes, unsigned int len){
61 txhead(0xFF,0xFE,len);
67 //! Transmit a header.
68 void txhead(unsigned char app,
73 //serial_tx(len); //old protocol
78 void txdata(unsigned char app,
86 serial_tx(cmddata[i]);
91 unsigned long rxlong(){
92 unsigned long toret=0;
94 toret|=(((long)serial_rx())<<8);
95 toret|=(((long)serial_rx())<<16);
96 toret|=(((long)serial_rx())<<24);
100 unsigned int rxword(){
101 unsigned long toret=0;
103 toret|=(((long)serial_rx())<<8);
107 void txlong(unsigned long l){
118 void txword(unsigned int l){
125 //Be very careful changing delay().
126 //It was chosen poorly by trial and error.
128 //! Delay for a count.
129 void delay(unsigned int count){
130 volatile unsigned int i=count;
131 while(i--) asm("nop");
134 void msdelay(unsigned int ms){
135 volatile unsigned int i,j;
139 while(j--) asm("nop");
141 //Using TimerA might be cleaner.