X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Favr%2Favr.c;h=a4ba6fdae890b58e89469f18920b48d46fcc6af9;hp=a8d9d341b82672cf199673e73c56cf610dd61d20;hb=166ecd9b06d0fd98ad69379f5b0d91c755adff2b;hpb=43d125b5bca16f0941450bee6ba7bd94ab41dc72;ds=sidebyside diff --git a/firmware/apps/avr/avr.c b/firmware/apps/avr/avr.c index a8d9d34..a4ba6fd 100644 --- a/firmware/apps/avr/avr.c +++ b/firmware/apps/avr/avr.c @@ -11,10 +11,13 @@ #include #include "avr.h" +#include "glitch.h" //! Setup the AVR pins. void avrsetup(){ spisetup(); + + glitchsetup(); } //! Initialized an attached AVR. @@ -67,7 +70,7 @@ u8 avrexchange(u8 a, u8 b, u8 c, u8 d){ 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); @@ -101,6 +104,12 @@ void avr_erase(){ u8 avr_lockbits(){ return avrexchange(0x58, 0, 0, 0); } +//! Write lock bits. +void avr_setlock(u8 bits){ + debugstr("Setting lock bits."); + avrexchange(0xAC,0xE0,0x00, + bits); +} //! Read a byte of EEPROM. u8 avr_peekeeprom(u16 adr){ @@ -159,7 +168,10 @@ void avrhandle(unsigned char app, cmddata[0]=avr_lockbits(); txdata(app,verb,1); break; - + case AVR_POKELOCK: + avr_setlock(cmddata[0]); + txdata(app,verb,0); + break; case AVR_POKEEEPROM: avr_pokeeeprom(cmddataword[0], cmddata[2]); //no break here.