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 #define RESET 0x80 // not a real app -- causes firmware to reset
18 //! General init function, calls platform-specific one.
21 #define INITCHIP msp430_init();
25 #define INITCHIP arduino_init();
31 #warning "No init() routine for this platform!"
42 void handle(uint8_t const app,
48 //debugstr("GoodFET");
51 // find the app and call the handle fn
52 for(i = 0; i < num_apps; i++)
54 if(apps[i]->app == app)
56 // call the app's handle fn
57 (*(apps[i]->handle))(app, verb, len);
64 // if we get here, then the desired app is not copiled in
66 debugstr("App missing.");
75 volatile unsigned int i;
76 unsigned char app, verb;
78 // MSP reboot count for reset input & reboot function located at 0xFFFE
79 volatile unsigned int reset_count = 0;
80 void (*reboot_function)(void) = (void *) 0xFFFE;
84 txstring(MONITOR,OK,"http://goodfet.sf.net/");
86 //Command loop. There's no end!
92 // If the app is the reset byte (0x80) increment and loop
99 // We could trigger the WDT with either:
102 // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00;
103 // but instead we'll jump to our reboot function pointer
104 (*reboot_function)();
118 //Read data, looking for buffer overflow.y
119 if(len <= CMDDATALEN)
121 for(i = 0; i < len; i++)
123 cmddata[i] = serial_rx();
126 handle(app,verb,len);
130 //Listen to the blaberring.
131 for(i = 0; i < len; i++)
134 //Reply with an error.
135 debugstr("Buffer length exceeded.");
136 txdata(MONITOR,NOK,0);