arduino-atmega/include/board_common.h
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 
10 /*
11  * @defgroup boards_common_arduino-atmega Arduino Atmega Common
12  * @ingroup boards_common
13  * @brief Shared files and configuration for Arduino Atmega boards.
14  * @{
15  *
16  * @file
17  * @brief Common board configuration for Arduino Atmega boards
18  *
19  * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
20  * @author Laurent Navet <laurent.navet@gmail.com>
21  */
22 
23 #ifndef BOARD_COMMON_H
24 #define BOARD_COMMON_H
25 
26 #include "cpu.h"
27 #include "arduino_pinmap.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
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 
68 #ifdef CPU_ATMEGA328P
69 #define AVR_CONTEXT_SWAP_INIT do { \
70  DDRD |= (1 << PD7); \
71  PCICR |= (1 << PCIE2); \
72  PCMSK2 |= (1 << PCINT23); \
73 } while (0)
74 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT2_vect
75 #define AVR_CONTEXT_SWAP_TRIGGER PORTD ^= (1 << PD7)
76 #endif
77 
78 #ifdef CPU_ATMEGA2560
79 #define AVR_CONTEXT_SWAP_INIT do { \
80  DDRJ |= (1 << PJ6); \
81  PCICR |= (1 << PCIE1); \
82  PCMSK1 |= (1 << PCINT15); \
83 } while (0)
84 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
85 #define AVR_CONTEXT_SWAP_TRIGGER PORTJ ^= (1 << PJ6)
86 #endif
87 
92 #define XTIMER_WIDTH (16)
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_COMMON_H */
107 
Mapping from MCU pins to Arduino pins for Arduino Atmega boards.
void board_init(void)
Initialize board specific hardware, including clock, LEDs and std-IO.