Struct rp2040_hal::uart::UartPeripheral
source · pub struct UartPeripheral<S: State, D: UartDevice, P: ValidUartPinout<D>> { /* private fields */ }
Expand description
An UART Peripheral based on an underlying UART device.
Implementations§
source§impl<S: State, D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<S, D, P>
impl<S: State, D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<S, D, P>
source§impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Disabled, D, P>
impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Disabled, D, P>
sourcepub fn new(
device: D,
pins: P,
resets: &mut RESETS
) -> UartPeripheral<Disabled, D, P>
pub fn new( device: D, pins: P, resets: &mut RESETS ) -> UartPeripheral<Disabled, D, P>
Creates an UartPeripheral in Disabled state.
sourcepub fn enable(
self,
config: UartConfig,
frequency: HertzU32
) -> Result<UartPeripheral<Enabled, D, P>, Error>
pub fn enable( self, config: UartConfig, frequency: HertzU32 ) -> Result<UartPeripheral<Enabled, D, P>, Error>
Enables the provided UART device with the given configuration.
source§impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Enabled, D, P>
impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Enabled, D, P>
sourcepub fn disable(self) -> UartPeripheral<Disabled, D, P>
pub fn disable(self) -> UartPeripheral<Disabled, D, P>
Disable this UART Peripheral, falling back to the Disabled state.
sourcepub fn set_fifos(&mut self, enable: bool)
pub fn set_fifos(&mut self, enable: bool)
Enable/disable the rx/tx FIFO
Unfortunately, it’s not possible to enable/disable rx/tx independently on this chip Default is false
sourcepub fn set_rx_watermark(&mut self, watermark: FifoWatermark)
pub fn set_rx_watermark(&mut self, watermark: FifoWatermark)
Set rx FIFO watermark
See DS: Table 423
sourcepub fn set_tx_watermark(&mut self, watermark: FifoWatermark)
pub fn set_tx_watermark(&mut self, watermark: FifoWatermark)
Set tx FIFO watermark
See DS: Table 423
sourcepub fn enable_rx_interrupt(&mut self)
pub fn enable_rx_interrupt(&mut self)
Enables the Receive Interrupt.
The relevant UARTx IRQ will fire when there is data in the receive register.
sourcepub fn enable_tx_interrupt(&mut self)
pub fn enable_tx_interrupt(&mut self)
Enables the Transmit Interrupt.
The relevant UARTx IRQ will fire when there is space in the transmit FIFO.
sourcepub fn disable_rx_interrupt(&mut self)
pub fn disable_rx_interrupt(&mut self)
Disables the Receive Interrupt.
sourcepub fn disable_tx_interrupt(&mut self)
pub fn disable_tx_interrupt(&mut self)
Disables the Transmit Interrupt.
sourcepub fn uart_is_writable(&self) -> bool
pub fn uart_is_writable(&self) -> bool
Is there space in the UART TX FIFO for new data to be written?
sourcepub fn uart_is_busy(&self) -> bool
pub fn uart_is_busy(&self) -> bool
Is the UART still busy transmitting data?
sourcepub fn uart_is_readable(&self) -> bool
pub fn uart_is_readable(&self) -> bool
Is there data in the UART RX FIFO ready to be read?
sourcepub fn write_raw<'d>(&self, data: &'d [u8]) -> Result<&'d [u8], Infallible>
pub fn write_raw<'d>(&self, data: &'d [u8]) -> Result<&'d [u8], Infallible>
Writes bytes to the UART. This function writes as long as it can. As soon that the FIFO is full, if :
- 0 bytes were written, a WouldBlock Error is returned
- some bytes were written, it is deemed to be a success Upon success, the remaining slice is returned.
sourcepub fn read_raw<'b>(&self, buffer: &'b mut [u8]) -> Result<usize, ReadError<'b>>
pub fn read_raw<'b>(&self, buffer: &'b mut [u8]) -> Result<usize, ReadError<'b>>
Reads bytes from the UART. This function reads as long as it can. As soon that the FIFO is empty, if :
- 0 bytes were read, a WouldBlock Error is returned
- some bytes were read, it is deemed to be a success Upon success, it will return how many bytes were read.
sourcepub fn write_full_blocking(&self, data: &[u8])
pub fn write_full_blocking(&self, data: &[u8])
Writes bytes to the UART. This function blocks until the full buffer has been sent.
sourcepub fn read_full_blocking(&self, buffer: &mut [u8]) -> Result<(), ReadErrorType>
pub fn read_full_blocking(&self, buffer: &mut [u8]) -> Result<(), ReadErrorType>
Reads bytes from the UART. This function blocks until the full buffer has been received.
source§impl<P: ValidUartPinout<UART0>> UartPeripheral<Enabled, UART0, P>
impl<P: ValidUartPinout<UART0>> UartPeripheral<Enabled, UART0, P>
Trait Implementations§
source§impl<D: UartDevice, P: ValidUartPinout<D>> ErrorType for UartPeripheral<Enabled, D, P>
impl<D: UartDevice, P: ValidUartPinout<D>> ErrorType for UartPeripheral<Enabled, D, P>
§type Error = ReadErrorType
type Error = ReadErrorType
source§impl<D: UartDevice, P: ValidUartPinout<D>> ErrorType for UartPeripheral<Enabled, D, P>
impl<D: UartDevice, P: ValidUartPinout<D>> ErrorType for UartPeripheral<Enabled, D, P>
§type Error = ReadErrorType
type Error = ReadErrorType
source§impl<D: UartDevice, P: ValidUartPinout<D>> Read for UartPeripheral<Enabled, D, P>
impl<D: UartDevice, P: ValidUartPinout<D>> Read for UartPeripheral<Enabled, D, P>
source§impl<D: UartDevice, P: ValidUartPinout<D>> Read for UartPeripheral<Enabled, D, P>
impl<D: UartDevice, P: ValidUartPinout<D>> Read for UartPeripheral<Enabled, D, P>
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
source§fn read_exact(
&mut self,
buf: &mut [u8]
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, buf: &mut [u8] ) -> Result<(), ReadExactError<Self::Error>>
buf
. Read more