diff --git a/boards/common/arduino-atmega/include/periph_conf.h b/boards/common/arduino-atmega/include/periph_conf.h index 5a8a026a18..8f9bc59943 100644 --- a/boards/common/arduino-atmega/include/periph_conf.h +++ b/boards/common/arduino-atmega/include/periph_conf.h @@ -49,7 +49,8 @@ extern "C" { * @{ */ #ifdef CPU_ATMEGA328P -#define TIMER_NUMOF (2U) +#define TIMER_NUMOF (1U) +#define TIMER_CHANNELS (2) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 @@ -60,6 +61,7 @@ extern "C" { #ifdef CPU_ATMEGA2560 #define TIMER_NUMOF (2U) +#define TIMER_CHANNELS (3) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 diff --git a/boards/jiminy-mega256rfr2/include/periph_conf.h b/boards/jiminy-mega256rfr2/include/periph_conf.h index 40c5600cd2..181aa2fd61 100644 --- a/boards/jiminy-mega256rfr2/include/periph_conf.h +++ b/boards/jiminy-mega256rfr2/include/periph_conf.h @@ -57,6 +57,7 @@ extern "C" { * @{ */ #define TIMER_NUMOF (3U) +#define TIMER_CHANNELS (3) #define TIMER_0 MEGA_TIMER4 #define TIMER_0_MASK &TIMSK4 diff --git a/boards/mega-xplained/include/periph_conf.h b/boards/mega-xplained/include/periph_conf.h index 6acb52069b..1be14db60c 100644 --- a/boards/mega-xplained/include/periph_conf.h +++ b/boards/mega-xplained/include/periph_conf.h @@ -51,6 +51,7 @@ extern "C" { * @{ */ #define TIMER_NUMOF (2U) +#define TIMER_CHANNELS (2) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 diff --git a/boards/waspmote-pro/include/periph_conf.h b/boards/waspmote-pro/include/periph_conf.h index d113f24425..01206b940e 100644 --- a/boards/waspmote-pro/include/periph_conf.h +++ b/boards/waspmote-pro/include/periph_conf.h @@ -44,6 +44,7 @@ extern "C" { * @{ */ #define TIMER_NUMOF (2U) +#define TIMER_CHANNELS (3) #define TIMER_0 MEGA_TIMER1 #define TIMER_0_MASK &TIMSK1 diff --git a/cpu/atmega_common/periph/timer.c b/cpu/atmega_common/periph/timer.c index cc420fd851..506271ee44 100644 --- a/cpu/atmega_common/periph/timer.c +++ b/cpu/atmega_common/periph/timer.c @@ -32,11 +32,6 @@ #define ENABLE_DEBUG (0) #include "debug.h" -/** - * @brief All timers have three channels - */ -#define CHANNELS (3) - /** * @brief We have 5 possible prescaler values */ @@ -137,7 +132,7 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg) int timer_set_absolute(tim_t tim, int channel, unsigned int value) { - if (channel >= CHANNELS) { + if (channel >= TIMER_CHANNELS) { return -1; } @@ -150,7 +145,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value) int timer_clear(tim_t tim, int channel) { - if (channel >= CHANNELS) { + if (channel >= TIMER_CHANNELS) { return -1; }