GLITCH application is coming together.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Tue, 24 Nov 2009 11:57:39 +0000 (11:57 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Tue, 24 Nov 2009 11:57:39 +0000 (11:57 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@239 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

firmware/apps/avr/avr.c
firmware/apps/glitch/glitch.c
firmware/goodfet.c
firmware/include/apps.h
firmware/include/glitch.h

index f1fe5b7..c9d0b94 100644 (file)
@@ -70,7 +70,7 @@ u8 avrexchange(u8 a, u8 b, u8 c, u8 d){
   avrtrans8(a);
   avrtrans8(b);
   if(avrtrans8(c)!=b){
   avrtrans8(a);
   avrtrans8(b);
   if(avrtrans8(c)!=b){
-    debugstr("AVR sync error, b not returned as c.");
+    //debugstr("AVR sync error, b not returned as c.");
     //Reconnect here?
   }
   return avrtrans8(d);
     //Reconnect here?
   }
   return avrtrans8(d);
index 1e7330d..e125544 100644 (file)
@@ -28,15 +28,60 @@ void glitchsetup(){
 
 //! Setup analog chain for glitching.
 void glitchsetupdac(){
 
 //! Setup analog chain for glitching.
 void glitchsetupdac(){
-#ifdef DAC12IR
+  glitchvoltages(glitchL,glitchH);
+}
+
+
+u16 glitchH=0xfff, glitchL=0xfff,
+  glitchstate, glitchcount;
+
+//! Glitch an application.
+void glitchapp(u8 app){
+  debugstr("That app is not yet supported.");
+}
+//! Set glitching voltages.
+void glitchvoltages(u16 low, u16 high){
   int i;
   int i;
+  glitchH=high;
+  glitchL=low;
+  
+  
+  #ifdef DAC12IR
   ADC12CTL0 = REF2_5V + REFON;                  // Internal 2.5V ref on
   // Delay here for reference to settle.
   for(i=0;i!=0xFFFF;i++) asm("nop");
   DAC12_0CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
   // 1.0V 0x0666, 2.5V 0x0FFF
   ADC12CTL0 = REF2_5V + REFON;                  // Internal 2.5V ref on
   // Delay here for reference to settle.
   for(i=0;i!=0xFFFF;i++) asm("nop");
   DAC12_0CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
   // 1.0V 0x0666, 2.5V 0x0FFF
-  DAC12_0DAT = 0x0FFF;
+  DAC12_0DAT = high;
   //DAC12_0DAT = 0x0880;
   //DAC12_0DAT = 0x0880;
-  //__bis_SR_register(LPM0_bits + GIE);           // Enter LPM0
-#endif 
+  #endif 
+}
+//! Set glitching rate.
+void glitchrate(u16 rate){
+  glitchcount=rate;
+}
+
+
+//! Handles a monitor command.
+void glitchhandle(unsigned char app,
+                 unsigned char verb,
+                 unsigned long len){
+  switch(verb){
+  case GLITCHVOLTAGES:
+    glitchvoltages(cmddataword[0],
+                  cmddataword[1]);
+    txdata(app,verb,0);
+    break;
+  case GLITCHRATE:
+    glitchrate(cmddataword[0]);
+    txdata(app,verb,0);
+    break;
+  case START:
+  case STOP:
+  case GLITCHAPP:
+  case GLITCHVERB:
+  default:
+    debugstr("Unknown glitching verb.");
+    txdata(app,NOK,0);
+  }
 }
 }
index 8dea02e..b08313f 100644 (file)
@@ -39,6 +39,9 @@ void handle(unsigned char app,
            unsigned long len){\r
   //debugstr("GoodFET");\r
   switch(app){\r
            unsigned long len){\r
   //debugstr("GoodFET");\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 MONITOR:\r
     monitorhandle(app,verb,len);\r
     break;\r
index b3989c6..ddb8a0b 100644 (file)
@@ -13,5 +13,6 @@
 #define AVR 0x32
 
 #define OCT 0x70
 #define AVR 0x32
 
 #define OCT 0x70
+#define GLITCH 0x71
 
 #define DEBUGAPP 0xFF
 
 #define DEBUGAPP 0xFF
index de3d4a8..6f30d6d 100644 (file)
@@ -7,7 +7,27 @@
 #include <io.h>
 #include <iomacros.h>
 
 #include <io.h>
 #include <iomacros.h>
 
+//Command codes
+#define GLITCHAPP      0x80
+#define GLITCHVERB     0x81
+#define GLITCHVOLTAGES 0x90
+#define GLITCHRATE     0x91
+
 //! Disable glitch state at init.
 void glitchsetup();
 //! Setup analog chain for glitching.
 void glitchsetupdac();
 //! Disable glitch state at init.
 void glitchsetup();
 //! Setup analog chain for glitching.
 void glitchsetupdac();
+
+extern u16 glitchH, glitchL, glitchstate, glitchcount;
+
+//! Glitch an application.
+void glitchapp(u8 app);
+//! Set glitching voltages.
+void glitchvoltages(u16 low, u16 high);
+//! Set glitching rate.
+void glitchrate(u16 rate);
+
+//! Handles a monitor command.
+void glitchhandle(unsigned char app,
+                 unsigned char verb,
+                 unsigned long len);