drivers: counter: add API to query counter frequency

Add API to get the base counter frequency.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
Peter A. Bigot 2019-01-13 09:59:25 -06:00 committed by Anas Nashif
commit 8f28e6043d

View file

@ -157,6 +157,21 @@ static inline u8_t counter_get_num_of_channels(const struct device *dev)
return config->channels;
}
/**
* @brief Function to get counter frequency.
*
* @param[in] dev Pointer to the device structure for the driver instance.
*
* @return Frequency of the counter in Hz, or zero if the counter does
* not have a fixed frequency.
*/
static inline u32_t counter_get_frequency(const struct device *dev)
{
const struct counter_config_info *config = dev->config->config_info;
return config->freq;
}
/**
* @brief Function to convert microseconds to ticks.
*