X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fspi%2Fspi.c;h=5c733eb18608cfb4726b3671f4587b3c408d2e96;hp=c58b4bc1e1a34bd7b5645fca9c8d975dfdb2c3b3;hb=681135fc7e254da993be28ffb6280ee149351234;hpb=9db7b366db7bd2535064bcdb0ae0ea89b2e6988f diff --git a/firmware/apps/spi/spi.c b/firmware/apps/spi/spi.c index c58b4bc..5c733eb 100644 --- a/firmware/apps/spi/spi.c +++ b/firmware/apps/spi/spi.c @@ -35,6 +35,10 @@ void spisetup(){ P5OUT|=SS; P5DIR|=MOSI+SCK+SS; P5DIR&=~MISO; + + //Begin a new transaction. + P5OUT&=~SS; + P5OUT|=SS; } //! Read and write an SPI bit. @@ -79,6 +83,7 @@ void spiflash_wrten(){ //! Grab the SPI flash status byte. unsigned char spiflash_status(){ unsigned char c; + P5OUT|=SS; //Raise !SS to end transaction. P5OUT&=~SS; //Drop !SS to begin transaction. spitrans8(0x05);//GET STATUS c=spitrans8(0xFF); @@ -91,7 +96,7 @@ void spiflash_setstatus(unsigned char c){ spitrans8(0x01);//SET STATUS spitrans8(c); P5OUT|=SS; //Raise !SS to end transaction. - return c; + //return c; } //! Handles a monitor command. @@ -99,6 +104,11 @@ void spihandle(unsigned char app, unsigned char verb, unsigned char len){ unsigned char i; + + + //Raise !SS to end transaction, just in case we forgot. + P5OUT|=SS; + switch(verb){ //PEEK and POKE might come later. case READ: @@ -127,8 +137,8 @@ void spihandle(unsigned char app, len=0x80;//128 byte chunk for(i=0;i