Add ADC10 application for sampling analog values.
[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 #define SETTST P4OUT|=TST
20 #define CLRTST P4OUT&=~TST
21 #define SETRST P2OUT|=RST
22 #define CLRRST P2OUT&=~RST
23
24
25 //! Set up the pins for SPI mode.
26 void spisetup();
27
28 //! Read and write an SPI byte.
29 unsigned char spitrans8(unsigned char byte);
30
31 //! Read a block to a buffer.
32 void spiflash_peekblock(unsigned long adr,
33                         unsigned char *buf,
34                         unsigned int len);
35
36
37 //! Write many blocks to the SPI Flash.
38 void spiflash_pokeblocks(unsigned long adr,
39                          unsigned char *buf,
40                          unsigned int len);
41
42
43 //! Enable SPI writing
44 void spiflash_wrten();
45
46 //! Read and write an SPI byte.
47 unsigned char spitrans8(unsigned char byte);
48 //! Grab the SPI flash status byte.
49 unsigned char spiflash_status();
50 //! Erase a sector.
51 void spiflash_erasesector(unsigned long adr);