1 //GoodFET SPI Application
4 //Higher level left to client application.
20 //This could be more accurate.
21 //Does it ever need to be?
23 #define SPIDELAY(x) delay(x)
25 #define SETMOSI P5OUT|=MOSI
26 #define CLRMOSI P5OUT&=~MOSI
27 #define SETCLK P5OUT|=SCK
28 #define CLRCLK P5OUT&=~SCK
29 #define READMISO (P5IN&MISO?1:0)
31 //! Set up the pins for SPI mode.
32 unsigned char spisetup(){
37 //! Read and write an SPI bit.
38 unsigned char spitrans8(unsigned char byte){
40 //This function came from the SPI Wikipedia article.
43 for (bit = 0; bit < 8; bit++) {
44 /* write MOSI on trailing edge of previous clock */
51 /* half a clock cycle before leading/rising edge */
55 /* half a clock cycle before trailing/falling edge */
58 /* read MISO on trailing edge */
66 //! Handles a monitor command.
67 void spihandle(unsigned char app,
71 //PEEK and POKE might come later.
74 cmddata[0]=spitrans8(cmddata[0]);