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.
23 #warning "No init() routine for this platform!"
34 void handle(uint8_t const app,
40 //debugstr("GoodFET");
43 // find the app and call the handle fn
44 for(i = 0; i < num_apps; i++)
46 if(apps[i]->app == app)
48 // call the app's handle fn
49 (*(apps[i]->handle))(app, verb, len);
56 // if we get here, then the desired app is not copiled in
58 debugstr("App missing.");
67 volatile unsigned int i;
68 unsigned char app, verb;
70 // MSP reboot count for reset input & reboot function located at 0xFFFE
71 volatile unsigned int reset_count = 0;
72 void (*reboot_function)(void) = (void *) 0xFFFE;
76 txstring(MONITOR,OK,"http://goodfet.sf.net/");
78 //Command loop. There's no end!
84 // If the app is the reset byte (0x80) increment and loop
91 // We could trigger the WDT with either:
94 // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00;
95 // but instead we'll jump to our reboot function pointer
110 //Read data, looking for buffer overflow.y
111 if(len <= CMDDATALEN)
113 for(i = 0; i < len; i++)
115 cmddata[i] = serial_rx();
118 handle(app,verb,len);
122 //Listen to the blaberring.
123 for(i = 0; i < len; i++)
126 //Reply with an error.
127 debugstr("Buffer length exceeded.");
128 txdata(MONITOR,NOK,0);