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>

source

pub fn free(self) -> (D, P)

Releases the underlying device and pins.

source§

impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Disabled, D, P>

source

pub fn new( device: D, pins: P, resets: &mut RESETS ) -> UartPeripheral<Disabled, D, P>

Creates an UartPeripheral in Disabled state.

source

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>

source

pub fn disable(self) -> UartPeripheral<Disabled, D, P>

Disable this UART Peripheral, falling back to the Disabled state.

source

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

source

pub fn set_rx_watermark(&mut self, watermark: FifoWatermark)

Set rx FIFO watermark

See DS: Table 423

source

pub fn set_tx_watermark(&mut self, watermark: FifoWatermark)

Set tx FIFO watermark

See DS: Table 423

source

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.

source

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.

source

pub fn disable_rx_interrupt(&mut self)

Disables the Receive Interrupt.

source

pub fn disable_tx_interrupt(&mut self)

Disables the Transmit Interrupt.

source

pub fn uart_is_writable(&self) -> bool

Is there space in the UART TX FIFO for new data to be written?

source

pub fn uart_is_busy(&self) -> bool

Is the UART still busy transmitting data?

source

pub fn uart_is_readable(&self) -> bool

Is there data in the UART RX FIFO ready to be read?

source

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.
source

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.
source

pub fn write_full_blocking(&self, data: &[u8])

Writes bytes to the UART. This function blocks until the full buffer has been sent.

source

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

pub fn join(reader: Reader<D, P>, writer: Writer<D, P>) -> Self

Join the reader and writer halves together back into the original Uart peripheral.

A reader/writer pair can be obtained by calling split.

source§

impl<P: ValidUartPinout<UART0>> UartPeripheral<Enabled, UART0, P>

source

pub fn split(self) -> (Reader<UART0, P>, Writer<UART0, P>)

Split this peripheral into a separate reader and writer.

source§

impl<P: ValidUartPinout<UART1>> UartPeripheral<Enabled, UART1, P>

source

pub fn split(self) -> (Reader<UART1, P>, Writer<UART1, P>)

Split this peripheral into a separate reader and writer.

Trait Implementations§

source§

impl<D: UartDevice, P: ValidUartPinout<D>> ErrorType for UartPeripheral<Enabled, D, P>

§

type Error = ReadErrorType

Error type of all the IO operations on this type.
source§

impl<D: UartDevice, P: ValidUartPinout<D>> ErrorType for UartPeripheral<Enabled, D, P>

§

type Error = ReadErrorType

Error type
source§

impl<D: UartDevice, P: ValidUartPinout<D>> Read for UartPeripheral<Enabled, D, P>

source§

fn read(&mut self) -> Result<u8, Self::Error>

Reads a single word from the serial interface
source§

impl<D: UartDevice, P: ValidUartPinout<D>> Read for UartPeripheral<Enabled, D, P>

source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
source§

fn read_exact( &mut self, buf: &mut [u8] ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
source§

impl<D: UartDevice, P: ValidUartPinout<D>> Write for UartPeripheral<Enabled, D, P>

source§

fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>

Write a buffer into this writer, returning how many bytes were written. Read more
source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, blocking until all intermediately buffered contents reach their destination.
source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write an entire buffer into this writer. Read more
source§

fn write_fmt( &mut self, fmt: Arguments<'_> ) -> Result<(), WriteFmtError<Self::Error>>

Write a formatted string into this writer, returning any error encountered. Read more
source§

impl<D: UartDevice, P: ValidUartPinout<D>> Write for UartPeripheral<Enabled, D, P>

source§

fn write(&mut self, word: u8) -> Result<(), Self::Error>

Writes a single word to the serial interface.
source§

fn flush(&mut self) -> Result<(), Self::Error>

Ensures that none of the previously written words are still buffered.
source§

impl<D: UartDevice, P: ValidUartPinout<D>> Write for UartPeripheral<Enabled, D, P>

source§

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

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<D: UartDevice, P: ValidUartPinout<D>> Read<u8> for UartPeripheral<Enabled, D, P>

§

type Error = ReadErrorType

Read error
source§

fn read(&mut self) -> Result<u8, Self::Error>

Reads a single word from the serial interface
source§

impl<D: UartDevice, P: ValidUartPinout<D>> Write<u8> for UartPeripheral<Enabled, D, P>

§

type Error = Infallible

Write error
source§

fn write(&mut self, word: u8) -> Result<(), Self::Error>

Writes a single word to the serial interface
source§

fn flush(&mut self) -> Result<(), Self::Error>

Ensures that none of the previously written words are still buffered

Auto Trait Implementations§

§

impl<S, D, P> RefUnwindSafe for UartPeripheral<S, D, P>

§

impl<S, D, P> Send for UartPeripheral<S, D, P>
where D: Send, P: Send, S: Send,

§

impl<S, D, P> Sync for UartPeripheral<S, D, P>
where D: Sync, P: Sync, S: Sync,

§

impl<S, D, P> Unpin for UartPeripheral<S, D, P>
where D: Unpin, P: Unpin, S: Unpin,

§

impl<S, D, P> UnwindSafe for UartPeripheral<S, D, P>
where D: UnwindSafe, P: UnwindSafe, S: UnwindSafe,

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<Choices> CoproductSubsetter<CNil, HNil> for Choices

§

type Remainder = Choices

source§

fn subset( self ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) 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, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

source§

fn lift_into(self) -> U

Performs the indexed conversion.
source§

impl<Source> Sculptor<HNil, HNil> for Source

§

type Remainder = Source

source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
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.