From: travisutk Date: Tue, 15 Jun 2010 00:43:04 +0000 (+0000) Subject: Closer to harmonizing different platforms. X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=97143fece53250662a3ffd22f141619a4902eda7;ds=sidebyside Closer to harmonizing different platforms. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@628 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- diff --git a/firmware/apps/radios/nrf.c b/firmware/apps/radios/nrf.c index 9254f93..ca70113 100644 --- a/firmware/apps/radios/nrf.c +++ b/firmware/apps/radios/nrf.c @@ -15,26 +15,21 @@ #include "nrf.h" #include "spi.h" -//Weird HOPE badge wiring. This was a fuckup. -//BIT0 should be SS, but in point of fact it is IRQ. -//BIT4 is actually SS, BIT5 is CE. -#define SS BIT4 -#define CE BIT5; - -#define RADIOACTIVE P5OUT|=CE -#define RADIOPASSIVE P5OUT&=~CE +#define RADIOACTIVE SETCE +#define RADIOPASSIVE CLRCE //! Set up the pins for NRF mode. void nrfsetup(){ - P5OUT|=SS; + SETSS; P5DIR&=~MISO; - P5DIR|=MOSI+SCK+SS+CE; - + P5DIR|=MOSI+SCK; + DIRSS; + DIRCE; //Begin a new transaction. - P5OUT&=~SS; - P5OUT|=SS; + CLRSS; + SETSS; } //! Read and write an NRF byte. @@ -64,24 +59,24 @@ u8 nrftrans8(u8 byte){ //! Writes a register u8 nrf_regwrite(u8 reg, const u8 *buf, int len){ - P5OUT&=~SS; + CLRSS; reg=nrftrans8(reg); while(len--) nrftrans8(*buf++); - P5OUT|=SS; + SETSS; return reg;//status } //! Reads a register u8 nrf_regread(u8 reg, u8 *buf, int len){ - P5OUT&=~SS; + CLRSS; reg=nrftrans8(reg); while(len--) *buf++=nrftrans8(0); - P5OUT|=SS; + SETSS; return reg;//status } @@ -94,35 +89,35 @@ void nrfhandle(unsigned char app, //Drop CE to passify radio. RADIOPASSIVE; //Raise !SS to end transaction, just in case we forgot. - P5OUT|=SS; + SETSS; nrfsetup(); switch(verb){ //PEEK and POKE might come later. case READ: case WRITE: - P5OUT&=~SS; //Drop !SS to begin transaction. + CLRSS; //Drop !SS to begin transaction. for(i=0;i //! Receive a byte. -unsigned char serial_rx(){ +unsigned char serial0_rx(){ char c; while(!(IFG2&UCA0RXIFG));//wait for a byte @@ -29,7 +29,7 @@ unsigned char serial1_rx(){ } //! Transmit a byte. -void serial_tx(unsigned char x){ +void serial0_tx(unsigned char x){ while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free UCA0TXBUF = x; /* send the character */ while(!(IFG2 & UCA0TXIFG)); @@ -47,7 +47,7 @@ void serial1_tx(unsigned char x){ } //! Set the baud rate. -void setbaud(unsigned char rate){ +void setbaud0(unsigned char rate){ //Table 15-4, page 481 of 2xx Family Guide switch(rate){ diff --git a/firmware/platforms/goodfet.h b/firmware/platforms/goodfet.h index e661085..230b8b8 100644 --- a/firmware/platforms/goodfet.h +++ b/firmware/platforms/goodfet.h @@ -27,5 +27,11 @@ //No longer works for Hope badge. #define SETSS P5OUT|=BIT0 #define CLRSS P5OUT&=~BIT0 - - +#define DIRSS P5DIR|=BIT0; + +//BIT5 is Chip Enable. Need to document this +//#define RADIOACTIVE P5OUT|=BIT5 +//#define RADIOPASSIVE P5OUT&=~BIT5 +#define SETCE P5OUT|=BIT5 +#define CLRCE P5OUT&=~BIT5 +#define DIRCE P5DIR|=BIT5 diff --git a/firmware/platforms/nhbadge.h b/firmware/platforms/nhbadge.h new file mode 100644 index 0000000..39f7964 --- /dev/null +++ b/firmware/platforms/nhbadge.h @@ -0,0 +1,23 @@ +/*! \file nhbadge.h + \author Travis Goodspeed + \brief Port descriptions for the Next Hope Badge. +*/ + + +//LED on P1.0 +#define PLEDOUT P1OUT +#define PLEDDIR P1DIR +#define PLEDPIN BIT0 + + +//No longer works for Hope badge. +#define SETSS P5OUT|=BIT4 +#define CLRSS P5OUT&=~BIT4 +#define DIRSS P5DIR|=BIT4; + +//BIT5 is Chip Enable +//#define RADIOACTIVE P5OUT|=BIT5 +//#define RADIOPASSIVE P5OUT&=~BIT5 +#define SETCE P5OUT|=BIT5 +#define CLRCE P5OUT&=~BIT5 +#define DIRCE P5DIR|=BIT5 diff --git a/firmware/platforms/telosb.h b/firmware/platforms/telosb.h index a482125..c536b1c 100644 --- a/firmware/platforms/telosb.h +++ b/firmware/platforms/telosb.h @@ -18,4 +18,10 @@ //Radio CS is P4.2 #define SETSS P4OUT|=BIT2 #define CLRSS P4OUT&=~BIT2 +#define DIRSS P4DIR|=BIT2; + +//CC2420 Chip Reset. Need to document this. +#define SETCE P4OUT|=BIT6 +#define CLRCE P4OUT&=~BIT6 +#define DIRCE P4DIR|=BIT6