X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fspi%2Fspi.c;h=7f9777b548d02fff403df12d0469c78f3c97acfe;hp=c58b4bc1e1a34bd7b5645fca9c8d975dfdb2c3b3;hb=c5f9be41f72eaddb734b78396ee4bf7bd6273439;hpb=9db7b366db7bd2535064bcdb0ae0ea89b2e6988f diff --git a/firmware/apps/spi/spi.c b/firmware/apps/spi/spi.c index c58b4bc..7f9777b 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,39 @@ void spiflash_setstatus(unsigned char c){ spitrans8(0x01);//SET STATUS spitrans8(c); P5OUT|=SS; //Raise !SS to end transaction. - return c; + //return c; +} + +//! Peek some blocks. +void spiflash_peek(unsigned char app, + unsigned char verb, + unsigned char len){ + register char blocks=(len>3?cmddata[3]:1); + unsigned char i,j; + + P5OUT&=~SS; //Drop !SS to begin transaction. + spitrans8(0x03);//Flash Read Command + len=3;//write 3 byte pointer + for(i=0;i