Clock

Struct Clock 

Source
pub struct Clock<T, Mode> { /* private fields */ }
Expand description

Defines the clock configuration for a USART instance

This struct has two type arguments:

  • T specifies the clock used to power the USART clock. This clock will be selected when the USART instance is enabled.
  • Mode specifies the USART mode. A distinction between synchronous and asynchronous mode has to be made, as OSRVAL has no meaning in synchronous mode.

Implementations§

Source§

impl Clock<IOSC, AsyncMode>

Source

pub fn new_with_baudrate(baudrate: u32) -> Self

Create a new configuration with a specified baudrate

Searches for configuration values that lead to a baud rate that is within 5% accuracy of the desired baudrate. Panics, if it can’t find such parameters.

Chooses the highest possibly oversampling value that will still give the desired accuracy. Please note that if the oversampling value gets too low, this can result in framing and noise errors when receiving data.

Due to the aforementioned limitations, and because this methods is relatively computationally expensive, it is recommended to only use it during initialization, with known baud rates. If you need more control, please use Clock::new in combination with an FRG.

Assumes the internal oscillator runs at 12 MHz.

Source§

impl<T, Mode> Clock<T, Mode>
where T: ClockSource,

Source

pub fn new(_: &T, brgval: u16, osrval: u8) -> Self

Create the clock configuration for the USART

The osrval argument has to be between 5-16. It will be ignored in synchronous mode.

Trait Implementations§

Source§

impl<T: Debug, Mode: Debug> Debug for Clock<T, Mode>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, Mode> Freeze for Clock<T, Mode>

§

impl<T, Mode> RefUnwindSafe for Clock<T, Mode>
where T: RefUnwindSafe, Mode: RefUnwindSafe,

§

impl<T, Mode> Send for Clock<T, Mode>
where T: Send, Mode: Send,

§

impl<T, Mode> Sync for Clock<T, Mode>
where T: Sync, Mode: Sync,

§

impl<T, Mode> Unpin for Clock<T, Mode>
where T: Unpin, Mode: Unpin,

§

impl<T, Mode> UnwindSafe for Clock<T, Mode>
where T: UnwindSafe, Mode: UnwindSafe,

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

Source§

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

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.