pub struct PioUartRx<PinID: PinId, PIO: PIOExt, SM: StateMachineIndex, State> { /* private fields */ }Expand description
Represents the Rx part of a UART interface using the RP2040’s PIO hardware.
§Type Parameters
PinID: The PinId for the RX pin.SM: The state machine to use.State: The state of the UART interface, eitherpio::Stoppedorpio::Running.
Implementations§
Source§impl<PinID: PinId, PIO: PIOExt, SM: StateMachineIndex> PioUartRx<PinID, PIO, SM, Stopped>
impl<PinID: PinId, PIO: PIOExt, SM: StateMachineIndex> PioUartRx<PinID, PIO, SM, Stopped>
Sourcepub fn new(
rx_pin: Pin<PinID, PIO::PinFunction, PullUp>,
rx_sm: UninitStateMachine<(PIO, SM)>,
rx_program: &mut RxProgram<PIO>,
baud: HertzU32,
system_freq: HertzU32,
) -> Self
pub fn new( rx_pin: Pin<PinID, PIO::PinFunction, PullUp>, rx_sm: UninitStateMachine<(PIO, SM)>, rx_program: &mut RxProgram<PIO>, baud: HertzU32, system_freq: HertzU32, ) -> Self
Create a new PioUartRx instance.
Requires the RxProgram to be already installed (see install_rx_program).
§Arguments
rx_pin: The RX pin configured withFunctionPioXandPullUp. Usepin.gpioX.reconfigure().sm: A PIO state machine instance.rx_program: The installed Rx program.baud: Desired baud rate.system_freq: System frequency.
Sourcepub fn enable(self) -> PioUartRx<PinID, PIO, SM, Running>
pub fn enable(self) -> PioUartRx<PinID, PIO, SM, Running>
Enables the UART, transitioning it to the Running state.
§Returns
An instance of PioUartRx in the Running state.
Sourcepub fn free(
self,
) -> (UninitStateMachine<(PIO, SM)>, Pin<PinID, PIO::PinFunction, PullUp>)
pub fn free( self, ) -> (UninitStateMachine<(PIO, SM)>, Pin<PinID, PIO::PinFunction, PullUp>)
Frees the underlying resources, returning the SM instance and the pin.
§Returns
A tuple containing the used SM and the RX pin.
Trait Implementations§
Source§impl<PinID: PinId, PIO: PIOExt, SM: StateMachineIndex> ErrorType for PioUartRx<PinID, PIO, SM, Running>
impl<PinID: PinId, PIO: PIOExt, SM: StateMachineIndex> ErrorType for PioUartRx<PinID, PIO, SM, Running>
Source§type Error = PioSerialError
type Error = PioSerialError
Error type of all the IO operations on this type.
Source§impl<PinID: PinId, PIO: PIOExt, SM: StateMachineIndex> Read for PioUartRx<PinID, PIO, SM, Running>
impl<PinID: PinId, PIO: PIOExt, SM: StateMachineIndex> Read for PioUartRx<PinID, PIO, SM, 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 moreAuto Trait Implementations§
impl<PinID, PIO, SM, State> Freeze for PioUartRx<PinID, PIO, SM, State>
impl<PinID, PIO, SM, State> !RefUnwindSafe for PioUartRx<PinID, PIO, SM, State>
impl<PinID, PIO, SM, State> Send for PioUartRx<PinID, PIO, SM, State>
impl<PinID, PIO, SM, State> !Sync for PioUartRx<PinID, PIO, SM, State>
impl<PinID, PIO, SM, State> Unpin for PioUartRx<PinID, PIO, SM, State>
impl<PinID, PIO, SM, State> !UnwindSafe for PioUartRx<PinID, PIO, SM, State>
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