Update to add support for MSP430-GCC 4.6 which moved things around;
[goodfet] / firmware / platforms / goodfet.h
1 /*! \file goodfet.h
2   \author Travis Goodspeed
3   \brief Port descriptions for the GoodFET platform.
4 */
5
6 #ifdef __MSPGCC__
7 #include <msp430.h>
8 #else
9 #include <signal.h>
10 #include <io.h>
11 #include <iomacros.h>
12 #endif
13
14 //LED on P1.0
15 #define PLEDOUT P1OUT
16 #define PLEDDIR P1DIR
17 #define PLEDPIN BIT0
18
19 //Use P3 instead of P5 for target I/O on chips without P5.
20 #ifdef msp430f2274
21 //#warning "No P5, using P3 instead.  Will break 2618 and 1612 support."
22 #define P5OUT P3OUT
23 #define P5DIR P3DIR
24 #define P5IN P3IN
25 #define P5REN P3REN
26
27 #define SPIOUT P3OUT
28 #define SPIDIR P3DIR
29 #define SPIIN  P3IN
30 #define SPIREN P3REN
31 #else
32
33 #define SPIOUT P5OUT
34 #define SPIDIR P5DIR
35 #define SPIIN  P5IN
36 #define SPIREN P5REN
37
38 #endif
39
40 //This is how things used to work, don't do it anymore.
41 //#ifdef msp430x1612
42 //#define P5REN somedamnedextern
43 //#endif
44
45 //No longer works for Hope badge.
46 #define SETSS P5OUT|=BIT0
47 #define CLRSS P5OUT&=~BIT0
48 #define DIRSS P5DIR|=BIT0;
49
50 //Used for the Nordic port, !RST pin on regular GoodFET.
51 #define SETCE P2OUT|=BIT6
52 #define CLRCE P2OUT&=~BIT6
53 #define DIRCE P2DIR|=BIT6
54
55 // network byte order converters
56 #define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \
57                                  (((uint16_t)(x) & 0x00FF) << 8))
58 #define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \
59                                   (((uint32_t)(x) & 0x00FF0000) >> 8) | \
60                                   (((uint32_t)(x) & 0x0000FF00) << 8) | \
61                                   (((uint32_t)(x) & 0x000000FF) << 24))
62
63 #define ntohs htons
64 #define ntohl htonl
65