+//GOODFET Echo test.\r
+\r
+\r
+#include "platform.h"\r
+#include "command.h"\r
+#include "apps.h"\r
+\r
+#include <signal.h>\r
+#include <io.h>\r
+#include <iomacros.h>\r
+\r
+\r
+//LED on P1.0\r
+//IO on P5\r
+\r
+//! Initialize registers and all that jazz.\r
+void init(){\r
+ volatile unsigned int i;\r
+ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer\r
+ \r
+ //LED and TX OUT\r
+ PLEDDIR |= PLEDPIN;\r
+ \r
+ msp430_init_dco();\r
+ msp430_init_uart();\r
+ \r
+ //Enable Interrupts.\r
+ //eint();\r
+}\r
+\r
+//! Handle a command.\r
+void handle(unsigned char app,\r
+ unsigned char verb,\r
+ unsigned char len){\r
+ switch(app){\r
+ case MONITOR:\r
+ monitorhandle(app,verb,len);\r
+ break;\r
+ default:\r
+ txdata(app,NOK,0);\r
+ }\r
+}\r
+\r
+//! Main loop.\r
+int main(void)\r
+{\r
+ volatile unsigned int i;\r
+ unsigned char app, verb, len;\r
+ \r
+ init();\r
+ \r
+ //Command loop. There's no end!\r
+ while(1){\r
+ //Ready\r
+ txdata(MONITOR,OK,0);\r
+ \r
+ //Magic 3\r
+ app=serial_rx();\r
+ verb=serial_rx();\r
+ len=serial_rx();\r
+ //Read data, if any\r
+ for(i=0;i<len;i++){\r
+ cmddata[i]=serial_rx();\r
+ }\r
+ handle(app,verb,len);\r
+ }\r
+ \r
+ //while(1) serial_tx(serial_rx());\r
+ while(1) serial_tx(serial_rx());\r
+ \r
+ while(1){\r
+ i = 10000;\r
+ while(i--);\r
+ \r
+ PLEDOUT^=PLEDPIN; // Blink\r
+ }\r
+}\r
+\r