esp_hal::uart

Struct UartRx

Source
pub struct UartRx<'d, M, T = AnyUart> { /* private fields */ }
Expand description

UART (Receive)

Implementations§

Source§

impl<'d, M, T> UartRx<'d, M, T>
where T: Instance, M: Mode,

Source

pub fn with_cts( self, cts: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Self

Configure CTS pin

Source

pub fn apply_config(&mut self, config: &Config) -> Result<(), Error>

Change the configuration.

Note that this also changes the configuration of the TX half.

Source

pub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Error>

Fill a buffer with received bytes

Source

pub fn read_byte(&mut self) -> Result<u8, Error>

Read a byte from the UART

Source

pub fn drain_fifo(&mut self, buf: &mut [u8]) -> usize

Read all available bytes from the RX FIFO into the provided buffer and returns the number of read bytes. Never blocks

Source§

impl<'d> UartRx<'d, Blocking>

Source

pub fn new( uart: impl Peripheral<P = impl Instance> + 'd, rx: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Result<Self, Error>

Create a new UART RX instance in Blocking mode.

Source

pub fn new_with_config( uart: impl Peripheral<P = impl Instance> + 'd, config: Config, rx: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Result<Self, Error>

Create a new UART RX instance with configuration options in Blocking mode.

Source§

impl<'d, T> UartRx<'d, Blocking, T>
where T: Instance,

Source

pub fn new_typed( uart: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Result<Self, Error>

Create a new UART RX instance in Blocking mode.

Source

pub fn new_with_config_typed( uart: impl Peripheral<P = T> + 'd, config: Config, rx: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Result<Self, Error>

Create a new UART RX instance with configuration options in Blocking mode.

Source

pub fn into_async(self) -> UartRx<'d, Async, T>

Reconfigures the driver to operate in Async mode.

Source§

impl<'d, T> UartRx<'d, Async, T>
where T: Instance,

Source

pub fn into_blocking(self) -> UartRx<'d, Blocking, T>

Reconfigures the driver to operate in Blocking mode.

Source§

impl<T> UartRx<'_, Async, T>
where T: Instance,

Source

pub async fn read_async(&mut self, buf: &mut [u8]) -> Result<usize, Error>

Read async to buffer slice buf. Waits until at least one byte is in the Rx FiFo and one of the following interrupts occurs:

  • RXFIFO_FULL
  • RXFIFO_OVF
  • AT_CMD_CHAR_DET (only if set_at_cmd was called)
  • RXFIFO_TOUT (only if `set_rx_timeout was called)

The interrupts in question are enabled during the body of this function. The method immediately returns when the interrupt has already occurred before calling this method (e.g. status bit set, but interrupt not enabled)

§Params
  • buf buffer slice to write the bytes into
§Ok

When successful, returns the number of bytes written to buf. This method will never return Ok(0)

Trait Implementations§

Source§

impl<T, M> ErrorType for UartRx<'_, M, T>

Source§

type Error = Error

Error type
Source§

impl<T, M> ErrorType for UartRx<'_, M, T>

Source§

type Error = Error

Error type of all the IO operations on this type.
Source§

impl<T> Read for UartRx<'_, Async, T>
where T: Instance,

Source§

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>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<T, M> Read for UartRx<'_, M, T>
where T: Instance, M: Mode,

Source§

fn read(&mut self) -> Result<u8, Self::Error>

Reads a single word from the serial interface
Source§

impl<T, M> Read for UartRx<'_, M, T>
where T: Instance, M: Mode,

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<T, M> ReadReady for UartRx<'_, M, T>
where T: Instance, M: Mode,

Source§

fn read_ready(&mut self) -> Result<bool, Self::Error>

Get whether the reader is ready for immediately reading. Read more
Source§

impl<M, T> SetConfig for UartRx<'_, M, T>
where T: Instance, M: Mode,

Source§

type Config = Config

The configuration type used by this driver.
Source§

type ConfigError = Error

The error type that can occur if set_config fails.
Source§

fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>

Set the configuration of the driver.
Source§

impl<T, M> Read<u8> for UartRx<'_, M, T>
where T: Instance, M: Mode,

Source§

type Error = Error

Read error
Source§

fn read(&mut self) -> Result<u8, Self::Error>

Reads a single word from the serial interface

Auto Trait Implementations§

§

impl<'d, M, T> Freeze for UartRx<'d, M, T>
where T: Freeze,

§

impl<'d, M, T> RefUnwindSafe for UartRx<'d, M, T>

§

impl<'d, M, T> Send for UartRx<'d, M, T>
where T: Send, M: Send,

§

impl<'d, M, T> Sync for UartRx<'d, M, T>
where T: Sync, M: Sync,

§

impl<'d, M, T> Unpin for UartRx<'d, M, T>
where T: Unpin, M: Unpin,

§

impl<'d, M, T = AnyUart> !UnwindSafe for UartRx<'d, M, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.