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,
47 //debugstr("GoodFET");
50 // find the app and call the handle fn
51 for(i = 0; i < num_apps; i++){
52 if(apps[i]->app == app){
53 // call the app's handle fn
54 (*(apps[i]->handle))(app, verb, len);
61 // if we get here, then the desired app is not copiled in
63 debugstr("App missing.");
72 volatile unsigned int i;
73 unsigned char app, verb;
75 // MSP reboot count for reset input & reboot function located at 0xFFFE
76 volatile unsigned int reset_count = 0;
77 void (*reboot_function)(void) = (void *) 0xFFFE;
81 txstring(MONITOR,OK,"http://goodfet.sf.net/");
83 while(1) serial0_tx(serial0_rx());
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
105 (*reboot_function)();
107 debugstr("Rebooting not supported on this platform.");
121 //Read data, looking for buffer overflow.y
122 if(len <= CMDDATALEN)
124 for(i = 0; i < len; i++)
126 cmddata[i] = serial_rx();
129 handle(app,verb,len);
133 //Listen to the blaberring.
134 for(i = 0; i < len; i++)
137 //Reply with an error.
138 debugstr("Buffer length exceeded.");
139 txdata(MONITOR,NOK,0);