New Chipcon SPI name.
[goodfet] / firmware / include / spi.h
1 /*! \file spi.h
2   \author Travis Goodspeed
3   \brief Definitions for the SPI application.
4 */
5
6
7 //Pins and I/O
8 //#define SS BIT0
9 #define MOSI BIT1
10 #define MISO BIT2
11 #define SCK  BIT3
12
13 #define SETMOSI P5OUT|=MOSI
14 #define CLRMOSI P5OUT&=~MOSI
15 #define SETCLK P5OUT|=SCK
16 #define CLRCLK P5OUT&=~SCK
17 #define READMISO (P5IN&MISO?1:0)
18
19 //! Set up the pins for SPI mode.
20 void spisetup();
21
22 //! Read and write an SPI byte.
23 unsigned char spitrans8(unsigned char byte);
24
25 //! Read a block to a buffer.
26 void spiflash_peekblock(unsigned long adr,
27                         unsigned char *buf,
28                         unsigned int len);
29
30
31 //! Write many blocks to the SPI Flash.
32 void spiflash_pokeblocks(unsigned long adr,
33                          unsigned char *buf,
34                          unsigned int len);
35
36
37 //! Enable SPI writing
38 void spiflash_wrten();
39
40 //! Read and write an SPI byte.
41 unsigned char spitrans8(unsigned char byte);
42 //! Grab the SPI flash status byte.
43 unsigned char spiflash_status();
44 //! Erase a sector.
45 void spiflash_erasesector(unsigned long adr);