pub struct Uart<'d, M, T = AnyUart> { /* private fields */ }Expand description
UART (Full-duplex)
Implementations§
Source§impl<'d> Uart<'d, Blocking>
impl<'d> Uart<'d, Blocking>
Sourcepub fn new(
uart: impl Peripheral<P = impl Instance> + 'd,
rx: impl Peripheral<P = impl PeripheralInput> + 'd,
tx: impl Peripheral<P = impl PeripheralOutput> + 'd,
) -> Result<Self, Error>
pub fn new( uart: impl Peripheral<P = impl Instance> + 'd, rx: impl Peripheral<P = impl PeripheralInput> + 'd, tx: impl Peripheral<P = impl PeripheralOutput> + 'd, ) -> Result<Self, Error>
Create a new UART instance in Blocking mode.
Sourcepub fn new_with_config(
uart: impl Peripheral<P = impl Instance> + 'd,
config: Config,
rx: impl Peripheral<P = impl PeripheralInput> + 'd,
tx: impl Peripheral<P = impl PeripheralOutput> + 'd,
) -> Result<Self, Error>
pub fn new_with_config( uart: impl Peripheral<P = impl Instance> + 'd, config: Config, rx: impl Peripheral<P = impl PeripheralInput> + 'd, tx: impl Peripheral<P = impl PeripheralOutput> + 'd, ) -> Result<Self, Error>
Create a new UART instance with configuration options in
Blocking mode.
Source§impl<'d, T> Uart<'d, Blocking, T>where
T: Instance,
impl<'d, T> Uart<'d, Blocking, T>where
T: Instance,
Sourcepub fn new_typed(
uart: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl PeripheralInput> + 'd,
tx: impl Peripheral<P = impl PeripheralOutput> + 'd,
) -> Result<Self, Error>
pub fn new_typed( uart: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl PeripheralInput> + 'd, tx: impl Peripheral<P = impl PeripheralOutput> + 'd, ) -> Result<Self, Error>
Create a new UART instance in Blocking mode.
Sourcepub fn new_with_config_typed(
uart: impl Peripheral<P = T> + 'd,
config: Config,
rx: impl Peripheral<P = impl PeripheralInput> + 'd,
tx: impl Peripheral<P = impl PeripheralOutput> + 'd,
) -> Result<Self, Error>
pub fn new_with_config_typed( uart: impl Peripheral<P = T> + 'd, config: Config, rx: impl Peripheral<P = impl PeripheralInput> + 'd, tx: impl Peripheral<P = impl PeripheralOutput> + 'd, ) -> Result<Self, Error>
Create a new UART instance with configuration options in
Blocking mode.
Sourcepub fn into_async(self) -> Uart<'d, Async, T>
pub fn into_async(self) -> Uart<'d, Async, T>
Reconfigures the driver to operate in Async mode.
Source§impl<'d, T> Uart<'d, Async, T>where
T: Instance,
impl<'d, T> Uart<'d, Async, T>where
T: Instance,
Sourcepub fn into_blocking(self) -> Uart<'d, Blocking, T>
pub fn into_blocking(self) -> Uart<'d, Blocking, T>
Reconfigures the driver to operate in Blocking mode.
Source§impl<'d, M, T> Uart<'d, M, T>
impl<'d, M, T> Uart<'d, M, T>
Sourcepub fn with_cts(
self,
cts: impl Peripheral<P = impl PeripheralInput> + 'd,
) -> Self
pub fn with_cts( self, cts: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Self
Configure CTS pin
Sourcepub fn with_rts(
self,
rts: impl Peripheral<P = impl PeripheralOutput> + 'd,
) -> Self
pub fn with_rts( self, rts: impl Peripheral<P = impl PeripheralOutput> + 'd, ) -> Self
Configure RTS pin
Sourcepub fn split(self) -> (UartRx<'d, M, T>, UartTx<'d, M, T>)
pub fn split(self) -> (UartRx<'d, M, T>, UartTx<'d, M, T>)
Split the UART into a transmitter and receiver
This is particularly useful when having two tasks correlating to transmitting and receiving.
Sourcepub fn write_bytes(&mut self, data: &[u8]) -> Result<usize, Error>
pub fn write_bytes(&mut self, data: &[u8]) -> Result<usize, Error>
Write bytes out over the UART
Sourcepub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Error>
pub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Error>
Fill a buffer with received bytes
Sourcepub fn set_at_cmd(&mut self, config: AtCmdConfig)
pub fn set_at_cmd(&mut self, config: AtCmdConfig)
Configures the AT-CMD detection settings
Sourcepub fn listen(&mut self, interrupts: impl Into<EnumSet<UartInterrupt>>)
pub fn listen(&mut self, interrupts: impl Into<EnumSet<UartInterrupt>>)
Listen for the given interrupts
Sourcepub fn unlisten(&mut self, interrupts: impl Into<EnumSet<UartInterrupt>>)
pub fn unlisten(&mut self, interrupts: impl Into<EnumSet<UartInterrupt>>)
Unlisten the given interrupts
Sourcepub fn interrupts(&mut self) -> EnumSet<UartInterrupt>
pub fn interrupts(&mut self) -> EnumSet<UartInterrupt>
Gets asserted interrupts
Sourcepub fn clear_interrupts(&mut self, interrupts: EnumSet<UartInterrupt>)
pub fn clear_interrupts(&mut self, interrupts: EnumSet<UartInterrupt>)
Resets asserted interrupts
Source§impl<T> Uart<'_, Async, T>where
T: Instance,
impl<T> Uart<'_, Async, T>where
T: Instance,
Sourcepub async fn read_async(&mut self, buf: &mut [u8]) -> Result<usize, Error>
pub async fn read_async(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Asynchronously reads data from the UART receive buffer into the provided buffer.
Sourcepub async fn write_async(&mut self, words: &[u8]) -> Result<usize, Error>
pub async fn write_async(&mut self, words: &[u8]) -> Result<usize, Error>
Asynchronously writes data to the UART transmit buffer.
Sourcepub async fn flush_async(&mut self) -> Result<(), Error>
pub async fn flush_async(&mut self) -> Result<(), Error>
Asynchronously flushes the UART transmit buffer.
Trait Implementations§
Source§impl<T> InterruptConfigurable for Uart<'_, Blocking, T>where
T: Instance,
impl<T> InterruptConfigurable for Uart<'_, Blocking, T>where
T: Instance,
Source§fn set_interrupt_handler(&mut self, handler: InterruptHandler)
fn set_interrupt_handler(&mut self, handler: InterruptHandler)
Source§impl<T> Read for Uart<'_, Async, T>where
T: Instance,
impl<T> Read for Uart<'_, Async, T>where
T: Instance,
Source§async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
In contrast to the documentation of embedded_io_async::Read, this method blocks until an uart interrupt occurs. See UartRx::read_async for more details.
Source§async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
buf. Read moreSource§impl<T, M> Read for Uart<'_, M, T>
impl<T, M> Read for Uart<'_, M, T>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Source§fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
buf. Read moreSource§impl<M, T> SetConfig for Uart<'_, M, T>
impl<M, T> SetConfig for Uart<'_, M, T>
Source§type ConfigError = Error
type ConfigError = Error
set_config fails.