Skip to main content

UartTx

Struct UartTx 

Source
pub struct UartTx<'d, Dm: DriverMode> { /* private fields */ }
Available on crate feature unstable only.
Expand description

UART (Transmit)

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Implementations§

Source§

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

Source

pub fn new( uart: impl Instance + 'd, config: Config, ) -> Result<Self, ConfigError>

Creates a new UART TX instance in Blocking mode.

§Examples
use esp_hal::uart::{Config, UartTx};
let tx = UartTx::new(peripherals.UART0, Config::default())?.with_tx(peripherals.GPIO1);
§Errors

ConfigError when the configuration is not supported by the hardware

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

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

Reconfigures the driver to operate in Async mode.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

impl<'d> UartTx<'d, Async>

Source

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

Reconfigures the driver to operate in Blocking mode.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

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

Writes data into the TX buffer.

Writes the provided buffer bytes into the UART transmit buffer. If the buffer is full, waits asynchronously for space in the buffer to become available.

Returns the number of bytes written into the buffer. This may be less than the length of the buffer.

Upon an error, returns immediately and the contents of the internal FIFO are not modified.

§Cancellation Safety

Cancellation safe.

Source

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

Asynchronously flushes the UART transmit buffer.

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

§Cancellation Safety

Cancellation safe.

Source

pub async fn send_break_async<D: DelayNs>(&mut self, delay: &mut D, bits: u32)

Sends a break signal for a specified duration in bit time.

Duration is in bits, the time it takes to transfer one bit at the current baud rate.

Restores the original TX line state after the break signal is sent, even if the future is cancelled.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

impl<'d, Dm> UartTx<'d, Dm>
where Dm: DriverMode,

Source

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

Configures RTS pin.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn with_tx(self, tx: impl PeripheralOutput<'d>) -> Self

Assigns the TX pin for UART instance.

Sets the specified pin to push-pull output and connects it to the UART TX signal.

Disconnects the previous pin that was assigned with with_tx.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

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

Changes the configuration.

Do not call this function while a transmission is in progress. The function discards the data that the transmitter did not send yet, and the TX line goes low for a short time. A receiver reports that pulse as an error. Call Self::flush first, to let the transmitter send the remaining data.

§Errors

ConfigError when the configuration is not supported by the hardware

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn write_ready(&self) -> bool

Returns whether the UART buffer is ready to accept more data.

If this function returns true, Self::write will not block.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

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

Writes bytes.

Writes data to the internal TX FIFO of the UART peripheral. The data is then transmitted over the UART TX line.

Returns the number of bytes written to the FIFO. This may be less than the length of the provided data. Returns 0 only if the provided data is empty.

§Errors

TxError when an error occurred during the write operation

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn flush(&mut self) -> Result<(), TxError>

Flushes the transmit buffer.

Blocks until all data in the TX FIFO has been transmitted.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn send_break(&mut self, bits: u32)

Sends a break signal for a specified duration in bit time.

Duration is in bits, the time it takes to transfer one bit at the current baud rate. The delay during the break is just busy-waiting.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Trait Implementations§

Source§

impl<Dm: DriverMode> ErrorType for UartTx<'_, Dm>

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

type Error = TxError

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

impl<Dm: DriverMode> ErrorType for UartTx<'_, Dm>

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

type Error = TxError

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

impl<Dm> SetConfig for UartTx<'_, Dm>
where Dm: DriverMode,

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

type Config = Config

The configuration type used by this driver.
Source§

type ConfigError = ConfigError

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<Dm> Write for UartTx<'_, Dm>
where Dm: DriverMode,

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<Dm> Write for UartTx<'_, Dm>
where Dm: DriverMode,

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

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<Dm> Write for UartTx<'_, Dm>
where Dm: DriverMode,

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

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 Write for UartTx<'_, Async>

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

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 Write for UartTx<'_, Async>

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

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<Dm> WriteReady for UartTx<'_, Dm>
where Dm: DriverMode,

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

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

Get whether the writer is ready for immediately writing. Read more
Source§

impl<Dm> WriteReady for UartTx<'_, Dm>
where Dm: DriverMode,

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

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

Get whether the writer is ready for immediately writing. Read more
Source§

impl<Dm> uWrite for UartTx<'_, Dm>
where Dm: DriverMode,

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

type Error = TxError

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, Dm> !UnwindSafe for UartTx<'d, Dm>

§

impl<'d, Dm> Freeze for UartTx<'d, Dm>
where PhantomData<Dm>: Freeze,

§

impl<'d, Dm> RefUnwindSafe for UartTx<'d, Dm>

§

impl<'d, Dm> Send for UartTx<'d, Dm>
where PhantomData<Dm>: Send,

§

impl<'d, Dm> Sync for UartTx<'d, Dm>
where PhantomData<Dm>: Sync,

§

impl<'d, Dm> Unpin for UartTx<'d, Dm>
where PhantomData<Dm>: Unpin,

§

impl<'d, Dm> UnsafeUnpin for UartTx<'d, Dm>

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.