From 6516232c0373af0681499ecfa762b89a65ee508f Mon Sep 17 00:00:00 2001 From: travisutk Date: Sat, 13 Feb 2010 21:14:33 +0000 Subject: [PATCH 1/1] Naming conventioned, removed glitchsetupdac(). git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@315 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/apps/glitch/glitch.c | 31 +++++++------------------------ firmware/include/glitch.h | 4 +--- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/firmware/apps/glitch/glitch.c b/firmware/apps/glitch/glitch.c index e1f8be2..bdaa705 100644 --- a/firmware/apps/glitch/glitch.c +++ b/firmware/apps/glitch/glitch.c @@ -15,8 +15,7 @@ //! Call this before the function to be glitched. void glitchprime(){ #ifdef DAC12IR - //Set to high voltage. - DAC12_0DAT = glitchH; + //Don't forget to call glitchvoltages(). //Reconfigure TACTL. TACTL=0; //Clear dividers. @@ -43,8 +42,6 @@ void glitchsetup(){ P5OUT|=0x80; P6OUT|=BIT6+BIT5; - - glitchsetupdac(); WDTCTL = WDTPW + WDTHOLD; // Stop WDT TACTL = TASSEL1 + TACLR; // SMCLK, clear TAR @@ -55,23 +52,12 @@ void glitchsetup(){ #endif } -//! Setup analog chain for glitching. -void glitchsetupdac(){ - glitchvoltages(glitchL,glitchH); -} - // Timer A0 interrupt service routine interrupt(TIMERA0_VECTOR) Timer_A (void) { #ifdef DAC12IR - //debugstr("Glitching."); - DAC12_0DAT = glitchL; - asm("nop"); - asm("nop"); - asm("nop"); - asm("nop"); - asm("nop"); - DAC12_0DAT = glitchH; + P5OUT&=~BIT7;//Glitch + P5OUT|=BIT7;//Normal #endif TACTL |= MC0; // Stop Timer_A; } @@ -89,11 +75,8 @@ void glitchapp(u8 app){ //! Set glitching voltages. -void glitchvoltages(u16 low, u16 high){ +void glitchvoltages(u16 gnd, u16 vcc){ int i; - glitchH=high; - glitchL=low; - //debugstr("Set glitching voltages."); #ifdef DAC12IR @@ -103,8 +86,8 @@ void glitchvoltages(u16 low, u16 high){ DAC12_0CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1 DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1 // 1.0V 0x0666, 2.5V 0x0FFF - DAC12_0DAT = high; - DAC12_1DAT = low; + DAC12_0DAT = vcc; //high; + DAC12_1DAT = gnd; //low; #endif } //! Set glitching rate. @@ -152,7 +135,7 @@ void glitchhandle(unsigned char app, while(1){ P5OUT&=~BIT7;//Glitch //asm("nop");//asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); - asm("nop"); + asm("nop"); //Not necessary. P5OUT|=BIT7;//Normal asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); diff --git a/firmware/include/glitch.h b/firmware/include/glitch.h index 8cbe7ed..aef8888 100644 --- a/firmware/include/glitch.h +++ b/firmware/include/glitch.h @@ -17,8 +17,6 @@ //! Setup glitching. void glitchsetup(); -//! Setup analog chain for glitching. -void glitchsetupdac(); //! Call this before the function to be glitched. void glitchprime(); @@ -27,7 +25,7 @@ extern u16 glitchH, glitchL, glitchstate, glitchcount; //! Glitch an application. void glitchapp(u8 app); //! Set glitching voltages. -void glitchvoltages(u16 low, u16 high); +void glitchvoltages(u16 gnd, u16 vcc); //! Set glitching rate. void glitchrate(u16 rate); -- 2.20.1