2 \author Travis Goodspeed
\r
5 This is the main module of the GoodFET, which calls the initialization
\r
6 routines and delegates commands to the various applications.
\r
10 #include "platform.h"
\r
11 #include "command.h"
\r
19 //! Initialize registers and all that jazz.
\r
21 WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
\r
25 PLEDOUT &= ~PLEDPIN;
\r
27 //Setup clocks, unique to each '430.
\r
31 //DAC should be at full voltage if it exists.
\r
33 glitchvoltages(0xfff,0xfff);
\r
36 //Enable Interrupts.
\r
41 //! Handle a command.
\r
42 void handle(unsigned char app,
\r
45 //debugstr("GoodFET");
\r
49 glitchhandle(app,verb,len);
\r
52 monitorhandle(app,verb,len);
\r
55 spihandle(app,verb,len);
\r
58 avrhandle(app,verb,len);
\r
61 i2chandle(app,verb,len);
\r
64 cchandle(app,verb,len);
\r
67 jtaghandle(app,verb,len);
\r
69 case JTAG430: //Also JTAG430X, JTAG430X2
\r
70 jtag430x2handle(app,verb,len);
\r
74 pluginhandle(app,verb,len);
\r
76 debugstr("Plugin missing.");
\r
87 volatile unsigned int i;
\r
88 unsigned char app, verb;
\r
90 // MSP reboot count for reset input & reboot function located at 0xFFFE
\r
91 volatile unsigned int reset_count = 0;
\r
92 void (*reboot_function)(void) = (void *) 0xFFFE;
\r
96 txstring(MONITOR,OK,"http://goodfet.sf.net/");
\r
99 //Command loop. There's no end!
\r
104 // If the app is the reset byte (0x80) increment and loop
\r
108 if (reset_count > 4) {
\r
109 // We could trigger the WDT with either:
\r
112 // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00;
\r
113 // but instead we'll jump to our reboot function pointer
\r
114 (*reboot_function)();
\r
126 //Read data, looking for buffer overflow.y
\r
127 if(len<=CMDDATALEN){
\r
128 for(i=0;i<len;i++){
\r
129 cmddata[i]=serial_rx();
\r
131 handle(app,verb,len);
\r
133 //Listen to the blaberring.
\r
136 //Reply with an error.
\r
137 debugstr("Buffer length exceeded.");
\r
138 txdata(MONITOR,NOK,0);
\r