pub struct UartTx<'d, Dm: DriverMode> { /* private fields */ }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>
impl<'d> UartTx<'d, Blocking>
Sourcepub fn new(
uart: impl Instance + 'd,
config: Config,
) -> Result<Self, ConfigError>
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§impl<'d> UartTx<'d, Async>
impl<'d> UartTx<'d, Async>
Sourcepub fn into_blocking(self) -> UartTx<'d, Blocking>
pub fn into_blocking(self) -> UartTx<'d, Blocking>
Sourcepub async fn write_async(&mut self, bytes: &[u8]) -> Result<usize, TxError>
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.
Sourcepub async fn flush_async(&mut self) -> Result<(), TxError>
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.
Sourcepub async fn send_break_async<D: DelayNs>(&mut self, delay: &mut D, bits: u32)
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,
impl<'d, Dm> UartTx<'d, Dm>where
Dm: DriverMode,
Sourcepub fn with_rts(self, rts: impl PeripheralOutput<'d>) -> Self
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.
Sourcepub fn with_tx(self, tx: impl PeripheralOutput<'d>) -> Self
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.
Sourcepub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>
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.
Sourcepub fn write_ready(&self) -> bool
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.
Sourcepub fn write(&mut self, data: &[u8]) -> Result<usize, TxError>
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.
Sourcepub fn flush(&mut self) -> Result<(), TxError>
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.
Sourcepub fn send_break(&mut self, bits: u32)
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.
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§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.
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§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.
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 ConfigError = ConfigError
type ConfigError = ConfigError
set_config fails.Source§fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>
Source§impl<Dm> Write for UartTx<'_, Dm>where
Dm: DriverMode,
impl<Dm> Write for UartTx<'_, Dm>where
Dm: DriverMode,
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.
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>
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Source§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
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.
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>
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Source§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
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.
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>
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
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.
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>
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
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.
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§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.
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§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.
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.