From dfa686327590bc3192ca40191909e56b6f9f0ffe Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 27 May 2020 20:10:07 +0200 Subject: [PATCH] cpu/atmega{1281,2560}: Relocate default timer config --- .../include/periph_conf_atmega_common.h | 44 --------------- cpu/atmega1281/include/default_timer_config.h | 54 +++++++++++++++++++ cpu/atmega1281/include/periph_cpu.h | 3 ++ cpu/atmega2560/include/default_timer_config.h | 54 +++++++++++++++++++ cpu/atmega2560/include/periph_cpu.h | 3 ++ 5 files changed, 114 insertions(+), 44 deletions(-) create mode 100644 cpu/atmega1281/include/default_timer_config.h create mode 100644 cpu/atmega2560/include/default_timer_config.h diff --git a/boards/common/atmega/include/periph_conf_atmega_common.h b/boards/common/atmega/include/periph_conf_atmega_common.h index 6b611a69fa..2cfafdbee0 100644 --- a/boards/common/atmega/include/periph_conf_atmega_common.h +++ b/boards/common/atmega/include/periph_conf_atmega_common.h @@ -48,50 +48,6 @@ extern "C" { #endif /* CLOCK_CORECLOCK */ /** @} */ -/** - * @name Timer configuration - * - * @details Only the 16 bit timers are used by xtimer - * - * ATmega1281 - * ========== - * The ATmega1281 has 6 timers. Timer0 and Timer2 are 8 Bit Timers, - * Timer0 has special uses too and therefore we'll avoid using it. - * - * The timer driver only supports the four 16-bit timers (Timer1, Timer3, - * Timer4, Timer5), so those are the only ones we can use here. - * - * ATmega2560 - * ========== - * The timer driver only supports the four 16-bit timers (Timer1, Timer3, - * Timer4, Timer5), so those are the only ones we can use here. - * - * @{ - */ -#ifndef TIMER_NUMOF -#if defined(CPU_ATMEGA2560) || defined(CPU_ATMEGA1281) - #define TIMER_NUMOF (2U) - #define TIMER_CHANNELS (3) - - #define TIMER_0 MEGA_TIMER1 - #define TIMER_0_MASK &TIMSK1 - #define TIMER_0_FLAG &TIFR1 - #define TIMER_0_ISRA TIMER1_COMPA_vect - #define TIMER_0_ISRB TIMER1_COMPB_vect - #define TIMER_0_ISRC TIMER1_COMPC_vect - - #define TIMER_1 MEGA_TIMER4 - #define TIMER_1_MASK &TIMSK4 - #define TIMER_1_FLAG &TIFR4 - #define TIMER_1_ISRA TIMER4_COMPA_vect - #define TIMER_1_ISRB TIMER4_COMPB_vect - #define TIMER_1_ISRC TIMER4_COMPC_vect -#else - #define TIMER_NUMOF (0U) -#endif -#endif /* TIMER_NUMOF */ -/** @} */ - /** * @name UART configuration * diff --git a/cpu/atmega1281/include/default_timer_config.h b/cpu/atmega1281/include/default_timer_config.h new file mode 100644 index 0000000000..41fb5f7857 --- /dev/null +++ b/cpu/atmega1281/include/default_timer_config.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2015 HAW Hamburg + * 2016 Freie Universität Berlin + * 2016 INRIA + * + * 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_atmega1281 + * @{ + * + * @file + * @brief Default timer configuration + * + * @author René Herthel + * @author Hauke Petersen + * @author Francisco Acosta + */ + +#ifndef DEFAULT_TIMER_CONFIG_H +#define DEFAULT_TIMER_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TIMER_NUMOF +#define TIMER_NUMOF (2U) +#define TIMER_CHANNELS (3) + +#define TIMER_0 MEGA_TIMER1 +#define TIMER_0_MASK &TIMSK1 +#define TIMER_0_FLAG &TIFR1 +#define TIMER_0_ISRA TIMER1_COMPA_vect +#define TIMER_0_ISRB TIMER1_COMPB_vect +#define TIMER_0_ISRC TIMER1_COMPC_vect + +#define TIMER_1 MEGA_TIMER4 +#define TIMER_1_MASK &TIMSK4 +#define TIMER_1_FLAG &TIFR4 +#define TIMER_1_ISRA TIMER4_COMPA_vect +#define TIMER_1_ISRB TIMER4_COMPB_vect +#define TIMER_1_ISRC TIMER4_COMPC_vect +#endif /* TIMER_NUMOF */ + +#ifdef __cplusplus +} +#endif + +#endif /* DEFAULT_TIMER_CONFIG_H */ +/** @} */ diff --git a/cpu/atmega1281/include/periph_cpu.h b/cpu/atmega1281/include/periph_cpu.h index 07ebe56a75..52ff42c91b 100644 --- a/cpu/atmega1281/include/periph_cpu.h +++ b/cpu/atmega1281/include/periph_cpu.h @@ -75,5 +75,8 @@ enum { } #endif +#include "periph_conf.h" +#include "default_timer_config.h" + #endif /* PERIPH_CPU_H */ /** @} */ diff --git a/cpu/atmega2560/include/default_timer_config.h b/cpu/atmega2560/include/default_timer_config.h new file mode 100644 index 0000000000..b38e8fe312 --- /dev/null +++ b/cpu/atmega2560/include/default_timer_config.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2015 HAW Hamburg + * 2016 Freie Universität Berlin + * 2016 INRIA + * + * 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_atmega2560 + * @{ + * + * @file + * @brief Default timer configuration + * + * @author René Herthel + * @author Hauke Petersen + * @author Francisco Acosta + */ + +#ifndef DEFAULT_TIMER_CONFIG_H +#define DEFAULT_TIMER_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TIMER_NUMOF +#define TIMER_NUMOF (2U) +#define TIMER_CHANNELS (3) + +#define TIMER_0 MEGA_TIMER1 +#define TIMER_0_MASK &TIMSK1 +#define TIMER_0_FLAG &TIFR1 +#define TIMER_0_ISRA TIMER1_COMPA_vect +#define TIMER_0_ISRB TIMER1_COMPB_vect +#define TIMER_0_ISRC TIMER1_COMPC_vect + +#define TIMER_1 MEGA_TIMER4 +#define TIMER_1_MASK &TIMSK4 +#define TIMER_1_FLAG &TIFR4 +#define TIMER_1_ISRA TIMER4_COMPA_vect +#define TIMER_1_ISRB TIMER4_COMPB_vect +#define TIMER_1_ISRC TIMER4_COMPC_vect +#endif /* TIMER_NUMOF */ + +#ifdef __cplusplus +} +#endif + +#endif /* DEFAULT_TIMER_CONFIG_H */ +/** @} */ diff --git a/cpu/atmega2560/include/periph_cpu.h b/cpu/atmega2560/include/periph_cpu.h index 2002edc28c..00cd85dc21 100644 --- a/cpu/atmega2560/include/periph_cpu.h +++ b/cpu/atmega2560/include/periph_cpu.h @@ -77,5 +77,8 @@ enum { } #endif +#include "periph_conf.h" +#include "default_timer_config.h" + #endif /* PERIPH_CPU_H */ /** @} */