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, eitherpio::Stoppedorpio::Running.
Implementations§
Source§impl<RXID: PinId, TXID: PinId, PIO: PIOExt> PioUart<RXID, TXID, PIO, Stopped>
impl<RXID: PinId, TXID: PinId, PIO: PIOExt> PioUart<RXID, TXID, PIO, Stopped>
Sourcepub 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
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 withFunctionPioXandPullUp. Usepin.gpioX.reconfigure().tx_pin: The TX pin configured withFunctionPioXandPullNone. Usepin.gpioX.reconfigure().resets: A mutable reference to the RP2040 resets.baud: Desired baud rate.system_freq: System frequency.
Trait Implementations§
Source§impl<RXID: PinId, TXID: PinId, PIO: PIOExt> ErrorType for PioUart<RXID, TXID, PIO, Running>
impl<RXID: PinId, TXID: PinId, PIO: PIOExt> ErrorType for PioUart<RXID, TXID, PIO, Running>
Source§type Error = PioSerialError
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>
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>
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>>
fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
Read the exact number of bytes required to fill
buf. Read moreSource§impl<RXID: PinId, TXID: PinId, PIO: PIOExt> Write for PioUart<RXID, TXID, PIO, Running>
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>
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>
fn flush(&mut self) -> Result<(), Self::Error>
Flush this output stream, blocking until all intermediately buffered contents reach their destination.
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>
impl<RXID, TXID, PIO, State> Send for PioUart<RXID, TXID, PIO, State>
impl<RXID, TXID, PIO, State> Unpin for PioUart<RXID, TXID, PIO, State>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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