X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fplatforms%2Ftelosb.h;h=51c07224cfd409a8546a7b6ccc34a97aae203f5d;hp=235faeeabb10f23e5dce9556d948f4ac18c00d31;hb=ed8fe6653a821e893857c9491d576b8c6dee8dad;hpb=854dba571fe62948dfb23a396be3299225fcbb05 diff --git a/firmware/platforms/telosb.h b/firmware/platforms/telosb.h index 235faee..51c0722 100644 --- a/firmware/platforms/telosb.h +++ b/firmware/platforms/telosb.h @@ -12,21 +12,24 @@ #include #endif -//LED on P5.4 +//LED on P5.4 (LED1 red) #define PLEDOUT P5OUT #define PLEDDIR P5DIR #define PLEDPIN BIT4 +//LED on P5.5 (LED2 green) +#define PLED2OUT P5OUT +#define PLED2DIR P5DIR +#define PLED2PIN BIT5 +//LED on P5.6 (LED3 blue) +#define PLED3OUT P5OUT +#define PLED3DIR P5DIR +#define PLED3PIN BIT6 #define SPIOUT P3OUT #define SPIDIR P3DIR #define SPIIN P3IN #define SPIREN P3REN - -#define P5OUT P3OUT -#define P5DIR P3DIR -#define P5IN P3IN -#define P5REN P3REN /* For the radio to be used: @@ -36,21 +39,60 @@ */ #define INITPLATFORM \ - P4DIR|=BIT6+BIT5+BIT2+BIT7+BIT4; \ - P4OUT=BIT5; + P1DIR = 0xe0;\ + P1OUT = 0x00;\ + P2DIR = 0x7b;\ + P2OUT = 0x10;\ + P3DIR = 0xf1;\ + P3OUT = 0x00;\ + P4DIR = 0xfd;\ + P4OUT = 0xFd;\ + P5DIR = 0xff;\ + P5OUT = 0xff;\ + P6DIR = 0xff;\ + P6OUT = 0x00; //Radio CS is P4.2 #define SETSS P4OUT|=BIT2 #define CLRSS P4OUT&=~BIT2 #define DIRSS P4DIR|=BIT2 -//Flash CS is P4.4 -//#define SETSS P4OUT|=BIT4 -//#define CLRSS P4OUT&=~BIT4 -//#define DIRSS P4DIR|=BIT4 - +//Flash CS is P4.4, redefine only for the SPI app. +#ifdef SPIAPPLICATION +#undef SETSS +#undef CLRSS +#undef DIRSS +#define SETSS P4OUT|=BIT4 +#define CLRSS P4OUT&=~BIT4 +#define DIRSS P4DIR|=BIT4 +#endif -//CC2420 Chip Reset. Need to document this. +//CC2420 Chip Enable #define SETCE P4OUT|=BIT6 #define CLRCE P4OUT&=~BIT6 #define DIRCE P4DIR|=BIT6 + +//CC2420 signals +#define SFD (P4IN&BIT1) +#define FIFOP (P1IN&BIT0) +#define FIFO (P1IN&BIT3) + +//GPIO Expansion Pins +#define GIO0 (P2OUT&BIT0) +#define GIO0HIGH P2OUT|=BIT0 +#define GIO0LOW P2OUT&=~BIT0 +#define GIO0OUT P2OUT +#define GIO0DIR P2DIR +#define GIO0PIN BIT0 + +// network byte order converters +#define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \ + (((uint16_t)(x) & 0x00FF) << 8)) +#define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \ + (((uint32_t)(x) & 0x00FF0000) >> 8) | \ + (((uint32_t)(x) & 0x0000FF00) << 8) | \ + (((uint32_t)(x) & 0x000000FF) << 24)) + +#define ntohs htons +#define ntohl htonl +