X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Finclude%2Fspi.h;h=02e548ae5ed3f2f72da71417776ca9ccd2a0a7e9;hp=c39766d5ea501bdf78de425510bbb0bfe154959f;hb=2c299b308dca8a7667bacce7690fa6238492723f;hpb=ae09939eb8c62c83f244527e7916cee5f9145e6c diff --git a/firmware/include/spi.h b/firmware/include/spi.h index c39766d..02e548a 100644 --- a/firmware/include/spi.h +++ b/firmware/include/spi.h @@ -5,16 +5,41 @@ //Pins and I/O -#define SS BIT0 +//#define SS BIT0 #define MOSI BIT1 #define MISO BIT2 #define SCK BIT3 -#define SETSS P5OUT|=SS -#define CLRSS P5OUT&=~SS - #define SETMOSI P5OUT|=MOSI #define CLRMOSI P5OUT&=~MOSI #define SETCLK P5OUT|=SCK #define CLRCLK P5OUT&=~SCK #define READMISO (P5IN&MISO?1:0) + +//! Set up the pins for SPI mode. +void spisetup(); + +//! Read and write an SPI byte. +unsigned char spitrans8(unsigned char byte); + +//! Read a block to a buffer. +void spiflash_peekblock(unsigned long adr, + unsigned char *buf, + unsigned int len); + + +//! Write many blocks to the SPI Flash. +void spiflash_pokeblocks(unsigned long adr, + unsigned char *buf, + unsigned int len); + + +//! Enable SPI writing +void spiflash_wrten(); + +//! Read and write an SPI byte. +unsigned char spitrans8(unsigned char byte); +//! Grab the SPI flash status byte. +unsigned char spiflash_status(); +//! Erase a sector. +void spiflash_erasesector(unsigned long adr);