From ba4e9392ba615ed84d47576fe973057f89bb8998 Mon Sep 17 00:00:00 2001 From: travisutk Date: Mon, 14 Jun 2010 22:19:17 +0000 Subject: [PATCH] Generalizing IO. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@627 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/apps/spi/spi.c | 40 ++++++++++++++++++------------------ firmware/include/gfports.h | 13 ------------ firmware/include/spi.h | 5 +---- firmware/platforms/goodfet.h | 17 +++++++++++++++ firmware/platforms/telosb.h | 5 +++++ 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/firmware/apps/spi/spi.c b/firmware/apps/spi/spi.c index fc31038..3da3135 100644 --- a/firmware/apps/spi/spi.c +++ b/firmware/apps/spi/spi.c @@ -23,13 +23,13 @@ //! Set up the pins for SPI mode. void spisetup(){ - P5OUT|=SS; - P5DIR|=MOSI+SCK+SS; + SETSS; + P5DIR|=MOSI+SCK+BIT0; //BIT0 might be SS P5DIR&=~MISO; //Begin a new transaction. - P5OUT&=~SS; - P5OUT|=SS; + CLRSS; + SETSS; } @@ -62,24 +62,24 @@ unsigned char spitrans8(unsigned char byte){ void spiflash_wrten(){ SETSS; /* - P5OUT&=~SS; //Drop !SS to begin transaction. + CLRSS; //Drop !SS to begin transaction. spitrans8(0x04);//Write Disable - P5OUT|=SS; //Raise !SS to end transaction. + SETSS; //Raise !SS to end transaction. */ - P5OUT&=~SS; //Drop !SS to begin transaction. + CLRSS; //Drop !SS to begin transaction. spitrans8(0x06);//Write Enable - P5OUT|=SS; //Raise !SS to end transaction. + SETSS; //Raise !SS to end transaction. } //! Grab the SPI flash status byte. unsigned char spiflash_status(){ unsigned char c; - P5OUT|=SS; //Raise !SS to end transaction. - P5OUT&=~SS; //Drop !SS to begin transaction. + SETSS; //Raise !SS to end transaction. + CLRSS; //Drop !SS to begin transaction. spitrans8(0x05);//GET STATUS c=spitrans8(0xFF); - P5OUT|=SS; //Raise !SS to end transaction. + SETSS; //Raise !SS to end transaction. return c; } @@ -179,7 +179,7 @@ void spiflash_peek(unsigned char app, unsigned char verb, unsigned long len){ unsigned int i; - P5OUT&=~SS; //Drop !SS to begin transaction. + CLRSS; //Drop !SS to begin transaction. spitrans8(0x03);//Flash Read Command len=3;//write 3 byte pointer for(i=0;i