Struct esp_idf_hal::uart::UartTxDriver
source · pub struct UartTxDriver<'d> { /* private fields */ }
Expand description
Serial transmitter
Implementations§
source§impl<'d> UartTxDriver<'d>
impl<'d> UartTxDriver<'d>
sourcepub fn new<UART: Uart>(
uart: impl Peripheral<P = UART> + 'd,
tx: impl Peripheral<P = impl OutputPin> + 'd,
cts: Option<impl Peripheral<P = impl InputPin> + 'd>,
rts: Option<impl Peripheral<P = impl OutputPin> + 'd>,
config: &Config,
) -> Result<Self, EspError>
pub fn new<UART: Uart>( uart: impl Peripheral<P = UART> + 'd, tx: impl Peripheral<P = impl OutputPin> + 'd, cts: Option<impl Peripheral<P = impl InputPin> + 'd>, rts: Option<impl Peripheral<P = impl OutputPin> + 'd>, config: &Config, ) -> Result<Self, EspError>
Create a new serial transmitter
sourcepub fn event_queue(&self) -> Option<&Queue<UartEvent>>
pub fn event_queue(&self) -> Option<&Queue<UartEvent>>
Retrieves the event queue for this UART. Returns None
if
the config specified 0 for queue_size
.
sourcepub fn change_stop_bits(&self, stop_bits: StopBits) -> Result<&Self, EspError>
pub fn change_stop_bits(&self, stop_bits: StopBits) -> Result<&Self, EspError>
Change the number of stop bits
sourcepub fn change_data_bits(&self, data_bits: DataBits) -> Result<&Self, EspError>
pub fn change_data_bits(&self, data_bits: DataBits) -> Result<&Self, EspError>
Change the number of data bits
sourcepub fn change_parity(&self, parity: Parity) -> Result<&Self, EspError>
pub fn change_parity(&self, parity: Parity) -> Result<&Self, EspError>
Change the type of parity checking
sourcepub fn change_baudrate<T: Into<Hertz> + Copy>(
&self,
baudrate: T,
) -> Result<&Self, EspError>
pub fn change_baudrate<T: Into<Hertz> + Copy>( &self, baudrate: T, ) -> Result<&Self, EspError>
Change the baudrate.
Will automatically select the clock source. When possible the reference clock (1MHz) will be used, because this is constant when the clock source/frequency changes. However if one of the clock frequencies is below 10MHz or if the baudrate is above the reference clock or if the baudrate cannot be set within 1.5% then use the APB clock.
sourcepub fn write(&mut self, bytes: &[u8]) -> Result<usize, EspError>
pub fn write(&mut self, bytes: &[u8]) -> Result<usize, EspError>
Write multiple bytes from a slice
sourcepub fn write_nb(&self, bytes: &[u8]) -> Result<usize, EspError>
pub fn write_nb(&self, bytes: &[u8]) -> Result<usize, EspError>
Write multiple bytes from a slice directly to the TX FIFO hardware. Returns the number of bytes written, where 0 would mean that the TX FIFO is full.
NOTE: In case the UART TX buffer is enabled, this method might have unpredictable results
when used together with method write
, as the latter will push the data to be sent to the
TX buffer first.
To avoid this, always call wait_done
after the last call to write
and before
calling this method.
sourcepub fn wait_done(&self, timeout: TickType_t) -> Result<(), EspError>
pub fn wait_done(&self, timeout: TickType_t) -> Result<(), EspError>
Waits until the transmission is complete or until the specified timeout expires.
sourcepub fn flush(&mut self) -> Result<(), EspError>
👎Deprecated since 0.41.3: Use UartTxDriver::wait_done
instead
pub fn flush(&mut self) -> Result<(), EspError>
UartTxDriver::wait_done
insteadWaits until the transmission is complete.