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