Facedancer11 support. Boards just shipped from China.
[goodfet] / firmware / platforms / z1.h
1 /*! \file z1.h
2   \author Travis Goodspeed
3   \brief Port descriptions for the Zolertia Z1 platform.
4   
5   This file defines the Zolertia hardware, so that the GoodFET firmware
6   may be loaded onto it.  Adjustments are identical to the Telos B.
7
8 */
9
10 #ifndef _GNU_ASSEMBLER_
11 #include <msp430.h>
12 #endif
13
14 //LED on P5.4 (LED1 red)
15 #define PLEDOUT P5OUT
16 #define PLEDDIR P5DIR
17 #define PLEDPIN BIT4
18 //LED on P5.5 (LED2 green)
19 #define PLED2OUT P5OUT
20 #define PLED2DIR P5DIR
21 #define PLED2PIN BIT5
22 //LED on P5.6 (LED3 blue)
23 #define PLED3OUT P5OUT
24 #define PLED3DIR P5DIR
25 #define PLED3PIN BIT6
26
27
28 #define SPIOUT P3OUT
29 #define SPIDIR P3DIR
30 #define SPIIN  P3IN
31 #define SPIREN P3REN
32
33
34 /* For the radio to be used:
35    4.6 (!RST) must be low
36    4.5 (VREF_EN) must be high
37    4.2 (!CS) must be low for the transaction.
38 */
39
40 #define INITPLATFORM \
41   P1DIR = 0xe0;\
42   P1OUT = 0x00;\
43   P2DIR = 0x7b;\
44   P2OUT = 0x10;\
45   P3DIR = 0xf1;\
46   P3OUT = 0x00;\
47   P4DIR = 0xfd;\
48   P4OUT = 0xFd;\
49   P5DIR = 0xff;\
50   P5OUT = 0xff;\
51   P6DIR = 0xff;\
52   P6OUT = 0x00;
53
54 //Radio CS is P4.2
55 #define SETSS P4OUT|=BIT2
56 #define CLRSS P4OUT&=~BIT2
57 #define DIRSS P4DIR|=BIT2
58
59 //Flash CS is P4.4, redefine only for the SPI app.
60 #ifdef SPIAPPLICATION
61 #undef SETSS
62 #undef CLRSS
63 #undef DIRSS
64 #define SETSS P4OUT|=BIT4
65 #define CLRSS P4OUT&=~BIT4
66 #define DIRSS P4DIR|=BIT4
67 #endif
68
69 //CC2420 Chip Enable
70 #define SETCE P4OUT|=BIT6
71 #define CLRCE P4OUT&=~BIT6
72 #define DIRCE P4DIR|=BIT6
73
74 //CC2420 signals
75 #define SFD   (P4IN&BIT1)
76 #define FIFOP (P1IN&BIT0)
77 #define FIFO  (P1IN&BIT3)
78
79 //GPIO Expansion Pins
80 #define GIO0  (P2OUT&BIT0)
81 #define GIO0HIGH P2OUT|=BIT0
82 #define GIO0LOW P2OUT&=~BIT0
83 #define GIO0OUT P2OUT
84 #define GIO0DIR P2DIR
85 #define GIO0PIN BIT0
86
87 // network byte order converters
88 #define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \
89                                  (((uint16_t)(x) & 0x00FF) << 8))
90 #define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \
91                                   (((uint32_t)(x) & 0x00FF0000) >> 8) | \
92                                   (((uint32_t)(x) & 0x0000FF00) << 8) | \
93                                   (((uint32_t)(x) & 0x000000FF) << 24))
94
95 #define ntohs htons
96 #define ntohl htonl
97