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/");
106 //txstring(0xab,0xcd,"http://goodfet.sf.net/");
109 //Command loop. There's no end!
115 // If the app is the reset byte (0x80) increment and loop
122 // We could trigger the WDT with either:
125 // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00;
126 // but instead we'll jump to our reboot function pointer
128 #if (platform == tilaunchpad)
129 // do we really need this, we do not want to reset the TUSB3410
130 dputs("reset_count>4\n");
132 //longjmp(warmstart,111);
136 (*reboot_function)();
139 debugstr("Rebooting not supported on this platform.");
153 //Read data, looking for buffer overflow.
154 if(len <= CMDDATALEN)
156 for(i = 0; i < len; i++)
158 cmddata[i] = serial_rx();
161 handle(app,verb,len);
165 //Listen to the blaberring.
166 for(i = 0; i < len; i++)
169 //Reply with an error.
170 debugstr("Buffer length exceeded.");
171 txdata(MONITOR,NOK,0);