2 \author Travis Goodspeed
5 This is the main module of the GoodFET, which calls the initialization
6 routines and delegates commands to the various applications.
15 #if (platform == tilaunchpad)
19 #include "msp430_serial.h"
22 #define RESET 0x80 // not a real app -- causes firmware to reset
25 //! General init function, calls platform-specific one.
28 #define INITCHIP msp430_init();
32 #define INITCHIP arduino_init();
38 #warning "No init() routine for this platform!"
49 void handle(uint8_t const app,
54 //debugstr("GoodFET");
57 // find the app and call the handle fn
58 for(i = 0; i < num_apps; i++){
59 if(apps[i]->app == app){
60 // call the app's handle fn
61 (*(apps[i]->handle))(app, verb, len);
68 // if we get here, then the desired app is not copiled in
70 debugstr("App missing.");
79 volatile unsigned int i;
80 unsigned char app, verb;
82 // MSP reboot count for reset input & reboot function located at 0xFFFE
83 volatile unsigned int reset_count = 0;
84 #if (platform == tilaunchpad)
87 //ret = setjmp(warmstart);// needs to be here since context from init() would be gone
90 coldstart(); // basic hardware setup, clock to TUSB3410, and enable
91 } else if (ret == 2) {
92 dputs("\nalmost BSL only one RTS change\n");
93 } else if (ret > 2) { // reset released after more than two tst transisitions
94 // We could write a BSL, a nice exercise for a Sunday afternoon.
96 //call_BSL(); // once you are done uncomment ;-)
97 } else { // we come here after DTR high (release reset)
98 dputs("\nWarmstart\n");
101 void (*reboot_function)(void) = (void *) 0xFFFE;
105 txstring(MONITOR,OK,"http://goodfet.sf.net/");
107 while(1) serial0_tx(serial0_rx());
110 //Command loop. There's no end!
116 // If the app is the reset byte (0x80) increment and loop
123 // We could trigger the WDT with either:
126 // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00;
127 // but instead we'll jump to our reboot function pointer
129 #if (platform == tilaunchpad)
130 // do we really need this, we do not want to reset the TUSB3410
131 dputs("reset_count>4\n");
133 //longjmp(warmstart,111);
137 (*reboot_function)();
140 debugstr("Rebooting not supported on this platform.");
154 //Read data, looking for buffer overflow.y
155 if(len <= CMDDATALEN)
157 for(i = 0; i < len; i++)
159 cmddata[i] = serial_rx();
162 handle(app,verb,len);
166 //Listen to the blaberring.
167 for(i = 0; i < len; i++)
170 //Reply with an error.
171 debugstr("Buffer length exceeded.");
172 txdata(MONITOR,NOK,0);