Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/native: Add support for periph_timer_query_freqs #20306

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
_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 Expand Up @@ -121,7 +143,7 @@
its.it_interval = its.it_value;
}

DEBUG("timer_set(): setting %lu.%09lu\n", (unsigned long)its.it_value.tv_sec, its.it_value.tv_nsec);

Check warning on line 146 in cpu/native/periph/timer.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
}

int timer_set(tim_t dev, int channel, unsigned int offset)
Expand Down
Loading