UartPeripheral

Struct UartPeripheral 

Source
pub struct UartPeripheral<S, D, P>
where S: State, D: UartDevice, P: ValidUartPinout<D>,
{ /* private fields */ }
Expand description

An UART Peripheral based on an underlying UART device.

Implementations§

Source§

impl<S, D, P> UartPeripheral<S, D, P>
where S: State, D: UartDevice, P: ValidUartPinout<D>,

Source

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

Releases the underlying device and pins.

Source§

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

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: Rate<u32, 1, 1>, ) -> Result<UartPeripheral<Enabled, D, P>, Error>

Enables the provided UART device with the given configuration.

Source§

impl<D, P> UartPeripheral<Enabled, D, P>
where D: UartDevice, P: ValidUartPinout<D>,

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], Error<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, Error<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 lowlevel_break_start(&mut self)

Initiates a break

If transmitting, this takes effect immediately after the current byte has completed.
For proper execution of the break command, this must be held for at least 2 complete frames worth of time.

The device won’t be able to send anything while breaking.
§Example
serial.lowlevel_break_start();
// at 115_200Bps on 8N1 configuration, 20bits takes (20*10⁶)/115200 = 173.611…μs.
timer.delay_us(175);
serial.lowlevel_break_stop();
}
Source

pub fn lowlevel_break_stop(&mut self)

Terminates a break condition.

See lowlevel_break_start for more details.

Source

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

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

Source§

type Error = ReadErrorType

Error type
Source§

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

Source§

type Error = ReadErrorType

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

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

Source§

type Error = ReadErrorType

Read error
Source§

fn read( &mut self, ) -> Result<u8, Error<<UartPeripheral<Enabled, D, P> as Read<u8>>::Error>>

Reads a single word from the serial interface
Source§

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

Source§

fn read( &mut self, ) -> Result<u8, Error<<UartPeripheral<Enabled, D, P> as ErrorType>::Error>>

Reads a single word from the serial interface
Source§

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

Source§

fn read( &mut self, buf: &mut [u8], ) -> Result<usize, <UartPeripheral<Enabled, D, P> as ErrorType>::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, P> ReadReady for UartPeripheral<Enabled, D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

fn read_ready( &mut self, ) -> Result<bool, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>

Get whether the reader is ready for immediately reading. Read more
Source§

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

Source§

type Error = Infallible

Write error
Source§

fn write( &mut self, word: u8, ) -> Result<(), Error<<UartPeripheral<Enabled, D, P> as Write<u8>>::Error>>

Writes a single word to the serial interface
Source§

fn flush( &mut self, ) -> Result<(), Error<<UartPeripheral<Enabled, D, P> as Write<u8>>::Error>>

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

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

Source§

fn write( &mut self, word: u8, ) -> Result<(), Error<<UartPeripheral<Enabled, D, P> as ErrorType>::Error>>

Writes a single word to the serial interface.
Source§

fn flush( &mut self, ) -> Result<(), Error<<UartPeripheral<Enabled, D, P> as ErrorType>::Error>>

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

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

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

Source§

fn write( &mut self, buf: &[u8], ) -> Result<usize, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>

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

fn flush( &mut self, ) -> Result<(), <UartPeripheral<Enabled, D, P> as ErrorType>::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, P> WriteReady for UartPeripheral<Enabled, D, P>
where D: UartDevice, P: ValidUartPinout<D>,

Source§

fn write_ready( &mut self, ) -> Result<bool, <UartPeripheral<Enabled, D, P> as ErrorType>::Error>

Get whether the writer is ready for immediately writing. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<S, D, P> UnwindSafe for UartPeripheral<S, D, P>
where D: UnwindSafe, S: UnwindSafe, P: 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

Source§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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

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

Source§

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

Source§

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.