Beginning EJTAG (MIPS) support with an empty app.
[goodfet] / firmware / goodfet.c
index 2fe74e1..900e836 100644 (file)
@@ -66,6 +66,9 @@ void handle(unsigned char app,
   case JTAG:\r
     jtaghandle(app,verb,len);\r
     break;\r
+  case EJTAG:\r
+    ejtaghandle(app,verb,len);\r
+    break;\r
   case JTAG430: //Also JTAG430X, JTAG430X2\r
     jtag430x2handle(app,verb,len);\r
     break;\r
@@ -87,6 +90,9 @@ int main(void)
   volatile unsigned int i;\r
   unsigned char app, verb;\r
   unsigned long len;\r
+  // MSP reboot count for reset input & reboot function located at 0xFFFE\r
+  volatile unsigned int reset_count = 0;\r
+  void (*reboot_function)(void) = (void *) 0xFFFE;\r
   \r
   init();\r
 \r
@@ -97,6 +103,25 @@ int main(void)
   while(1){\r
     //Magic 3\r
     app=serial_rx();\r
+\r
+       // If the app is the reset byte (0x80) increment and loop\r
+       if (app == 0x80) {\r
+               reset_count++;\r
+\r
+               if (reset_count > 4) {\r
+                       // We could trigger the WDT with either:\r
+                       // WDTCTL = 0;\r
+                       // or\r
+                       // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00;\r
+                       // but instead we'll jump to our reboot function pointer\r
+                       (*reboot_function)();\r
+               }\r
+\r
+               continue;\r
+       } else {\r
+               reset_count = 0;\r
+       }\r
+\r
     verb=serial_rx();\r
     //len=serial_rx();\r
     len=rxword();\r