Module atmega_hal::usart
source · Expand description
USART
§Example
Complete example source code can be found in the repository:
atmega2560-usart.rs
Note: ufmt is used instead of core::fmt
because
core::fmt
code quickly grows too large for AVR platforms.
let dp = atmega_hal::Peripherals::take().unwrap();
let pins = atmega_hal::pins!(dp);
let mut serial = Usart::new(
dp.USART0,
pins.pe0,
pins.pe1.into_output(),
Baudrate::<crate::CoreClock>::new(57600),
);
ufmt::uwriteln!(&mut serial, "Hello from ATmega!").unwrap();
loop {
// Read a byte from the serial connection
let b = nb::block!(serial.read()).unwrap();
// Answer
ufmt::uwriteln!(&mut serial, "Got {}!", b).unwrap();
}
Structs§
- Representation of a USART baudrate
Enums§
- Events/Interrupts for USART peripherals
Traits§
- Same as
BaudrateExt
but accounts for an errata of certain Arduino boards: - Provide a
into_baudrate()
method for integers. - Internal trait for low-level USART peripherals.