2 \author Travis Goodspeed
3 \brief Definitions for the SPI application.
14 #if (platform == donbfet)
15 # define MOSI (1 << PA2)
16 # define MISO (1 << PA1)
17 # define SCK (1 << PA0)
18 # define SS (1 << PA3)
19 # define TST (1 << PA4)
20 # define XRST (1 << PA5)
21 #elif (platform == arduino)
22 // pin Arduini - nrf pin
25 # define CE (1 << PB1) // pin 9 - nrf 3 CE
26 # define SS (1 << PB2) // pin 10 CS - nrf 4 CSN
27 # define MOSI (1 << PB3) // pin 11 MOSI - nrf 6 MOSI
28 # define MISO (1 << PB4) // pin 12 MISO - nrf 7 MISO
29 # define SCK (1 << PB5) // pin 13 SCL - nrf 5 CLK
31 //# define TST (1 << PA4)
32 //# define XRST (1 << PA5)
40 //Apimotev2 SET/CLRRST needs to be on pin 21, so 2.1 -- just redefine RST to BIT0
42 #define SETMOSI SPIOUT|=MOSI
43 #define CLRMOSI SPIOUT&=~MOSI
44 #define SETCLK SPIOUT|=SCK
45 #define CLRCLK SPIOUT&=~SCK
46 #define READMISO (SPIIN&MISO?1:0)
48 //FIXME this should be defined by the platform.
49 #if (platform == donbfet)
50 # define SETTST PORTA|=(1 << PA4);
51 # define CLRTST PORTA&=~(1 << PA4);
52 # define SETRST PORTA|=(1 << PA5);
53 # define CLRRST PORTA&=~(1 << PA5);
54 #elif (platform == arduino)
55 //# define SETTST PORTA|=(1 << PA4);
56 //# define CLRTST PORTA&=~(1 << PA4);
57 //# define SETRST PORTA|=(1 << PA5);
58 //# define CLRRST PORTA&=~(1 << PA5);
60 # define SETTST P4OUT|=TST
61 # define CLRTST P4OUT&=~TST
62 # define SETRST P2OUT|=RST
63 # define CLRRST P2OUT&=~RST
66 //! Set up the pins for SPI mode.
69 //! Read and write an SPI byte.
70 unsigned char spitrans8(unsigned char byte);
72 //! Read a block to a buffer.
73 void spiflash_peekblock(unsigned long adr,
78 //! Write many blocks to the SPI Flash.
79 void spiflash_pokeblocks(unsigned long adr,
84 //! Enable SPI writing
85 void spiflash_wrten();
87 //! Read and write an SPI byte.
88 unsigned char spitrans8(unsigned char byte);
89 //! Grab the SPI flash status byte.
90 unsigned char spiflash_status();
92 void spiflash_erasesector(unsigned long adr);
94 extern app_t const spi_app;