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>

source

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.

source

pub fn instruction_address(&self) -> u32

The address of the instruction currently being executed.

source

pub fn set_instruction(&mut self, instruction: u16)

👎Deprecated: Renamed to exec_instruction

Execute the instruction immediately.

source

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.

source

pub fn stalled(&self) -> bool

Check if the current instruction is stalled.

source

pub fn clear_fifos(&mut self)

Clear both TX and RX FIFOs

source

pub fn drain_tx_fifo(&mut self)

Drain Tx fifo.

source

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.

source

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>

source

pub fn start(self) -> StateMachine<SM, Running>

Starts execution of the selected program.

source

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).

source

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>

source

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>

source

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>

source

pub fn stop(self) -> StateMachine<SM, Stopped>

Stops execution of the selected program.

source

pub fn restart(&mut self)

Restarts the execution of the selected program from its wrap target.

Trait Implementations§

source§

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>
where State: Unpin, SM: Unpin, <SM as ValidStateMachine>::PIO: Unpin,

§

impl<SM, State> !UnwindSafe for StateMachine<SM, State>

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

§

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

§

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

§

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

§

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.