Struct stm32h7xx_hal::serial::config::Config
source · 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
impl Config
sourcepub fn new(frequency: Hertz) -> Self
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
pub fn baudrate(self, baudrate: Hertz) -> Self
pub fn parity_none(self) -> Self
sourcepub fn parity_even(self) -> Self
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.
sourcepub fn parity_odd(self) -> Self
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.
sourcepub fn clockphase(self, clockphase: ClockPhase) -> Self
pub fn clockphase(self, clockphase: ClockPhase) -> Self
Specify the clock phase. Only applies to USART peripherals
sourcepub fn clockpolarity(self, clockpolarity: ClockPolarity) -> Self
pub fn clockpolarity(self, clockpolarity: ClockPolarity) -> Self
Specify the clock polarity. Only applies to USART peripherals
sourcepub fn lastbitclockpulse(self, lastbitclockpulse: bool) -> Self
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
pub fn rxfifothreshold(self, rxfifothreshold: FifoThreshold) -> Self
pub fn txfifothreshold(self, txfifothreshold: FifoThreshold) -> Self
sourcepub fn halfduplex(self, halfduplex: bool) -> Self
pub fn halfduplex(self, halfduplex: bool) -> Self
If true
, sets to half-duplex mode