Type Alias atmega_hal::usart::Usart
source · pub type Usart<USART, RX, TX, CLOCK> = Usart<Atmega, USART, RX, TX, CLOCK>;
Aliased Type§
struct Usart<USART, RX, TX, CLOCK> { /* private fields */ }
Implementations
source§impl<H, USART, RXPIN, TXPIN, CLOCK> Usart<H, USART, Pin<Input, RXPIN>, Pin<Output, TXPIN>, CLOCK>
impl<H, USART, RXPIN, TXPIN, CLOCK> Usart<H, USART, Pin<Input, RXPIN>, Pin<Output, TXPIN>, CLOCK>
sourcepub fn new<IMODE>(
p: USART,
rx: Pin<Input<IMODE>, RXPIN>,
tx: Pin<Output, TXPIN>,
baudrate: Baudrate<CLOCK>
) -> Usart<H, USART, Pin<Input, RXPIN>, Pin<Output, TXPIN>, CLOCK>where
IMODE: InputMode,
pub fn new<IMODE>(
p: USART,
rx: Pin<Input<IMODE>, RXPIN>,
tx: Pin<Output, TXPIN>,
baudrate: Baudrate<CLOCK>
) -> Usart<H, USART, Pin<Input, RXPIN>, Pin<Output, TXPIN>, CLOCK>where
IMODE: InputMode,
Initialize a USART peripheral on the given pins.
Note that the RX and TX pins are hardwired for each USART peripheral and you must pass the correct ones. This is enforced at compile time.
source§impl<H, USART, RX, TX, CLOCK> Usart<H, USART, RX, TX, CLOCK>where
USART: UsartOps<H, RX, TX>,
impl<H, USART, RX, TX, CLOCK> Usart<H, USART, RX, TX, CLOCK>where
USART: UsartOps<H, RX, TX>,
sourcepub fn release(self) -> (USART, RX, TX)
pub fn release(self) -> (USART, RX, TX)
Deinitialize/disable this peripheral and release the pins.
sourcepub fn write_byte(&mut self, byte: u8)
pub fn write_byte(&mut self, byte: u8)
Transmit a byte.
This method will block until the byte has been enqueued for transmission but not until it was entirely sent.
sourcepub fn read_byte(&mut self) -> u8
pub fn read_byte(&mut self) -> u8
Receive a byte.
This method will block until a byte could be received.
sourcepub fn split(
self
) -> (UsartReader<H, USART, RX, TX, CLOCK>, UsartWriter<H, USART, RX, TX, CLOCK>)
pub fn split( self ) -> (UsartReader<H, USART, RX, TX, CLOCK>, UsartWriter<H, USART, RX, TX, CLOCK>)
Split this USART into a UsartReader
and a UsartWriter
.
This allows concurrently receiving and transmitting data from different contexts.