Struct kea_hal::adc::AdcConfig [−][src]
pub struct AdcConfig { pub clock_source: AdcClocks, pub clock_divisor: ClockDivisor, pub resolution: AdcResolution, pub sample_time: AdcSampleTime, pub low_power: bool, }
Expand description
Configuration struct for Adc peripheral.
Fields
clock_source: AdcClocks
Determines the clock source for the ADC peripheral
Default is AdcClocks::Bus
clock_divisor: ClockDivisor
Divides the clock source to get the ADC clock into it’s usable range of 400kHz - 8MHz (4MHz in low power mode).
Default is ClockDivisor::_1 (no divison)
resolution: AdcResolution
Set the resolution of ADC conversion
Default is AdcResolution::_8bit
sample_time: AdcSampleTime
Set ADC sample time.
Default is AdcSampleTime::Short
low_power: bool
Set low power mode
Default is false.
Implementations
Calculate the ADC clock divisor
Uses the current clock source and clock frequency to determine the best divisor to use in order to have minimal error between the ADC clock rate and the desired ADC clock rate.
Note: This relies on trustworthy values for source_freq and valid values for req_adc_freq. In the future this should know or determine what the current clock frequency is instead of relying on the user to provide it.
Set the divisor directly. panics if divisor isn’t supported by the clock source.
TODO: Refactor to remove assert. Add Clock Source as a type state
Sets the clock source, panics if divisor isn’t supported
TODO: Refactor to remove assert. Add Clock Source as a type state