POKE verb of the Monitor.
[goodfet] / firmware / apps / goodfet.c
1 //GOODFET Echo test.\r
2 \r
3 \r
4 #include "platform.h"\r
5 #include "command.h"\r
6 #include "apps.h"\r
7 \r
8 #include <signal.h>\r
9 #include <io.h>\r
10 #include <iomacros.h>\r
11 \r
12 \r
13 //LED on P1.0\r
14 //IO on P5\r
15 \r
16 //! Initialize registers and all that jazz.\r
17 void init(){\r
18   volatile unsigned int i;\r
19   WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer\r
20   \r
21   //LED and TX OUT\r
22   PLEDDIR |= PLEDPIN;\r
23   \r
24   msp430_init_dco();\r
25   msp430_init_uart();\r
26   \r
27   //Enable Interrupts.\r
28   //eint();\r
29 }\r
30 \r
31 //! Handle a command.\r
32 void handle(unsigned char app,\r
33             unsigned char verb,\r
34             unsigned char len){\r
35   switch(app){\r
36   case MONITOR:\r
37     monitorhandle(app,verb,len);\r
38     break;\r
39   default:\r
40     txdata(app,NOK,0);\r
41   }\r
42 }\r
43 \r
44 //! Main loop.\r
45 int main(void)\r
46 {\r
47   volatile unsigned int i;\r
48   unsigned char app, verb, len;\r
49   \r
50   init();\r
51   \r
52   //Ready\r
53   txdata(MONITOR,OK,0);\r
54   \r
55   //Command loop.  There's no end!\r
56   while(1){\r
57     //Magic 3\r
58     app=serial_rx();\r
59     verb=serial_rx();\r
60     len=serial_rx();\r
61     //Read data, if any\r
62     for(i=0;i<len;i++){\r
63       cmddata[i]=serial_rx();\r
64     }\r
65     handle(app,verb,len);\r
66   }\r
67     \r
68   //while(1) serial_tx(serial_rx());\r
69   while(1) serial_tx(serial_rx());\r
70   \r
71   while(1){\r
72     i = 10000;\r
73     while(i--);\r
74     \r
75     PLEDOUT^=PLEDPIN;  // Blink\r
76   }\r
77 }\r
78 \r