arduino-atmega-common/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  * @ingroup boards_arduino-atmega-common
12  * @{
13  *
14  * @file
15  * @brief Common board configuration for Arduino Atmega boards
16  *
17  * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
18  * @author Laurent Navet <laurent.navet@gmail.com>
19  */
20 
21 #ifndef BOARD_COMMON_H
22 #define BOARD_COMMON_H
23 
24 #include "cpu.h"
25 #include "arduino_pinmap.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
38 #define UART_STDIO_BAUDRATE (9600U)
39 
45 #ifdef CPU_ATMEGA328P
46 #define LED0_PIN GPIO_PIN(1, 5)
47 #define LED0_MASK (1 << DDB5)
48 #endif
49 
50 #ifdef CPU_ATMEGA2560
51 #define LED0_PIN GPIO_PIN(1, 7)
52 #define LED0_MASK (1 << DDB7)
53 #endif
54 
55 #define LED0_ON (PORTB |= LED0_MASK)
56 #define LED0_OFF (PORTB &= ~LED0_MASK)
57 #define LED0_TOGGLE (PORTB ^= LED0_MASK)
58 
66 #ifdef CPU_ATMEGA328P
67 #define AVR_CONTEXT_SWAP_INIT do { \
68  DDRC |= (1 << PC5); \
69  PCICR |= (1 << PCIE1); \
70  PCMSK1 |= (1 << PCINT13); \
71 } while (0)
72 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
73 #define AVR_CONTEXT_SWAP_TRIGGER PORTC ^= (1 << PC5)
74 #endif
75 
76 #ifdef CPU_ATMEGA2560
77 #define AVR_CONTEXT_SWAP_INIT do { \
78  DDRJ |= (1 << PJ6); \
79  PCICR |= (1 << PCIE1); \
80  PCMSK1 |= (1 << PCINT15); \
81 } while (0)
82 #define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
83 #define AVR_CONTEXT_SWAP_TRIGGER PORTJ ^= (1 << PJ6)
84 #endif
85 
90 #define XTIMER_WIDTH (16)
91 #define XTIMER_SHIFT (2)
92 #define XTIMER_HZ (250000UL)
93 #define XTIMER_BACKOFF (40)
94 
99 void board_init(void);
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif /* BOARD_COMMON_H */
106 
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.