Expand description
Asynchronous serial (USART), blocking and non-blocking.
Word width is a typestate: a Usart<.., Byte> moves u8 values and
is what new builds, while new_word gives a
Usart<.., Word> for raw 9-bit frames carrying u16.
ⓘ
let tx = parts.pa9.into_alternate::<1>();
let rx = parts.pa10.into_alternate::<1>();
let mut serial = Usart::new(&mut rcu, dp.usart0, tx, rx, UsartConfig::default());
serial.write_byte(b'x');Which pins are valid depends on the chip variant: on x6/x8 PA2/PA3 reach
USART1, not USART0.
A receiver just built takes the first frame apart wrongly unless the line has
been idle for a frame beforehand, and with frames arriving back to back the
damage carries through the whole burst. Against a peer that comes up at the
same time this never shows: raising TEN sends an idle frame. It bites when
the peer is already transmitting — then the line has to be given that idle,
by waiting a frame time before the traffic starts.
Modules§
- baud
- Named constants for the standard bit rates.
Structs§
- Byte
- Word-width marker: 8-bit words (
Usart::write_byte,Usart::read_byte), optionally with parity. - Usart
- A configured USART, owning the peripheral and both pins.
- Usart
Config - Configuration for
Usart::new. - Usart
Config9 - Configuration for
Usart::new_word. - Word
- Word-width marker: raw 9-bit words (
Usart::write_word,Usart::read_word), no parity possible.
Enums§
- Error
- A line error the receiver reported for one frame.
- Event
- A USART event that can raise an interrupt.
- Frame
Format - Word length and parity, as a single setting.
- Oversampling
- How many times each bit is sampled.