From 6070c57e21eec56f3aa434f17c0a75bde75068a2 Mon Sep 17 00:00:00 2001 From: Armin Wolf Date: Sat, 27 Jan 2024 16:46:56 +0100 Subject: [PATCH] cpu/native: Add support for periph_timer_query_freqs Add support for querying the frequency supported by `periph_timer`. This allows applications which require this feature to run on the `native` board. Signed-off-by: Armin Wolf --- cpu/native/Makefile.features | 1 + cpu/native/include/periph_conf.h | 3 ++- cpu/native/periph/timer.c | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cpu/native/Makefile.features b/cpu/native/Makefile.features index 14f89d59fb99..3527cf2d2dab 100644 --- a/cpu/native/Makefile.features +++ b/cpu/native/Makefile.features @@ -18,6 +18,7 @@ FEATURES_PROVIDED += periph_hwrng FEATURES_PROVIDED += periph_pm FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_timer_periodic +FEATURES_PROVIDED += periph_timer_query_freqs ifeq ($(OS) $(OS_ARCH),Linux x86_64) FEATURES_PROVIDED += rust_target endif diff --git a/cpu/native/include/periph_conf.h b/cpu/native/include/periph_conf.h index eaf611029d52..0df89b2c53ae 100644 --- a/cpu/native/include/periph_conf.h +++ b/cpu/native/include/periph_conf.h @@ -49,7 +49,8 @@ extern "C" { * @name Timer peripheral configuration * @{ */ -#define TIMER_NUMOF (1U) +#define TIMER_NUMOF (1U) +#define TIMER_CHANNEL_NUMOF (1U) /**< Number of timer channels */ /** * @brief xtimer configuration diff --git a/cpu/native/periph/timer.c b/cpu/native/periph/timer.c index e275dc5574e2..8bfc4dd0ee70 100644 --- a/cpu/native/periph/timer.c +++ b/cpu/native/periph/timer.c @@ -75,6 +75,28 @@ void native_isr_timer(void) _callback(_cb_arg, 0); } +uword_t timer_query_freqs_numof(tim_t dev) +{ + (void)dev; + + assert(TIMER_DEV(dev) < TIMER_NUMOF); + + return 1; +} + +uint32_t timer_query_freqs(tim_t dev, uword_t index) +{ + (void)dev; + + assert(TIMER_DEV(dev) < TIMER_NUMOF); + + if (index > 0) { + return 0; + } + + return NATIVE_TIMER_SPEED; +} + int timer_init(tim_t dev, uint32_t freq, timer_cb_t cb, void *arg) { (void)freq;