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