Struct PeripheralClockConfig

Source
pub struct PeripheralClockConfig { /* private fields */ }
Available on crate feature unstable only.
Expand description

Clock configuration of the MCPWM peripheral

Implementations§

Source§

impl PeripheralClockConfig

Source

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)

Source

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.

Source

pub fn frequency(&self) -> Rate

Get the peripheral clock frequency.

§Note:

The actual value is rounded down to the nearest u32 value

Source

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)

Source

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

Source§

fn clone(&self) -> PeripheralClockConfig

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PeripheralClockConfig

Auto Trait Implementations§

§

impl Freeze for PeripheralClockConfig

§

impl RefUnwindSafe for PeripheralClockConfig

§

impl Send for PeripheralClockConfig

§

impl Sync for PeripheralClockConfig

§

impl Unpin for PeripheralClockConfig

§

impl UnwindSafe for PeripheralClockConfig

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.