Skip to content

Commit

Permalink
cpu/native: Add support for periph_timer_query_freqs
Browse files Browse the repository at this point in the history
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 <W_Armin@gmx.de>
  • Loading branch information
Wer-Wolf committed Jan 30, 2024
1 parent 8f111a3 commit 6070c57
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions cpu/native/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cpu/native/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions cpu/native/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6070c57

Please sign in to comment.