embassy-stm32

Crates

git

Versions

stm32h747ig-cm7

Flavors

Skip to main content

CkoutDivider

Struct CkoutDivider 

Source
pub struct CkoutDivider(/* private fields */);
Expand description

CKOUT divider register value.

0 = CKOUT stopped; 1..=255 = enabled (actual divider = value + 1, range 2..=256).

The CKOUT output runs at 0 to 20 MHz. Stop CKOUT (divider 0) and wait for the clock to settle before changing the CKOUT source, or the output can glitch. Stopping takes 4 system-clock cycles for the system source, or 1 system clock plus 3 audio-clock cycles for the audio source.

Implementations§

Source§

impl CkoutDivider

Source

pub fn new(divider: u16) -> Self

Create from the actual divider value (2..=256). Panics if out of range. For a non-panicking variant, use CkoutDivider::try_from.

Source

pub fn from_frequency<T: Instance>( source: Hertz, ckout_rate: Hertz, ) -> Result<Self, Error>

Compute the divider to get a wanted CKOUT output frequency from the CKOUT source clock.

source is the CKOUT input clock (selected by CkoutSource); ckout_rate is the wanted CKOUT frequency. The divider is rounded up so the actual CKOUT frequency never exceeds ckout_rate.

The DFSDM kernel clock (crate::rcc::frequency::<T>()) must be at least 4x ckout_rate (SPI coding, RM0455); this is enforced here.

§Errors

Returns Error::InvalidConfig if the wanted frequency is zero, too high relative to the kernel clock, or unreachable with the 2..=256 divider range.

§Panics

Panics if the clock is not active.

Source

pub fn for_manchester<T: Instance>( source: Hertz, manchester_rate: Hertz, ) -> Result<Self, Error>

Compute the divider for a Manchester data rate.

manchester_rate is the expected Manchester data rate, i.e. the recovered clock frequency (RM0455: 0 to 10 MHz and < fDFSDMCLK/6). The divider is chosen so the Manchester period satisfies (CKOUTDIV + 1) x T_source < T_manchester < 2 x CKOUTDIV x T_source (RM0455), which puts the CKOUT output at ~1.5x the Manchester rate, inside the valid window.

The DFSDM kernel clock (crate::rcc::frequency::<T>()) must be at least 6x the Manchester rate; this is enforced here.

§Errors

Returns Error::InvalidConfig if the rate is above 10 MHz, above fDFSDMCLK/6, or unreachable with the 2..=256 divider range.

§Panics

Panics if the clock is not active.

Source

pub const fn raw(self) -> u8

Raw register value.

Trait Implementations§

Source§

impl Clone for CkoutDivider

Source§

fn clone(&self) -> CkoutDivider

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for CkoutDivider

Source§

impl Eq for CkoutDivider

Source§

impl From<CkoutDivider> for u8

Source§

fn from(value: CkoutDivider) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for CkoutDivider

Source§

fn eq(&self, other: &CkoutDivider) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CkoutDivider

Source§

impl TryFrom<u16> for CkoutDivider

Source§

fn try_from(divider: u16) -> Result<Self, Self::Error>

Try to create from the actual divider value (2..=256).

Source§

type Error = ()

The type returned in the event of a conversion error.

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, I> Binding<I, NoHandler<I>> for T
where T: Copy, I: Interrupt,

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> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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>,

Source§

type Error = !

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>,

Source§

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.