63a8a0a72969fd01bf30f735551cfcf2f2d02089
[goodfet] / firmware / platforms / apimote.h
1 /*! \file apimote.h\r
2   \author Ryan Speers\r
3   \brief Port descriptions for the Apimote platform.\r
4 */\r
5 \r
6 #ifndef _GNU_ASSEMBLER_\r
7 #include <msp430.h>\r
8 #endif\r
9 \r
10 //LED on P5.5 (pin 49) (LED1 red)\r
11 #define PLEDOUT P5OUT\r
12 #define PLEDDIR P5DIR\r
13 #define PLEDPIN BIT5\r
14 //LED on P5.6 (pin 50) (LED2 green)\r
15 #define PLED2OUT P5OUT\r
16 #define PLED2DIR P5DIR\r
17 #define PLED2PIN BIT6\r
18 //LED on P5.7 (pin 51) (LED3 blue)\r
19 #define PLED3OUT P5OUT\r
20 #define PLED3DIR P5DIR\r
21 #define PLED3PIN BIT7\r
22 \r
23 //mtx frx p34 \r
24 //mrx ftx p35\r
25 \r
26 //SPI\r
27 //TelosB:  29/3.1=RF_SI, 30/3.2=RF_SO, 31/3.3=RF_SCLK\r
28 //ApiMote: 29/3.1=RF_SI, 30/3.2=RF_SO, 31/3.3=RF_SCLK\r
29 #define SPIOUT P3OUT\r
30 #define SPIDIR P3DIR\r
31 #define SPIIN  P3IN\r
32 #define SPIREN P3REN\r
33 \r
34 /* For the radio to be used:\r
35    2.7 (!RST) must be low\r
36    2.0 (VREF_EN) must be high (cc2420-41 rf_vreg)\r
37    3.0 (!CS) must be low for the transaction.\r
38 */\r
39 \r
40 \r
41 \r
42 #define INITPLATFORM \\r
43   P2DIR |= BIT0+BIT7; \\r
44   P2OUT &= ~BIT7; \\r
45   P2OUT |= BIT0; \\r
46   P3DIR |= BIT0;\r
47 \r
48   /*\r
49   P1DIR = 0xe0;  \\r
50   P1OUT = 0x00;\\r
51   P2DIR = 0x7b;\\r
52   P2OUT = 0x10;\\r
53   P3DIR = 0xf1;\\r
54   P3OUT = 0x00;\\r
55   P4DIR = 0xfd;\\r
56   P4OUT = 0xFd;\\r
57   P5DIR = 0xff;\\r
58   P5OUT = 0xff;\\r
59   P6DIR = 0xff;\\r
60   P6OUT = 0x00;\r
61   */\r
62 \r
63 \r
64 //RF Control\r
65 //TelosB:  Radio CS is 38/P4.2 (to CC2420 pin31)\r
66 //ApiMote: Radio CS is 28/P3.0\r
67 #define SETSS P3OUT|=BIT0\r
68 #define CLRSS P3OUT&=~BIT0\r
69 #define DIRSS P3DIR|=BIT0\r
70 \r
71 //CC2420 Chip Enable\r
72 //TelosB:  Radio RESETn is 42/P4.6 (to CC2420 pin21)\r
73 //ApiMote: Radio RESETn is 27/P2.7 (to CC2420 pin21)\r
74 #define SETCE P2OUT|=BIT7\r
75 #define CLRCE P2OUT&=~BIT7\r
76 #define DIRCE P2DIR|=BIT7\r
77 \r
78 //CC2420 signals\r
79 #define SFD   (P2IN&BIT6) //TelosB 37/P4.1 -> ApiMote 26/P2.6\r
80 #define FIFOP (P2IN&BIT4) //TelosB 12/P1.0 -> ApiMote 24/P2.4 (rf_pkt cc2420-29)\r
81 #define FIFO  (P2IN&BIT3) //TelosB 15/P1.3 -> ApiMote 23/P2.3 (rf_gio0 cc2420-30)\r
82 \r
83 // network byte order converters\r
84 #define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \\r
85                                  (((uint16_t)(x) & 0x00FF) << 8))\r
86 #define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \\r
87                                   (((uint32_t)(x) & 0x00FF0000) >> 8) | \\r
88                                   (((uint32_t)(x) & 0x0000FF00) << 8) | \\r
89                                   (((uint32_t)(x) & 0x000000FF) << 24))\r
90 \r
91 #define ntohs htons\r
92 #define ntohl htonl\r
93 \r