From 97343af69d579d713f7862a47ccb6607912f1e54 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sat, 18 Apr 2020 19:17:26 +0200 Subject: [PATCH] cpu/ezr32wg: define TIMER_CHANNEL_NUMOF --- cpu/ezr32wg/include/periph_cpu.h | 5 +++++ cpu/ezr32wg/periph/timer.c | 11 +++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cpu/ezr32wg/include/periph_cpu.h b/cpu/ezr32wg/include/periph_cpu.h index 338a7a0bbf..81fd9b7be9 100644 --- a/cpu/ezr32wg/include/periph_cpu.h +++ b/cpu/ezr32wg/include/periph_cpu.h @@ -38,6 +38,11 @@ extern "C" { typedef uint32_t tim_t; /** @} */ +/** + * @brief This timer implementation has three available channels + */ +#define TIMER_CHANNEL_NUMOF (3) + /** * @brief Starting offset of CPU_ID */ diff --git a/cpu/ezr32wg/periph/timer.c b/cpu/ezr32wg/periph/timer.c index 8d9c681dee..f273cdad93 100644 --- a/cpu/ezr32wg/periph/timer.c +++ b/cpu/ezr32wg/periph/timer.c @@ -26,11 +26,6 @@ #define ENABLE_DEBUG (0) #include "debug.h" -/** - * @brief This timer implementation has three available channels - */ -#define CC_CHANNELS (3U) - /** * @brief Timer state memory */ @@ -87,7 +82,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value) { TIMER_TypeDef *tim; - if ((channel < 0) || (channel >= (int)CC_CHANNELS)) { + if ((channel < 0) || (channel >= TIMER_CHANNEL_NUMOF)) { return -1; } @@ -99,7 +94,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value) int timer_clear(tim_t dev, int channel) { - if ((channel < 0) || (channel >= (int)CC_CHANNELS)) { + if ((channel < 0) || (channel >= TIMER_CHANNEL_NUMOF)) { return -1; } @@ -131,7 +126,7 @@ void timer_reset(tim_t dev) void TIMER_0_ISR(void) { TIMER_TypeDef *tim = timer_config[0].timer; - for (unsigned i = 0; i < CC_CHANNELS; i++) { + for (int i = 0; i < TIMER_CHANNEL_NUMOF; i++) { if (tim->IF & (TIMER_IF_CC0 << i)) { tim->CC[i].CTRL = _TIMER_CC_CTRL_MODE_OFF; tim->IFC = (TIMER_IFC_CC0 << i);