pub struct PeripheralClockConfig { /* private fields */ }Expand description
Clock configuration of the MCPWM peripheral
Implementations§
Source§impl PeripheralClockConfig
impl PeripheralClockConfig
Sourcepub fn with_prescaler(prescaler: u8) -> Self
pub fn with_prescaler(prescaler: u8) -> Self
Get a clock configuration with the given prescaler.
With standard system clock configurations the input clock to the MCPWM
peripheral is 160 MHz.
The peripheral clock frequency is calculated as:
peripheral_clock = input_clock / (prescaler + 1)
Sourcepub fn with_frequency(target_freq: Rate) -> Result<Self, FrequencyError>
pub fn with_frequency(target_freq: Rate) -> Result<Self, FrequencyError>
Get a clock configuration with the given frequency.
§Note:
This will try to select an appropriate prescaler for the
PeripheralClockConfig::with_prescaler method.
If the calculated prescaler is not in the range 0..u8::MAX
FrequencyError will be returned.
With standard system clock configurations the input clock to the MCPWM
peripheral is 160 MHz.
Only divisors of the input clock (160 Mhz / 1, 160 Mhz / 2, …,
160 Mhz / 256) are representable exactly. Other target frequencies
will be rounded up to the next divisor.
Sourcepub fn frequency(&self) -> Rate
pub fn frequency(&self) -> Rate
Get the peripheral clock frequency.
§Note:
The actual value is rounded down to the nearest u32 value
Sourcepub fn timer_clock_with_prescaler(
&self,
period: u16,
mode: PwmWorkingMode,
prescaler: u8,
) -> TimerClockConfig
pub fn timer_clock_with_prescaler( &self, period: u16, mode: PwmWorkingMode, prescaler: u8, ) -> TimerClockConfig
Get a timer clock configuration with the given prescaler.
The resulting timer frequency depends on the chosen
timer::PwmWorkingMode.
§PwmWorkingMode::Increase or PwmWorkingMode::Decrease
timer_frequency = peripheral_clock / (prescaler + 1) / (period + 1)
§PwmWorkingMode::UpDown
timer_frequency = peripheral_clock / (prescaler + 1) / (2 * period)
Sourcepub fn timer_clock_with_frequency(
&self,
period: u16,
mode: PwmWorkingMode,
target_freq: Rate,
) -> Result<TimerClockConfig, FrequencyError>
pub fn timer_clock_with_frequency( &self, period: u16, mode: PwmWorkingMode, target_freq: Rate, ) -> Result<TimerClockConfig, FrequencyError>
Get a timer clock configuration with the given frequency.
§Note:
This will try to select an appropriate prescaler for the timer.
If the calculated prescaler is not in the range 0..u8::MAX
FrequencyError will be returned.
See PeripheralClockConfig::timer_clock_with_prescaler for how the
frequency is calculated.
Trait Implementations§
Source§impl Clone for PeripheralClockConfig
Available on crate feature unstable only.
impl Clone for PeripheralClockConfig
unstable only.Source§fn clone(&self) -> PeripheralClockConfig
fn clone(&self) -> PeripheralClockConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PeripheralClockConfig
unstable only.