1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #20148 from maribu/periph_timer_query_freq-stm32

cpu/stm32: implement periph_timer_query_freqs
This commit is contained in:
Marian Buschsieweke 2023-12-07 21:57:49 +00:00 committed by GitHub
commit b0261f31ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View File

@ -12,6 +12,7 @@ config CPU_STM32
select HAS_PERIPH_GPIO
select HAS_PERIPH_GPIO_IRQ
select HAS_PERIPH_TIMER_PERIODIC
select HAS_PERIPH_TIMER_QUERY_FREQS
select HAS_PERIPH_RTT_OVERFLOW
select HAS_PERIPH_UART_MODECFG
select HAS_PERIPH_UART_NONBLOCKING

View File

@ -8,6 +8,7 @@ FEATURES_PROVIDED += cpu_stm32$(CPU_FAM)
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_timer_periodic
FEATURES_PROVIDED += periph_timer_query_freqs
FEATURES_PROVIDED += periph_rtt_overflow
FEATURES_PROVIDED += periph_uart_modecfg
FEATURES_PROVIDED += periph_uart_nonblocking

View File

@ -161,6 +161,23 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
return 0;
}
uword_t timer_query_freqs_numof(tim_t dev)
{
(void)dev;
/* Prescaler values from 0 to UINT16_MAX are supported */
return UINT16_MAX + 1;
}
uint32_t timer_query_freqs(tim_t dev, uword_t index)
{
if (index > UINT16_MAX) {
return 0;
}
return periph_timer_clk(timer_config[dev].bus) / (index + 1);
}
int timer_set(tim_t tim, int channel, unsigned int timeout)
{
unsigned value = (dev(tim)->CNT + timeout) & timer_config[tim].max;