riot_sys

Function timer_query_freqs

Source
pub unsafe extern "C" fn timer_query_freqs(
    dev: tim_t,
    index: uword_t,
) -> u32
Expand description

@brief Iterate over supported frequencies

@param dev Timer to get the next supported frequency of @param index Index of the frequency to get @return The @p index highest frequency supported by the timer @retval 0 @p index is too high

@note Add FEATURES_REQUIRED += periph_timer_query_freqs to your Makefile.

When called with a value of 0 for @p index, the highest supported frequency is returned. For a value 1 the second highest is returned, and so on. For values out of range, 0 is returned. A program hence can iterate over all supported frequencies using:

uint32_t freq:
for (uword_t i = 0; (freq = timer_query_freqs(dev, i)); i++) {
    work_with_frequency(freq);
}

Or alternatively:

for (uword_t i = 0; i < timer_query_freqs_numof(dev); i++) {
    work_with_frequency(timer_query_freqs(dev, i));
}