waspmote-pro/include/board.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universit├Ąt Berlin, Hinnerk van Bruinehsen
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef BOARD_H
23 #define BOARD_H
24 
25 #include "cpu.h"
26 #include "waspmote_pinmap.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 #define UART_STDIO_BAUDRATE (9600U)
37 
42 #ifdef XBEE_UART
43 #if XBEE_UART == 0
44 #define UART_STDIO_DEV (UART_DEV(1))
45 #else
46 #define UART_STDIO_DEV (UART_DEV(0))
47 #endif
48 #endif
49 
54 #define LED0_PORT PORTD
55 #define LED1_PORT PORTC
56 #define LED0_PIN (1 << 6)
57 #define LED1_PIN (1 << 1)
58 
64 #define LED0_ENABLE_PORT DDRD |= (1 << DDD6)
65 #define LED0_ON LED0_PORT |= LED0_PIN
66 #define LED0_OFF LED0_PORT &= ~LED0_PIN
67 #define LED0_TOGGLE LED0_PORT ^= LED0_PIN;
68 
69 #define LED1_ENABLE_PORT DDRC |= (1 << DDC1)
70 #define LED1_ON LED1_PORT |= LED1_PIN
71 #define LED1_OFF LED1_PORT &= ~LED1_PIN
72 #define LED1_TOGGLE LED1_PORT ^= LED1_PIN;
73 
74 /* for compatibility to other boards */
75 #define LED_GREEN_ON LED1_ON
76 #define LED_GREEN_OFF LED1_OFF
77 #define LED_GREEN_TOGGLE LED1_TOGGLE
78 #define LED_RED_ON LED0_ON
79 #define LED_RED_OFF LED0_OFF
80 #define LED_RED_TOGGLE LED0_TOGGLE
81 
87 #define MUX_PW_PORT PORTD
88 #define MUX0_PORT PORTB
89 #define MUX1_PORT PORTB
90 #define MUX_USB_XBEE_PORT PORTD
91 #define MUX_PW_PIN (1 << 7)
92 #define MUX0_PIN (1 << 6)
93 #define MUX1_PIN (1 << 7)
94 #define MUX_USB_XBEE_PIN (1 << 5)
95 
96 #define MUX_PW_ENABLE_PORT DDRD |= (1 << DDD7);
97 #define MUX_PW_ON MUX_PW_PORT |= MUX_PW_PIN
98 #define MUX_PW_OFF MUX_PW_PORT &= ~MUX_PW_PIN
99 
100 #define MUX0_ENABLE_PORT DDRB |= (1 << DDB6)
101 #define MUX0_ON MUX0_PORT |= MUX0_PIN
102 #define MUX0_OFF MUX0_PORT &= ~MUX0_PIN
103 
104 #define MUX1_ENABLE_PORT DDRB |= (1 << DDB7)
105 #define MUX1_ON MUX1_PORT |= MUX1_PIN
106 #define MUX1_OFF MUX1_PORT &= ~MUX1_PIN
107 
108 #define MUX_USB_XBEE_ENABLE_PORT DDRD |= (1 << DDD5)
109 #define MUX_USB_XBEE_ON MUX_USB_XBEE_PORT |= MUX_USB_XBEE_PIN
110 #define MUX_USB_XBEE_OFF MUX_USB_XBEE_PORT &= ~MUX_USB_XBEE_PIN
111 
112 /* Multiplexer settings to enable UART1 on the desired module
113  *
114  * --------------
115  * MUX0_OFF & MUX1_ON ---> GPS MODULE
116  * MUX0_ON & MUX1_ON ---> SOCKET1
117  * MUX0_ON & MUX1_OFF ---> AUX1 MODULE
118  * MUX0_OFF & MUX1_OFF ---> AUX2 MODULE
119  *
120  * Multiplexer setting to enable UART0 to the desired module
121  *
122  * --------------
123  * MUX_USB_XBEE_OFF ---> USB MODULE
124  * MUX_USB_XBEE_ON ---> SOCKET0
125  *
126  */
127 
128 #define SET_MUX_GPS MUX_PW_ENABLE_PORT; MUX_PW_ON; \
129  MUX0_ENABLE_PORT; MUX1_ENABLE_PORT; \
130  MUX0_OFF; MUX1_ON
131 #define SET_MUX_SOCKET1 MUX_PW_ENABLE_PORT; MUX_PW_ON; \
132  MUX0_ENABLE_PORT; MUX1_ENABLE_PORT; \
133  MUX0_ON; MUX1_ON
134 #define SET_MUX_AUX1_MODULE MUX_PW_ENABLE_PORT; MUX_PW_ON; \
135  MUX0_ENABLE_PORT; MUX1_ENABLE_PORT; \
136  MUX0_ON; MUX1_OFF
137 #define SET_MUX_AUX2_MODULE MUX_PW_ENABLE_PORT; MUX_PW_ON; \
138  MUX0_ENABLE_PORT; MUX1_ENABLE_PORT; \
139  MUX0_OFF; MUX1_OFF
140 #define SET_MUX_USB_MODULE MUX_PW_ENABLE_PORT; MUX_PW_ON; \
141  MUX_USB_XBEE_ENABLE_PORT; \
142  MUX_USB_XBEE_OFF
143 #define SET_MUX_SOCKET0 MUX_PW_ENABLE_PORT; MUX_PW_ON; \
144  MUX_USB_XBEE_ENABLE_PORT; \
145  MUX_USB_XBEE_ON
146 
153 #define AVR_CONTEXT_SWAP_INIT do { \
154  DDRB |= (1 << PB5); \
155  PCICR |= (1 << PCIE0); \
156  PCMSK0 |= (1 << PCINT5); \
157 } while (0)
158 
159 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT0_vect
160 #define AVR_CONTEXT_SWAP_TRIGGER PORTB ^= (1 << PB5)
161 
167 #define XTIMER_WIDTH (16)
168 #define XTIMER_SHIFT (4)
169 #define XTIMER_HZ (62500UL)
170 #define XTIMER_BACKOFF (40)
171 
176 void board_init(void);
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 #endif /* BOARD_H */
183 
Mapping from MCU pins to Waspmote pins.
void board_init(void)
Initialize board specific hardware, including clock, LEDs and std-IO.