The friendly Operating System for the Internet of Things
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 
43 #ifdef XBEE_UART
44 #if XBEE_UART == 0
45 #define UART_STDIO_DEV (UART_DEV(1))
46 #else
47 #define UART_STDIO_DEV (UART_DEV(0))
48 #endif
49 #endif
50 
57 #define LED0_PORT PORTD
58 #define LED1_PORT PORTC
59 #define LED0_PIN (1 << 6)
60 #define LED1_PIN (1 << 1)
61 
67 #define LED0_ENABLE_PORT DDRD |= (1 << DDD6)
68 #define LED0_ON LED0_PORT |= LED0_PIN
69 #define LED0_OFF LED0_PORT &= ~LED0_PIN
70 #define LED0_TOGGLE LED0_PORT ^= LED0_PIN;
71 
72 #define LED1_ENABLE_PORT DDRC |= (1 << DDC1)
73 #define LED1_ON LED1_PORT |= LED1_PIN
74 #define LED1_OFF LED1_PORT &= ~LED1_PIN
75 #define LED1_TOGGLE LED1_PORT ^= LED1_PIN;
76 
77 /* for compatibility to other boards */
78 #define LED_GREEN_ON LED1_ON
79 #define LED_GREEN_OFF LED1_OFF
80 #define LED_GREEN_TOGGLE LED1_TOGGLE
81 #define LED_RED_ON LED0_ON
82 #define LED_RED_OFF LED0_OFF
83 #define LED_RED_TOGGLE LED0_TOGGLE
84 
90 #define MUX_PW_PORT PORTD
91 #define MUX0_PORT PORTB
92 #define MUX1_PORT PORTB
93 #define MUX_USB_XBEE_PORT PORTD
94 #define MUX_PW_PIN (1 << 7)
95 #define MUX0_PIN (1 << 6)
96 #define MUX1_PIN (1 << 7)
97 #define MUX_USB_XBEE_PIN (1 << 5)
98 
99 #define MUX_PW_ENABLE_PORT DDRD |= (1 << DDD7);
100 #define MUX_PW_ON MUX_PW_PORT |= MUX_PW_PIN
101 #define MUX_PW_OFF MUX_PW_PORT &= ~MUX_PW_PIN
102 
103 #define MUX0_ENABLE_PORT DDRB |= (1 << DDB6)
104 #define MUX0_ON MUX0_PORT |= MUX0_PIN
105 #define MUX0_OFF MUX0_PORT &= ~MUX0_PIN
106 
107 #define MUX1_ENABLE_PORT DDRB |= (1 << DDB7)
108 #define MUX1_ON MUX1_PORT |= MUX1_PIN
109 #define MUX1_OFF MUX1_PORT &= ~MUX1_PIN
110 
111 #define MUX_USB_XBEE_ENABLE_PORT DDRD |= (1 << DDD5)
112 #define MUX_USB_XBEE_ON MUX_USB_XBEE_PORT |= MUX_USB_XBEE_PIN
113 #define MUX_USB_XBEE_OFF MUX_USB_XBEE_PORT &= ~MUX_USB_XBEE_PIN
114 
115 /* Multiplexer settings to enable UART1 on the desired module
116  *
117  * --------------
118  * MUX0_OFF & MUX1_ON ---> GPS MODULE
119  * MUX0_ON & MUX1_ON ---> SOCKET1
120  * MUX0_ON & MUX1_OFF ---> AUX1 MODULE
121  * MUX0_OFF & MUX1_OFF ---> AUX2 MODULE
122  *
123  * Multiplexer setting to enable UART0 to the desired module
124  *
125  * --------------
126  * MUX_USB_XBEE_OFF ---> USB MODULE
127  * MUX_USB_XBEE_ON ---> SOCKET0
128  *
129  */
130 
131 #define SET_MUX_GPS MUX_PW_ENABLE_PORT; MUX_PW_ON; \
132  MUX0_ENABLE_PORT; MUX1_ENABLE_PORT; \
133  MUX0_OFF; MUX1_ON
134 #define SET_MUX_SOCKET1 MUX_PW_ENABLE_PORT; MUX_PW_ON; \
135  MUX0_ENABLE_PORT; MUX1_ENABLE_PORT; \
136  MUX0_ON; MUX1_ON
137 #define SET_MUX_AUX1_MODULE MUX_PW_ENABLE_PORT; MUX_PW_ON; \
138  MUX0_ENABLE_PORT; MUX1_ENABLE_PORT; \
139  MUX0_ON; MUX1_OFF
140 #define SET_MUX_AUX2_MODULE MUX_PW_ENABLE_PORT; MUX_PW_ON; \
141  MUX0_ENABLE_PORT; MUX1_ENABLE_PORT; \
142  MUX0_OFF; MUX1_OFF
143 #define SET_MUX_USB_MODULE MUX_PW_ENABLE_PORT; MUX_PW_ON; \
144  MUX_USB_XBEE_ENABLE_PORT; \
145  MUX_USB_XBEE_OFF
146 #define SET_MUX_SOCKET0 MUX_PW_ENABLE_PORT; MUX_PW_ON; \
147  MUX_USB_XBEE_ENABLE_PORT; \
148  MUX_USB_XBEE_ON
149 
150 
158 #define AVR_CONTEXT_SWAP_INIT do { \
159  DDRB |= (1 << PB5); \
160  PCICR |= (1 << PCIE0); \
161  PCMSK0 |= (1 << PCINT5); \
162 } while (0)
163 
164 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT0_vect
165 #define AVR_CONTEXT_SWAP_TRIGGER PORTB ^= (1 << PB5)
166 
172 #define XTIMER_WIDTH (16)
173 #define XTIMER_SHIFT (4)
174 #define XTIMER_HZ (62500UL)
175 #define XTIMER_BACKOFF (40)
176 
181 void board_init(void);
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* BOARD_H */
188 
Mapping from MCU pins to Waspmote pins.
void board_init(void)
Initialize board specific hardware, including clock, LEDs and std-IO.