diff --git a/boards/common/atmega/include/periph_conf_atmega_common.h b/boards/common/atmega/include/periph_conf_atmega_common.h index a065f857ac..18a2474fa6 100644 --- a/boards/common/atmega/include/periph_conf_atmega_common.h +++ b/boards/common/atmega/include/periph_conf_atmega_common.h @@ -53,21 +53,6 @@ extern "C" { * * @details Only the 16 bit timers are used by xtimer * - * ATmega256RFR2 - * ============= - * The timer driver only supports the four 16-bit timers - * (Timer1, TST, Timer3, Timer4, Timer5), so those are the Timer we can use here. - * Timer 1, TST, PORT B5/6/7 Out, Port D4/6 In, Analog Comparator Input Capture, Output Compare Modulator, PWM - * Timer 3, TST, PORT E3/4/5 Out, Port E/6/7 In, Input or Output Compare and PWM Output - * Timer 4, TST, It can not be connected to any I/O Pin, - * Timer 5, TST, It can not be connected to any I/O Pin, - * - * Using Atmel Timer 4 and 5 seems to be the best choice - * Using Atmel Timer 4 as Xtimer - * and Atmel Timer 5 as timer available for the the application seems to be the best choice, - * as the special functions of the other timer are not lost. - * Atmel Timer1 to be used as PWM timer for RGB LED - * * ATmega328p * ========== * The timer driver only supports the 16-bit timer (Timer1) @@ -96,31 +81,7 @@ extern "C" { * @{ */ #ifndef TIMER_NUMOF -#if defined(CPU_ATMEGA128RFA1) || defined(CPU_ATMEGA256RFR2) - #define TIMER_NUMOF (3U) - #define TIMER_CHANNELS (3) - - #define TIMER_0 MEGA_TIMER4 - #define TIMER_0_MASK &TIMSK4 - #define TIMER_0_FLAG &TIFR4 - #define TIMER_0_ISRA TIMER4_COMPA_vect - #define TIMER_0_ISRB TIMER4_COMPB_vect - #define TIMER_0_ISRC TIMER4_COMPC_vect - - #define TIMER_1 MEGA_TIMER5 - #define TIMER_1_MASK &TIMSK5 - #define TIMER_1_FLAG &TIFR5 - #define TIMER_1_ISRA TIMER5_COMPA_vect - #define TIMER_1_ISRB TIMER5_COMPB_vect - #define TIMER_1_ISRC TIMER5_COMPC_vect - - #define TIMER_2 MEGA_TIMER1 - #define TIMER_2_MASK &TIMSK1 - #define TIMER_2_FLAG &TIFR1 - #define TIMER_2_ISRA TIMER1_COMPA_vect - #define TIMER_2_ISRB TIMER1_COMPB_vect - #define TIMER_2_ISRC TIMER1_COMPC_vect -#elif defined(CPU_ATMEGA328P) +#if defined(CPU_ATMEGA328P) #define TIMER_NUMOF (1U) #define TIMER_CHANNELS (2) diff --git a/cpu/atmega128rfa1/include/default_timer_config.h b/cpu/atmega128rfa1/include/default_timer_config.h new file mode 100644 index 0000000000..e3a7901e04 --- /dev/null +++ b/cpu/atmega128rfa1/include/default_timer_config.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) Josua Arndt, Steffen Robertz 2017 RWTH Aachen + * + * 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. + */ + +/** + * @ingroup cpu_atmega128rfa1 + * @{ + * + * @file + * @brief Default timer configuration + * + * @author Josua Arndt + * @author Steffen Robertz + */ + +#ifndef DEFAULT_TIMER_CONFIG_H +#define DEFAULT_TIMER_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TIMER_NUMOF +#define TIMER_NUMOF (3U) +#define TIMER_CHANNELS (3) + +#define TIMER_0 MEGA_TIMER4 +#define TIMER_0_MASK &TIMSK4 +#define TIMER_0_FLAG &TIFR4 +#define TIMER_0_ISRA TIMER4_COMPA_vect +#define TIMER_0_ISRB TIMER4_COMPB_vect +#define TIMER_0_ISRC TIMER4_COMPC_vect + +#define TIMER_1 MEGA_TIMER5 +#define TIMER_1_MASK &TIMSK5 +#define TIMER_1_FLAG &TIFR5 +#define TIMER_1_ISRA TIMER5_COMPA_vect +#define TIMER_1_ISRB TIMER5_COMPB_vect +#define TIMER_1_ISRC TIMER5_COMPC_vect + +#define TIMER_2 MEGA_TIMER1 +#define TIMER_2_MASK &TIMSK1 +#define TIMER_2_FLAG &TIFR1 +#define TIMER_2_ISRA TIMER1_COMPA_vect +#define TIMER_2_ISRB TIMER1_COMPB_vect +#define TIMER_2_ISRC TIMER1_COMPC_vect +#endif /* TIMER_NUMOF */ + +#ifdef __cplusplus +} +#endif + +#endif /* DEFAULT_TIMER_CONFIG_H */ +/** @} */ diff --git a/cpu/atmega128rfa1/include/periph_cpu.h b/cpu/atmega128rfa1/include/periph_cpu.h index 9cfa5ae6c0..eeb80e4c7c 100644 --- a/cpu/atmega128rfa1/include/periph_cpu.h +++ b/cpu/atmega128rfa1/include/periph_cpu.h @@ -73,5 +73,8 @@ enum { } #endif +#include "periph_conf.h" +#include "default_timer_config.h" + #endif /* PERIPH_CPU_H */ /** @} */ diff --git a/cpu/atmega256rfr2/include/default_timer_config.h b/cpu/atmega256rfr2/include/default_timer_config.h new file mode 100644 index 0000000000..8670c66553 --- /dev/null +++ b/cpu/atmega256rfr2/include/default_timer_config.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) Josua Arndt, Steffen Robertz 2017 RWTH Aachen + * + * 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. + */ + +/** + * @ingroup cpu_atmega256rfr2 + * @{ + * + * @file + * @brief Default timer configuration + * + * @author Josua Arndt + * @author Steffen Robertz + */ + +#ifndef DEFAULT_TIMER_CONFIG_H +#define DEFAULT_TIMER_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TIMER_NUMOF +#define TIMER_NUMOF (3U) +#define TIMER_CHANNELS (3) + +#define TIMER_0 MEGA_TIMER4 +#define TIMER_0_MASK &TIMSK4 +#define TIMER_0_FLAG &TIFR4 +#define TIMER_0_ISRA TIMER4_COMPA_vect +#define TIMER_0_ISRB TIMER4_COMPB_vect +#define TIMER_0_ISRC TIMER4_COMPC_vect + +#define TIMER_1 MEGA_TIMER5 +#define TIMER_1_MASK &TIMSK5 +#define TIMER_1_FLAG &TIFR5 +#define TIMER_1_ISRA TIMER5_COMPA_vect +#define TIMER_1_ISRB TIMER5_COMPB_vect +#define TIMER_1_ISRC TIMER5_COMPC_vect + +#define TIMER_2 MEGA_TIMER1 +#define TIMER_2_MASK &TIMSK1 +#define TIMER_2_FLAG &TIFR1 +#define TIMER_2_ISRA TIMER1_COMPA_vect +#define TIMER_2_ISRB TIMER1_COMPB_vect +#define TIMER_2_ISRC TIMER1_COMPC_vect +#endif /* TIMER_NUMOF */ + +#ifdef __cplusplus +} +#endif + +#endif /* DEFAULT_TIMER_CONFIG_H */ +/** @} */ diff --git a/cpu/atmega256rfr2/include/periph_cpu.h b/cpu/atmega256rfr2/include/periph_cpu.h index 49d1305e34..d2ffd79cd2 100644 --- a/cpu/atmega256rfr2/include/periph_cpu.h +++ b/cpu/atmega256rfr2/include/periph_cpu.h @@ -73,5 +73,8 @@ enum { } #endif +#include "periph_conf.h" +#include "default_timer_config.h" + #endif /* PERIPH_CPU_H */ /** @} */