The friendly Operating System for the Internet of Things
arduino-atmega-common/include/board.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universit├Ąt Berlin, Hinnerk van Bruinehsen
3  * 2016 Laurent Navet <laurent.navet@gmail.com>
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
25 #ifndef BOARD_H
26 #define BOARD_H
27 
28 #include "cpu.h"
29 #include "arduino_pinmap.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
40 #define UART_STDIO_BAUDRATE (9600U)
41 
47 #ifdef CPU_ATMEGA328P
48 #define LED0_PIN GPIO_PIN(1, 5)
49 #define LED0_MASK (1 << DDB5)
50 #endif
51 
52 #ifdef CPU_ATMEGA2560
53 #define LED0_PIN GPIO_PIN(1, 7)
54 #define LED0_MASK (1 << DDB7)
55 #endif
56 
57 #define LED0_ON (PORTB |= LED0_MASK)
58 #define LED0_OFF (PORTB &= ~LED0_MASK)
59 #define LED0_TOGGLE (PORTB ^= LED0_MASK)
60 
67 #ifdef CPU_ATMEGA328P
68 #define AVR_CONTEXT_SWAP_INIT do { \
69  DDRC |= (1 << PC5); \
70  PCICR |= (1 << PCIE1); \
71  PCMSK1 |= (1 << PCINT13); \
72 } while (0)
73 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
74 #define AVR_CONTEXT_SWAP_TRIGGER PORTC ^= (1 << PC5)
75 #endif
76 
77 #ifdef CPU_ATMEGA2560
78 #define AVR_CONTEXT_SWAP_INIT do { \
79  DDRJ |= (1 << PJ6); \
80  PCICR |= (1 << PCIE1); \
81  PCMSK1 |= (1 << PCINT15); \
82 } while (0)
83 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
84 #define AVR_CONTEXT_SWAP_TRIGGER PORTJ ^= (1 << PJ6)
85 #endif
86 
91 #define XTIMER_WIDTH (16)
92 #define XTIMER_SHIFT (2)
93 #define XTIMER_HZ (250000UL)
94 #define XTIMER_BACKOFF (40)
95 
100 void board_init(void);
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif /* BOARD_H */
107 
Mapping from MCU pins to Arduino pins.
void board_init(void)
Initialize board specific hardware, including clock, LEDs and std-IO.