X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Finclude%2Fspi.h;h=e96bef3795180be369ccadf2577cb88e94ba0938;hp=8cd488aa6ff60fb29f0cd33d1a3b2904e9ea3c57;hb=bd6ced95abc5725c991fc100d94a023b27c9e159;hpb=8c6abfea1a9e8225746fed39bcb8ffeba01670a9 diff --git a/firmware/include/spi.h b/firmware/include/spi.h index 8cd488a..e96bef3 100644 --- a/firmware/include/spi.h +++ b/firmware/include/spi.h @@ -1,4 +1,7 @@ -/** SPI **/ +/*! \file spi.h + \author Travis Goodspeed + \brief Definitions for the SPI application. +*/ //Pins and I/O @@ -15,3 +18,31 @@ #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);