Clocking changes.
[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 SETSS P5OUT|=SS
14 #define CLRSS P5OUT&=~SS
15
16 #define SETMOSI P5OUT|=MOSI
17 #define CLRMOSI P5OUT&=~MOSI
18 #define SETCLK P5OUT|=SCK
19 #define CLRCLK P5OUT&=~SCK
20 #define READMISO (P5IN&MISO?1:0)
21
22 //! Set up the pins for SPI mode.
23 void spisetup();
24
25 //! Read and write an SPI byte.
26 unsigned char spitrans8(unsigned char byte);
27
28 //! Read a block to a buffer.
29 void spiflash_peekblock(unsigned long adr,
30                         unsigned char *buf,
31                         unsigned int len);
32
33
34 //! Write many blocks to the SPI Flash.
35 void spiflash_pokeblocks(unsigned long adr,
36                          unsigned char *buf,
37                          unsigned int len);
38
39
40 //! Enable SPI writing
41 void spiflash_wrten();
42
43 //! Read and write an SPI byte.
44 unsigned char spitrans8(unsigned char byte);
45 //! Grab the SPI flash status byte.
46 unsigned char spiflash_status();
47 //! Erase a sector.
48 void spiflash_erasesector(unsigned long adr);