pub struct PeripheralClockConfig<'a> { /* private fields */ }
Expand description

Clock configuration of the MCPWM peripheral

Implementations§

source§

impl<'a> PeripheralClockConfig<'a>

source

pub fn with_prescaler( clocks: &'a Clocks<'_>, prescaler: u8 ) -> PeripheralClockConfig<'a>

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( clocks: &'a Clocks<'_>, target_freq: Rate<u32, 1, 1> ) -> Result<PeripheralClockConfig<'a>, 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<u32, 1, 1>

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<'a>

Get a timer clock configuration with the given prescaler.

The resulting timer frequency depends of 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<u32, 1, 1> ) -> Result<TimerClockConfig<'a>, 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<'a> Clone for PeripheralClockConfig<'a>

source§

fn clone(&self) -> PeripheralClockConfig<'a>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'a> Copy for PeripheralClockConfig<'a>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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.
source§

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

Performs the conversion.