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, Dm> UartTx<'d, Dm>where
Dm: DriverMode,
impl<'d, Dm> UartTx<'d, Dm>where
Dm: DriverMode,
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
§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 Peripheral<P = impl PeripheralOutput> + 'd,
) -> Self
pub fn with_tx( self, tx: impl Peripheral<P = impl PeripheralOutput> + 'd, ) -> Self
Assign 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>
Change the configuration.
§Errors
This function returns a ConfigError
if 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(&mut self, data: &[u8]) -> Result<usize, TxError>
pub fn write(&mut self, data: &[u8]) -> Result<usize, TxError>
Write bytes.
This function writes data to the internal TX FIFO of the UART peripheral. The data is then transmitted over the UART TX line.
The function returns the number of bytes written to the FIFO. This may be less than the length of the provided data. The function may only return 0 if the provided data is empty.
§Errors
This function returns a TxError
if 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>
Flush the transmit buffer.
This function 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§impl<'d> UartTx<'d, Blocking>
impl<'d> UartTx<'d, Blocking>
Sourcepub fn new(
uart: impl Peripheral<P = impl Instance> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new( uart: impl Peripheral<P = impl Instance> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create a new UART TX instance in Blocking
mode.
§Errors
This function returns a ConfigError
if the configuration is not
supported by the hardware.
§Example
let tx = UartTx::new(
peripherals.UART0,
Config::default())?
.with_tx(peripherals.GPIO1);
§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 UartTx<'_, Async>
impl UartTx<'_, Async>
Sourcepub async fn write_async(&mut self, bytes: &[u8]) -> Result<usize, TxError>
pub async fn write_async(&mut self, bytes: &[u8]) -> Result<usize, TxError>
Write data into the TX buffer.
This function writes the provided buffer bytes
into the UART transmit
buffer. If the buffer is full, the function waits asynchronously for
space in the buffer to become available.
The function returns the number of bytes written into the buffer. This may be less than the length of the buffer.
Upon an error, the function returns immediately and the contents of the internal FIFO are not modified.
§Cancellation
This function is 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.
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.
§Cancellation
This function is cancellation safe.
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> 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 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> 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> 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.
Source§fn write_str(&mut self, s: &str) -> Result<(), Self::Error>
fn write_str(&mut self, s: &str) -> Result<(), Self::Error>
Source§fn write_char(&mut self, c: char) -> Result<(), Self::Error>
fn write_char(&mut self, c: char) -> Result<(), Self::Error>
char
] into this writer, returning whether the write succeeded. Read more