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

cpu/stm32: implement periph_timer_query_freqs

This commit is contained in:
Marian Buschsieweke 2023-04-27 17:52:03 +02:00 committed by Marian Buschsieweke
parent 5dc3d9c743
commit 3868a7fa10
No known key found for this signature in database
GPG Key ID: 77AA882EC78084E6
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;