esp_hal::uart

Struct UartTx

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

UART (Transmit)

Implementations§

Source§

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

Source

pub fn with_rts( self, rts: impl Peripheral<P = impl PeripheralOutput> + 'd, ) -> Self

Configure RTS pin

Source

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

Change the configuration.

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

Source

pub fn write_bytes(&mut self, data: &[u8]) -> Result<usize, Error>

Writes bytes

Source

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

Flush the transmit buffer of the UART

Source§

impl<'d> UartTx<'d, Blocking>

Source

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

Create a new UART TX instance in Blocking mode.

Source

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

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

Source§

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

Source

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

Create a new UART TX instance in Blocking mode.

Source

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

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

Source

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

Reconfigures the driver to operate in Async mode.

Source§

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

Source

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

Reconfigures the driver to operate in Blocking mode.

Source§

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

Source

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

Asynchronously writes data to the UART transmit buffer in chunks.

This function sends the contents of the provided buffer words over the UART. Data is written in chunks to avoid overflowing the transmit FIFO, and the function waits asynchronously when necessary for space in the buffer to become available.

Source

pub async fn flush_async(&mut self) -> Result<(), Error>

Asynchronously flushes the UART transmit buffer.

This function ensures that all pending data in the transmit FIFO has been sent over the UART. If the FIFO contains data, it waits for the transmission to complete before returning.

Trait Implementations§

Source§

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

Source§

type Error = Error

Error type
Source§

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

Source§

type Error = Error

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

impl<M, T> SetConfig for UartTx<'_, 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> Write for UartTx<'_, Async, T>
where T: Instance,

Source§

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

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

async fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
Source§

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

Write an entire buffer into this writer. Read more
Source§

impl<T, M> Write for UartTx<'_, M, T>
where T: Instance, M: Mode,

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
Source§

impl<T, M> Write for UartTx<'_, M, T>
where T: Instance, M: Mode,

Source§

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

Writes a single word to the serial interface.
Source§

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

Ensures that none of the previously written words are still buffered.
Source§

impl<T, M> Write for UartTx<'_, M, T>
where T: Instance, M: Mode,

Source§

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

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

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

Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Source§

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

Write an entire buffer into this writer. Read more
Source§

fn write_fmt( &mut self, fmt: Arguments<'_>, ) -> Result<(), WriteFmtError<Self::Error>>

Write a formatted string into this writer, returning any error encountered. Read more
Source§

impl<T, M> Write<u8> for UartTx<'_, M, T>
where T: Instance, M: Mode,

Source§

type Error = Error

Write error
Source§

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

Writes a single word to the serial interface
Source§

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

Ensures that none of the previously written words are still buffered
Source§

impl<T, M> uWrite for UartTx<'_, M, T>
where T: Instance, M: Mode,

Source§

type Error = Error

The error associated to this writer
Source§

fn write_str(&mut self, s: &str) -> Result<(), Self::Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
Source§

fn write_char(&mut self, c: char) -> Result<(), Self::Error>

Writes a char into this writer, returning whether the write succeeded. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'d, M, T = AnyUart> !UnwindSafe for UartTx<'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.