Struct rp2040_hal::pio::StateMachine
source · pub struct StateMachine<SM: ValidStateMachine, State> { /* private fields */ }
Expand description
PIO State Machine with an associated program.
Implementations§
source§impl<SM: ValidStateMachine, State> StateMachine<SM, State>
impl<SM: ValidStateMachine, State> StateMachine<SM, State>
sourcepub fn uninit(
self,
_rx: Rx<SM>,
_tx: Tx<SM>
) -> (UninitStateMachine<SM>, InstalledProgram<SM::PIO>)
pub fn uninit( self, _rx: Rx<SM>, _tx: Tx<SM> ) -> (UninitStateMachine<SM>, InstalledProgram<SM::PIO>)
Stops the state machine if it is still running and returns its program.
The program can be uninstalled to free space once it is no longer used by any state machine.
sourcepub fn instruction_address(&self) -> u32
pub fn instruction_address(&self) -> u32
The address of the instruction currently being executed.
sourcepub fn set_instruction(&mut self, instruction: u16)
👎Deprecated: Renamed to exec_instruction
pub fn set_instruction(&mut self, instruction: u16)
Execute the instruction immediately.
sourcepub fn exec_instruction(&mut self, instruction: Instruction)
pub fn exec_instruction(&mut self, instruction: Instruction)
Execute the instruction immediately.
If an instruction written to INSTR stalls, it is stored in the same instruction latch used by OUT EXEC and MOV EXEC, and will overwrite an in-progress instruction there. If EXEC instructions are used, instructions written to INSTR must not stall.
sourcepub fn clear_fifos(&mut self)
pub fn clear_fifos(&mut self)
Clear both TX and RX FIFOs
sourcepub fn drain_tx_fifo(&mut self)
pub fn drain_tx_fifo(&mut self)
Drain Tx fifo.
sourcepub fn set_clock_divisor(&mut self, divisor: f32)
pub fn set_clock_divisor(&mut self, divisor: f32)
Change the clock divider of a state machine.
Changing the clock divider of a running state machine is allowed and guaranteed to not cause any glitches, but the exact timing of clock pulses during the change is not specified.
sourcepub fn clock_divisor_fixed_point(&mut self, int: u16, frac: u8)
pub fn clock_divisor_fixed_point(&mut self, int: u16, frac: u8)
Change the clock divider of a state machine using a 16.8 fixed point value.
Changing the clock divider of a running state machine is allowed and guaranteed to not cause any glitches, but the exact timing of clock pulses during the change is not specified.
source§impl<SM: ValidStateMachine> StateMachine<SM, Stopped>
impl<SM: ValidStateMachine> StateMachine<SM, Stopped>
sourcepub fn start(self) -> StateMachine<SM, Running>
pub fn start(self) -> StateMachine<SM, Running>
Starts execution of the selected program.
sourcepub fn set_pins(&mut self, pins: impl IntoIterator<Item = (u8, PinState)>)
pub fn set_pins(&mut self, pins: impl IntoIterator<Item = (u8, PinState)>)
Sets the pin state for the specified pins.
The user has to make sure that they do not select any pins that are in use by any other state machines of the same PIO block.
The iterator’s item are pairs of (pin_number, pin_state)
.
sourcepub fn set_pindirs(&mut self, pindirs: impl IntoIterator<Item = (u8, PinDir)>)
pub fn set_pindirs(&mut self, pindirs: impl IntoIterator<Item = (u8, PinDir)>)
Set pin directions.
The user has to make sure that they do not select any pins that are in use by any other state machines of the same PIO block.
The iterator’s item are pairs of (pin_number, pin_dir)
.
source§impl<P: PIOExt, SM: StateMachineIndex> StateMachine<(P, SM), Stopped>
impl<P: PIOExt, SM: StateMachineIndex> StateMachine<(P, SM), Stopped>
sourcepub fn synchronize_with<'sm, SM2: StateMachineIndex>(
&'sm mut self,
_other_sm: &'sm mut StateMachine<(P, SM2), Stopped>
) -> Synchronize<'sm, (P, SM)>
pub fn synchronize_with<'sm, SM2: StateMachineIndex>( &'sm mut self, _other_sm: &'sm mut StateMachine<(P, SM2), Stopped> ) -> Synchronize<'sm, (P, SM)>
Restarts the clock dividers for the specified state machines.
As a result, the clock will be synchronous for the state machines, which is a precondition for synchronous operation.
The function returns an object that, once destructed, restarts the clock dividers. This object allows further state machines to be added if more than two shall be synchronized.
§Example
sm0.synchronize_with(sm1).and_with(sm2);
source§impl<P: PIOExt, SM: StateMachineIndex, State> StateMachine<(P, SM), State>
impl<P: PIOExt, SM: StateMachineIndex, State> StateMachine<(P, SM), State>
sourcepub fn with<SM2: StateMachineIndex>(
self,
other_sm: StateMachine<(P, SM2), State>
) -> StateMachineGroup2<P, SM, SM2, State>
pub fn with<SM2: StateMachineIndex>( self, other_sm: StateMachine<(P, SM2), State> ) -> StateMachineGroup2<P, SM, SM2, State>
Create a group of state machines, which can be started/stopped synchronously
source§impl<SM: ValidStateMachine> StateMachine<SM, Running>
impl<SM: ValidStateMachine> StateMachine<SM, Running>
Trait Implementations§
impl<SM: ValidStateMachine + Send, State> Send for StateMachine<SM, State>
Auto Trait Implementations§
impl<SM, State> Freeze for StateMachine<SM, State>
impl<SM, State> !RefUnwindSafe for StateMachine<SM, State>
impl<SM, State> !Sync for StateMachine<SM, State>
impl<SM, State> Unpin for StateMachine<SM, State>
impl<SM, State> !UnwindSafe for StateMachine<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
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>
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>
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