2 \author Travis Goodspeed
3 \brief AVR SPI Programmer
15 //! Setup the AVR pins.
20 //! Initialized an attached AVR.
25 //Pulse !RST (SS) at least twice while CLK is low.
39 //! Read and write an SPI byte with delays.
40 unsigned char avrtrans8(unsigned char byte){
41 register unsigned int bit;
42 //This function came from the SPI Wikipedia article.
45 for (bit = 0; bit < 8; bit++) {
46 /* write MOSI on trailing edge of previous clock */
56 /* read MISO on trailing edge */
65 //! Perform a 4-byte exchange.
66 u8 avrexchange(u8 a, u8 b, u8 c, u8 d){
70 debugstr("AVR sync error, b not returned as c.");
76 //! Enable AVR programming mode.
78 avrexchange(0xAC, 0x53, 0, 0);
81 //! Read AVR device code.
83 return avrexchange(0x30, //Read signature byte
90 //! Handles an AVR command.
91 void avrhandle(unsigned char app,
101 cmddata[i]=spitrans8(cmddata[i]);
102 txdata(app,verb,len);
108 case START://returns device code
113 cmddata[i]=avr_sig(i);
119 debugstr("Verb unimplemented in AVR application.");