Struct esp32_hal::Uart

source ·
pub struct Uart<'d, T> { /* private fields */ }
Expand description

UART driver

Implementations§

source§

impl<'d, T> Uart<'d, T>
where T: Instance,

source

pub fn new_with_config<P>( _uart: impl Peripheral<P = T> + 'd, config: Config, pins: Option<P>, clocks: &Clocks<'_> ) -> Uart<'d, T>
where P: UartPins,

Create a new UART instance with defaults

source

pub fn new( uart: impl Peripheral<P = T> + 'd, clocks: &Clocks<'_> ) -> Uart<'d, T>

Create a new UART instance with defaults

source

pub fn split(self) -> (UartTx<'d, T>, UartRx<'d, T>)

Split the Uart into a transmitter and receiver, which is particuarly useful when having two tasks correlating to transmitting and receiving.

source

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

Writes bytes

source

pub fn set_at_cmd(&mut self, config: AtCmdConfig)

Configures the AT-CMD detection settings.

source

pub fn set_rx_timeout(&mut self, timeout: Option<u8>) -> Result<(), Error>

Configures the Receive Timeout detection setting

§Arguments

timeout - the number of symbols (“bytes”) to wait for before triggering a timeout. Pass None to disable the timeout.

§Errors

Err(Error::InvalidArgument) if the provided value exceeds the maximum value for SOC :

  • esp32: Symbol size is fixed to 8, do not pass a value > 0x7F.
  • esp32c2, esp32c3, esp32c6, esp32h2, esp32s2, esp32s3: The value you pass times the symbol size must be <= 0x3FF
source

pub fn set_rx_fifo_full_threshold( &mut self, threshold: u16 ) -> Result<(), Error>

Configures the RX-FIFO threshold

§Errors

Err(Error::InvalidArgument) if provided value exceeds maximum value for SOC :

  • esp32 0x7F
  • esp32c6, esp32h2 0xFF
  • esp32c3, esp32c2, esp32s2 0x1FF
  • esp32s3 0x3FF
source

pub fn listen_at_cmd(&mut self)

Listen for AT-CMD interrupts

source

pub fn unlisten_at_cmd(&mut self)

Stop listening for AT-CMD interrupts

source

pub fn listen_tx_done(&mut self)

Listen for TX-DONE interrupts

source

pub fn unlisten_tx_done(&mut self)

Stop listening for TX-DONE interrupts

source

pub fn listen_rx_fifo_full(&mut self)

Listen for RX-FIFO-FULL interrupts

source

pub fn unlisten_rx_fifo_full(&mut self)

Stop listening for RX-FIFO-FULL interrupts

source

pub fn at_cmd_interrupt_set(&self) -> bool

Checks if AT-CMD interrupt is set

source

pub fn tx_done_interrupt_set(&self) -> bool

Checks if TX-DONE interrupt is set

source

pub fn rx_fifo_full_interrupt_set(&self) -> bool

Checks if RX-FIFO-FULL interrupt is set

source

pub fn reset_at_cmd_interrupt(&self)

Reset AT-CMD interrupt

source

pub fn reset_tx_done_interrupt(&self)

Reset TX-DONE interrupt

source

pub fn reset_rx_fifo_full_interrupt(&self)

Reset RX-FIFO-FULL interrupt

source

pub fn change_stop_bits(&mut self, stop_bits: StopBits) -> &mut Uart<'d, T>

Change the number of stop bits

Trait Implementations§

source§

impl<T> Write for Uart<'_, T>
where T: Instance,

source§

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

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> Read<u8> for Uart<'_, T>
where T: Instance,

§

type Error = Error

Read error
source§

fn read(&mut self) -> Result<u8, Error<<Uart<'_, T> as Read<u8>>::Error>>

Reads a single word from the serial interface
source§

impl<T> Write<u8> for Uart<'_, T>
where T: Instance,

§

type Error = Error

Write error
source§

fn write( &mut self, word: u8 ) -> Result<(), Error<<Uart<'_, T> as Write<u8>>::Error>>

Writes a single word to the serial interface
source§

fn flush(&mut self) -> Result<(), Error<<Uart<'_, T> as Write<u8>>::Error>>

Ensures that none of the previously written words are still buffered

Auto Trait Implementations§

§

impl<'d, T> RefUnwindSafe for Uart<'d, T>
where T: RefUnwindSafe,

§

impl<'d, T> Send for Uart<'d, T>
where T: Send,

§

impl<'d, T> Sync for Uart<'d, T>
where T: Sync,

§

impl<'d, T> Unpin for Uart<'d, T>

§

impl<'d, T> !UnwindSafe for Uart<'d, 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>,

§

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>,

§

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.