cc56739d76e301fdc3bc7257c076a73ac1727830
[goodfet] / firmware / platforms / zigduino.h
1 /*! \file donbfet.h
2   \author Don A. Bailey
3   \brief Port descriptions for the DonbFET platform.
4 */
5
6 /* NB: define default CPU frequency */
7 //XXX #define F_CPU 8000000UL
8 #define F_CPU 20000000UL
9
10 #include <avr/io.h>
11 #include <avr/wdt.h>
12 #include <avr/boot.h>
13 #include <avr/sleep.h>
14 #include <avr/interrupt.h>
15 #include <avr/pgmspace.h>
16 #include <util/delay.h>
17 #include <inttypes.h>
18 #include <stdint.h>
19 #include <string.h>
20 #include <stdlib.h>
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <ctype.h>
24
25 /* all AVR SRAM starts after I/O mapped memory and registers */
26 #define RAMSTART 0x100
27
28 #ifndef PB0
29 # define PB0 PORTB0
30 #endif
31 #ifndef PA0
32 # define PA0 PORTA0
33 #endif
34 #ifndef PA1
35 # define PA1 PORTA1
36 #endif
37 #ifndef PA2
38 # define PA2 PORTA2
39 #endif
40 #ifndef PA3
41 # define PA3 PORTA3
42 #endif
43 #ifndef PA4
44 # define PA4 PORTA4
45 #endif
46 #ifndef PA5
47 # define PA5 PORTA5
48 #endif
49
50 //LED on P1.0
51 #define PLEDOUT PORTB
52 #define PLEDDIR DDRB
53 #define PLEDPIN PB0
54
55 //Use P3 instead of P5 for target I/O on chips without P5.
56 #ifdef msp430f2274
57 //#warning "No P5, using P3 instead.  Will break 2618 and 1612 support."
58 # define P5OUT P3OUT
59 # define P5DIR P3DIR
60 # define P5IN P3IN
61 # define P5REN P3REN
62
63 # define SPIOUT P3OUT
64 # define SPIDIR P3DIR
65 # define SPIIN  P3IN
66 # define SPIREN P3REN
67 #else
68
69 # if (platform == zigduino)
70 #  define SPIOUT PORTA
71 #  define SPIDIR DDRA
72 #  define SPIIN  PINA
73 //# define SPIREN P5REN
74 # endif
75 #endif
76
77 //This is how things used to work, don't do it anymore.
78 //#ifdef msp430x1612
79 //#define P5REN somedamnedextern
80 //#endif
81
82 #if (platform == zigduino)
83 # define SETSS PORTA|=SS;
84 # define CLRSS PORTA&=~SS;
85 # define DIRSS DDRA|=SS;
86 #else
87 //No longer works for Hope badge.
88 # define SETSS P5OUT|=BIT0
89 # define CLRSS P5OUT&=~BIT0
90 # define DIRSS P5DIR|=BIT0;
91 #endif
92
93 //Used for the Nordic port, !RST pin on regular GoodFET.
94 #define SETCE P2OUT|=BIT6
95 #define CLRCE P2OUT&=~BIT6
96 #define DIRCE P2DIR|=BIT6
97
98 // network byte order converters
99 #define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \
100                                  (((uint16_t)(x) & 0x00FF) << 8))
101 #define htonl(x) ((((uint32_t)(x) & 0xFF000000) >> 24) | \
102                                   (((uint32_t)(x) & 0x00FF0000) >> 8) | \
103                                   (((uint32_t)(x) & 0x0000FF00) << 8) | \
104                                   (((uint32_t)(x) & 0x000000FF) << 24))
105
106 #define ntohs htons
107 #define ntohl htonl
108
109 extern uint8_t zigduino_get_byte(uint16_t);
110