pub struct Config {
Show 13 fields pub baudrate: Hertz, pub parity: Parity, pub stopbits: StopBits, pub bitorder: BitOrder, pub clockphase: ClockPhase, pub clockpolarity: ClockPolarity, pub lastbitclockpulse: bool, pub swaptxrx: bool, pub invertrx: bool, pub inverttx: bool, pub rxfifothreshold: FifoThreshold, pub txfifothreshold: FifoThreshold, pub halfduplex: bool,
}
Expand description

A structure for specifying the USART or UART configuration. Fields relating to synchronous mode are ignored for UART peripherals.

This structure uses builder semantics to generate the configuration.

let config = Config::new().partity_odd();

Fields§

§baudrate: Hertz§parity: Parity§stopbits: StopBits§bitorder: BitOrder§clockphase: ClockPhase§clockpolarity: ClockPolarity§lastbitclockpulse: bool§swaptxrx: bool§invertrx: bool§inverttx: bool§rxfifothreshold: FifoThreshold§txfifothreshold: FifoThreshold§halfduplex: bool

Implementations§

source§

impl Config

source

pub fn new(frequency: Hertz) -> Self

Create a default configuration for the USART or UART interface

  • 8 bits, 1 stop bit, no parity (8N1)
  • LSB first
source

pub fn baudrate(self, baudrate: Hertz) -> Self

source

pub fn parity_none(self) -> Self

source

pub fn parity_even(self) -> Self

Enables Even Parity

Note that parity bits are included in the serial word length, so if parity is used word length will be set to 9.

source

pub fn parity_odd(self) -> Self

Enables Odd Parity

Note that parity bits are included in the serial word length, so if parity is used word length will be set to 9.

source

pub fn stopbits(self, stopbits: StopBits) -> Self

Specify the number of stop bits

source

pub fn bitorder(self, bitorder: BitOrder) -> Self

Specify the bit order

source

pub fn clockphase(self, clockphase: ClockPhase) -> Self

Specify the clock phase. Only applies to USART peripherals

source

pub fn clockpolarity(self, clockpolarity: ClockPolarity) -> Self

Specify the clock polarity. Only applies to USART peripherals

source

pub fn lastbitclockpulse(self, lastbitclockpulse: bool) -> Self

Specify if the last bit transmitted in each word has a corresponding clock pulse in the SCLK pin. Only applies to USART peripherals

source

pub fn swaptxrx(self, swaptxrx: bool) -> Self

If true, swap the Tx and Rx pins

source

pub fn invertrx(self, invertrx: bool) -> Self

If true, RX pin signal levels are inverted

source

pub fn inverttx(self, inverttx: bool) -> Self

If true, TX pin signal levels are inverted

source

pub fn rxfifothreshold(self, rxfifothreshold: FifoThreshold) -> Self

source

pub fn txfifothreshold(self, txfifothreshold: FifoThreshold) -> Self

source

pub fn halfduplex(self, halfduplex: bool) -> Self

If true, sets to half-duplex mode

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

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 Default for Config

source§

fn default() -> Config

Returns the “default value” for a type. Read more
source§

impl From<Rate<u32, 1, 1>> for Config

source§

fn from(frequency: Hertz) -> Config

Converts to this type from the input type.
source§

impl Copy for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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.