esp_hal::uart

Struct Config

Source
pub struct Config {
    pub baudrate: u32,
    pub data_bits: DataBits,
    pub parity: Parity,
    pub stop_bits: StopBits,
    pub clock_source: ClockSource,
    pub rx_fifo_full_threshold: u16,
    pub rx_timeout: Option<u8>,
}
Expand description

UART Configuration

Fields§

§baudrate: u32

The baud rate (speed) of the UART communication in bits per second (bps).

§data_bits: DataBits

Number of data bits in each frame (5, 6, 7, or 8 bits).

§parity: Parity

Parity setting (None, Even, or Odd).

§stop_bits: StopBits

Number of stop bits in each frame (1, 1.5, or 2 bits).

§clock_source: ClockSource

Clock source used by the UART peripheral.

§rx_fifo_full_threshold: u16

Threshold level at which the RX FIFO is considered full.

§rx_timeout: Option<u8>

Optional timeout value for RX operations.

Implementations§

Source§

impl Config

Source

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

Sets the baud rate for the UART configuration.

Source

pub fn parity_none(self) -> Self

Configures the UART to use no parity check.

Source

pub fn parity_even(self) -> Self

Configures the UART to use even parity check.

Source

pub fn parity_odd(self) -> Self

Configures the UART to use odd parity check.

Source

pub fn data_bits(self, data_bits: DataBits) -> Self

Sets the number of data bits for the UART configuration.

Source

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

Sets the number of stop bits for the UART configuration.

Source

pub fn clock_source(self, source: ClockSource) -> Self

Sets the clock source for the UART configuration.

Source

pub fn symbol_length(&self) -> u8

Calculates the total symbol length in bits based on the configured data bits, parity, and stop bits.

Source

pub fn rx_fifo_full_threshold(self, threshold: u16) -> Self

Sets the RX FIFO full threshold for the UART configuration.

Source

pub fn rx_timeout(self, timeout: Option<u8>) -> Self

Sets the RX timeout for the UART configuration.

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
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> CloneToUninit for T
where T: Clone,

Source§

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