More glitching improvements.
[goodfet] / firmware / goodfet.c
index 4cddc19..2702fdd 100644 (file)
@@ -10,7 +10,7 @@
 #include "platform.h"\r
 #include "command.h"\r
 #include "apps.h"\r
-\r
+#include "glitch.h"\r
 \r
 \r
 //LED on P1.0\r
@@ -22,28 +22,41 @@ void init(){
   \r
   //LED out and on.\r
   PLEDDIR |= PLEDPIN;\r
-  PLEDOUT |= PLEDPIN;\r
+  PLEDOUT &= ~PLEDPIN;\r
   \r
   //Setup clocks, unique to each '430.\r
   msp430_init_dco();\r
   msp430_init_uart();\r
   \r
+  //DAC should be at full voltage if it exists.\r
+  #ifdef DAC12IR\r
+  glitchvoltages(0xfff,0xfff);\r
+  #endif\r
+  \r
   //Enable Interrupts.\r
   //eint();\r
 }\r
 \r
+\r
 //! Handle a command.\r
 void handle(unsigned char app,\r
            unsigned char verb,\r
            unsigned long len){\r
   //debugstr("GoodFET");\r
+  P1OUT&=~1;\r
   switch(app){\r
+  case GLITCH:\r
+    glitchhandle(app,verb,len);\r
+    break;\r
   case MONITOR:\r
     monitorhandle(app,verb,len);\r
     break;\r
   case SPI:\r
     spihandle(app,verb,len);\r
     break;\r
+  case AVR:\r
+    avrhandle(app,verb,len);\r
+    break;\r
   case I2CAPP:\r
     i2chandle(app,verb,len);\r
     break;\r
@@ -57,11 +70,13 @@ void handle(unsigned char app,
     jtag430x2handle(app,verb,len);\r
     break;\r
   default:\r
-    #ifdef HANDLEOTHER\r
-    HANDLEOTHER(app,verb,len);\r
-    #else\r
-    txdata(app,NOK,0);\r
-    #endif\r
+    if(pluginhandle){\r
+      pluginhandle(app,verb,len);\r
+    }else{\r
+      debugstr("Plugin missing.");\r
+      txdata(app,NOK,0);\r
+    }\r
+      \r
     break;\r
   }\r
 }\r
@@ -74,9 +89,10 @@ int main(void)
   unsigned long len;\r
   \r
   init();\r
-  \r
+\r
   txstring(MONITOR,OK,"http://goodfet.sf.net/");\r
   \r
+  \r
   //Command loop.  There's no end!\r
   while(1){\r
     //Magic 3\r