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: u32The baud rate (speed) of the UART communication in bits per second (bps).
data_bits: DataBitsNumber of data bits in each frame (5, 6, 7, or 8 bits).
parity: ParityParity setting (None, Even, or Odd).
stop_bits: StopBitsNumber of stop bits in each frame (1, 1.5, or 2 bits).
clock_source: ClockSourceClock source used by the UART peripheral.
rx_fifo_full_threshold: u16Threshold level at which the RX FIFO is considered full.
rx_timeout: Option<u8>Optional timeout value for RX operations.
Implementations§
Source§impl Config
impl Config
Sourcepub fn parity_none(self) -> Self
pub fn parity_none(self) -> Self
Configures the UART to use no parity check.
Sourcepub fn parity_even(self) -> Self
pub fn parity_even(self) -> Self
Configures the UART to use even parity check.
Sourcepub fn parity_odd(self) -> Self
pub fn parity_odd(self) -> Self
Configures the UART to use odd parity check.
Sourcepub fn data_bits(self, data_bits: DataBits) -> Self
pub fn data_bits(self, data_bits: DataBits) -> Self
Sets the number of data bits for the UART configuration.
Sourcepub fn stop_bits(self, stop_bits: StopBits) -> Self
pub fn stop_bits(self, stop_bits: StopBits) -> Self
Sets the number of stop bits for the UART configuration.
Sourcepub fn clock_source(self, source: ClockSource) -> Self
pub fn clock_source(self, source: ClockSource) -> Self
Sets the clock source for the UART configuration.
Sourcepub fn symbol_length(&self) -> u8
pub fn symbol_length(&self) -> u8
Calculates the total symbol length in bits based on the configured data bits, parity, and stop bits.
Sourcepub fn rx_fifo_full_threshold(self, threshold: u16) -> Self
pub fn rx_fifo_full_threshold(self, threshold: u16) -> Self
Sets the RX FIFO full threshold for the UART configuration.
Sourcepub fn rx_timeout(self, timeout: Option<u8>) -> Self
pub fn rx_timeout(self, timeout: Option<u8>) -> Self
Sets the RX timeout for the UART configuration.