From 9de1b0dfccf2e31a0ab1fc93a910ead5d9417899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 1 Mar 2018 17:51:44 +0100 Subject: [PATCH 1/2] cpu/mips32r2_common: use `periph_common` timer_set Use 'timer_set' provided by 'periph_common' instead of re-implementing it. It also fixes 'mips32r2_generic' that should have been defining 'PERIPH_TIMER_PROVIDES_SET' as 'mips32r2_common' uses 'periph_common' but is not necessary if removing the function. --- cpu/mips32r2_common/periph/timer.c | 17 ----------------- .../include/periph_cpu_common.h | 5 ----- 2 files changed, 22 deletions(-) diff --git a/cpu/mips32r2_common/periph/timer.c b/cpu/mips32r2_common/periph/timer.c index d9498e6bfc28..d71d698bc721 100644 --- a/cpu/mips32r2_common/periph/timer.c +++ b/cpu/mips32r2_common/periph/timer.c @@ -121,23 +121,6 @@ int timer_init(tim_t dev, unsigned long freq, timer_cb_t cb, void *arg) return 0; } -int timer_set(tim_t dev, int channel, unsigned int timeout) -{ - assert(dev == 0); - assert(channel < CHANNELS); - - (void)dev; - - timeout >>= TIMER_ACCURACY_SHIFT; - timeout <<= TIMER_ACCURACY_SHIFT; - - uint32_t status = irq_disable(); - compares[channel] = counter + timeout; - irq_restore(status); - - return channel; -} - int timer_set_absolute(tim_t dev, int channel, unsigned int value) { assert(dev == 0); diff --git a/cpu/mips_pic32_common/include/periph_cpu_common.h b/cpu/mips_pic32_common/include/periph_cpu_common.h index 115bb66025a9..f3159bfa687c 100644 --- a/cpu/mips_pic32_common/include/periph_cpu_common.h +++ b/cpu/mips_pic32_common/include/periph_cpu_common.h @@ -56,11 +56,6 @@ enum { PORT_G = 6, /**< port G */ }; -/** - * @brief Prevent shared timer functions from being used - */ -#define PERIPH_TIMER_PROVIDES_SET - #ifdef __cplusplus } #endif From b07170ced1b6c4e04efe16b7a049462130add237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 2 Mar 2018 15:18:43 +0100 Subject: [PATCH 2/2] mips32r2_common/periph/timer: fix return values Fix 'timer_set_absolute' and 'timer_clear' return value to 1 on success as documented in the API. --- cpu/mips32r2_common/periph/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/mips32r2_common/periph/timer.c b/cpu/mips32r2_common/periph/timer.c index d71d698bc721..b19af489fa24 100644 --- a/cpu/mips32r2_common/periph/timer.c +++ b/cpu/mips32r2_common/periph/timer.c @@ -135,7 +135,7 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value) compares[channel] = value; irq_restore(status); - return channel; + return 1; } int timer_clear(tim_t dev, int channel) @@ -149,7 +149,7 @@ int timer_clear(tim_t dev, int channel) compares[channel] = 0; irq_restore(status); - return channel; + return 1; } unsigned int timer_read(tim_t dev)