Skip to main content

PioUart

Struct PioUart 

Source
pub struct PioUart<RXID: PinId, TXID: PinId, PIO: PIOExt, State> { /* private fields */ }
Expand description

Represents a UART interface using the RP2040’s PIO hardware.

§Type Parameters

  • RXID: The PinId for the RX pin.
  • TXID: The PinId for the TX pin.
  • PIO: The PIO instance, either pac::PIO0 or pac::PIO1.
  • State: The state of the UART interface, either pio::Stopped or pio::Running.

Implementations§

Source§

impl<RXID: PinId, TXID: PinId, PIO: PIOExt> PioUart<RXID, TXID, PIO, Stopped>

Source

pub fn new( pio: PIO, rx_pin: Pin<RXID, <PIO as PIOExt>::PinFunction, PullUp>, tx_pin: Pin<TXID, <PIO as PIOExt>::PinFunction, PullNone>, resets: &mut RESETS, baud: HertzU32, system_freq: HertzU32, ) -> Self

Create a new PioUart instance. This method consumes the PIO instance and does not allow to use the other 2 state machines. If more control is required, use PioUartRx and PioUartTx individually.

§Arguments
  • pio: A PIO instance from the RP2040, either pac::PIO0 or pac::PIO1.
  • rx_pin: The RX pin configured with FunctionPioX and PullUp. Use pin.gpioX.reconfigure().
  • tx_pin: The TX pin configured with FunctionPioX and PullNone. Use pin.gpioX.reconfigure().
  • resets: A mutable reference to the RP2040 resets.
  • baud: Desired baud rate.
  • system_freq: System frequency.
Source

pub fn enable(self) -> PioUart<RXID, TXID, PIO, Running>

Enables the UART, transitioning it to the Running state.

§Returns

An instance of PioUart in the Running state.

Source

pub fn free( self, ) -> (PIO, Pin<RXID, <PIO as PIOExt>::PinFunction, PullUp>, Pin<TXID, <PIO as PIOExt>::PinFunction, PullNone>)

Frees the underlying resources, returning the PIO instance and pins. Also uninstalls the UART programs.

§Returns

A tuple containing the PIO, RX pin, and TX pin.

Trait Implementations§

Source§

impl<RXID: PinId, TXID: PinId, PIO: PIOExt> ErrorType for PioUart<RXID, TXID, PIO, Running>

Source§

type Error = PioSerialError

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

impl<RXID: PinId, TXID: PinId, PIO: PIOExt> Read for PioUart<RXID, TXID, PIO, Running>

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<RXID: PinId, TXID: PinId, PIO: PIOExt> Write for PioUart<RXID, TXID, PIO, Running>

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

Auto Trait Implementations§

§

impl<RXID, TXID, PIO, State> !RefUnwindSafe for PioUart<RXID, TXID, PIO, State>

§

impl<RXID, TXID, PIO, State> !Sync for PioUart<RXID, TXID, PIO, State>

§

impl<RXID, TXID, PIO, State> !UnwindSafe for PioUart<RXID, TXID, PIO, State>

§

impl<RXID, TXID, PIO, State> Freeze for PioUart<RXID, TXID, PIO, State>
where PIO: Freeze, RXID: Freeze, <PIO as PIOExt>::PinFunction: Freeze, TXID: Freeze,

§

impl<RXID, TXID, PIO, State> Send for PioUart<RXID, TXID, PIO, State>
where RXID: Send, <PIO as PIOExt>::PinFunction: Send, TXID: Send,

§

impl<RXID, TXID, PIO, State> Unpin for PioUart<RXID, TXID, PIO, State>
where PIO: Unpin, RXID: Unpin, <PIO as PIOExt>::PinFunction: Unpin, TXID: Unpin, State: Unpin,

§

impl<RXID, TXID, PIO, State> UnsafeUnpin for PioUart<RXID, TXID, PIO, State>
where PIO: UnsafeUnpin, RXID: UnsafeUnpin, <PIO as PIOExt>::PinFunction: UnsafeUnpin, TXID: UnsafeUnpin,

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.