2016-09-05 21:12:47 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
|
|
|
|
* 2016 Laurent Navet <laurent.navet@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2017-02-02 20:01:11 +01:00
|
|
|
* @defgroup boards_arduino-atmega-common Arduino common
|
2016-09-05 21:12:47 +02:00
|
|
|
* @ingroup boards
|
|
|
|
* @brief Board specific files for the arduino Uno and
|
|
|
|
* @brief Duemilanove boards.
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Board specific definitions for the arduino Uno and
|
|
|
|
* @brief Duemilanove boards.
|
|
|
|
*
|
|
|
|
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
|
|
|
* @author Laurent Navet <laurent.navet@gmail.com>
|
|
|
|
*/
|
|
|
|
|
2017-04-13 17:39:12 +02:00
|
|
|
#ifndef BOARD_COMMON_H
|
|
|
|
#define BOARD_COMMON_H
|
2016-09-05 21:12:47 +02:00
|
|
|
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "arduino_pinmap.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @name STDIO configuration
|
|
|
|
*
|
|
|
|
* As the CPU is too slow to handle 115200 baud, we set the default
|
|
|
|
* baudrate to 9600 for this board
|
2016-09-05 21:12:47 +02:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define UART_STDIO_BAUDRATE (9600U)
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @name LED pin definitions and handlers
|
2016-09-05 21:12:47 +02:00
|
|
|
* @{
|
|
|
|
*/
|
2017-02-02 20:01:11 +01:00
|
|
|
#ifdef CPU_ATMEGA328P
|
2016-09-05 21:12:47 +02:00
|
|
|
#define LED0_PIN GPIO_PIN(1, 5)
|
|
|
|
#define LED0_MASK (1 << DDB5)
|
2017-02-02 20:01:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CPU_ATMEGA2560
|
|
|
|
#define LED0_PIN GPIO_PIN(1, 7)
|
|
|
|
#define LED0_MASK (1 << DDB7)
|
|
|
|
#endif
|
2016-09-05 21:12:47 +02:00
|
|
|
|
|
|
|
#define LED0_ON (PORTB |= LED0_MASK)
|
|
|
|
#define LED0_OFF (PORTB &= ~LED0_MASK)
|
|
|
|
#define LED0_TOGGLE (PORTB ^= LED0_MASK)
|
|
|
|
/** @} */
|
|
|
|
|
2016-09-10 00:09:27 +02:00
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @brief Context swap defines
|
|
|
|
*
|
|
|
|
* Setup to use PC5 which is pin change interrupt 13 (PCINT13)
|
|
|
|
* This emulates a software triggered interrupt
|
|
|
|
*/
|
2017-02-02 20:01:11 +01:00
|
|
|
#ifdef CPU_ATMEGA328P
|
2016-09-10 00:09:27 +02:00
|
|
|
#define AVR_CONTEXT_SWAP_INIT do { \
|
2017-01-10 21:48:39 +01:00
|
|
|
DDRC |= (1 << PC5); \
|
2016-09-10 00:09:27 +02:00
|
|
|
PCICR |= (1 << PCIE1); \
|
2017-01-10 21:48:39 +01:00
|
|
|
PCMSK1 |= (1 << PCINT13); \
|
2016-09-10 00:09:27 +02:00
|
|
|
} while (0)
|
|
|
|
#define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
|
2017-01-10 21:48:39 +01:00
|
|
|
#define AVR_CONTEXT_SWAP_TRIGGER PORTC ^= (1 << PC5)
|
2017-02-02 20:01:11 +01:00
|
|
|
#endif
|
2016-09-10 00:09:27 +02:00
|
|
|
|
2017-02-02 20:01:11 +01:00
|
|
|
#ifdef CPU_ATMEGA2560
|
|
|
|
#define AVR_CONTEXT_SWAP_INIT do { \
|
|
|
|
DDRJ |= (1 << PJ6); \
|
|
|
|
PCICR |= (1 << PCIE1); \
|
|
|
|
PCMSK1 |= (1 << PCINT15); \
|
|
|
|
} while (0)
|
|
|
|
#define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
|
|
|
|
#define AVR_CONTEXT_SWAP_TRIGGER PORTJ ^= (1 << PJ6)
|
|
|
|
#endif
|
2016-09-10 00:09:27 +02:00
|
|
|
|
2016-09-05 21:12:47 +02:00
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @name xtimer configuration values
|
2016-09-05 21:12:47 +02:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define XTIMER_WIDTH (16)
|
|
|
|
#define XTIMER_SHIFT (2)
|
2016-07-05 21:04:58 +02:00
|
|
|
#define XTIMER_HZ (250000UL)
|
2016-09-05 21:12:47 +02:00
|
|
|
#define XTIMER_BACKOFF (40)
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
2017-04-10 19:04:32 +02:00
|
|
|
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
|
2016-09-05 21:12:47 +02:00
|
|
|
*/
|
|
|
|
void board_init(void);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-04-13 17:39:12 +02:00
|
|
|
#endif /* BOARD_COMMON_H */
|
2016-09-05 21:12:47 +02:00
|
|
|
/** @} */
|