Struct StateMachine

Source
pub struct StateMachine { /* private fields */ }

Implementations§

Source§

impl StateMachine

Source

pub fn config(&self, config: &StateMachineConfiguration)

State machine configuration with any config structure.

Source

pub fn set_tx_client(&self, client: &'static dyn PioTxClient)

Set tx client for a state machine.

Source

pub fn set_rx_client(&self, client: &'static dyn PioRxClient)

Set rx client for a state machine.

Source

pub fn set_in_pins(&self, in_base: u32)

Set every config for the IN pins.

in_base => the starting location for the input pins

Source

pub fn set_set_pins(&self, set_base: u32, set_count: u32)

Set every config for the SET pins.

set_base => the starting location for the SET pins set_count => the number of SET pins

Source

pub fn set_out_pins(&self, out_base: u32, out_count: u32)

Set every config for the OUT pins.

out_base => the starting location for the OUT pins out_count => the number of OUT pins

Source

pub fn set_in_shift( &self, shift_right: bool, autopush: bool, push_threshold: u32, )

Setup ‘in’ shifting parameters.

shift_right => true to shift ISR to right or false to shift to left autopush => true to enable, false to disable push_threshold => threshold in bits to shift in before auto/conditional re-pushing of the ISR

Source

pub fn set_out_shift( &self, shift_right: bool, autopull: bool, pull_threshold: u32, )

Setup ‘out’ shifting parameters.

shift_right => true to shift OSR to right or false to shift to left autopull => true to enable, false to disable pull_threshold => threshold in bits to shift out before auto/conditional re-pulling of the OSR

Source

pub fn set_out_special( &self, sticky: bool, has_enable_pin: bool, enable_pin_index: u32, )

Set special OUT operations in a state machine.

sticky => true to enable sticky output (rere-asserting most recent OUT/SET pin values on subsequent cycles) => false to disable sticky output has_enable_pin => true to enable auxiliary OUT enable pin => false to disable auxiliary OUT enable pin enable_pin_index => pin index for auxiliary OUT enable

Source

pub fn set_jmp_pin(&self, pin: u32)

Set the ‘jmp’ pin.

pin => the raw GPIO pin number to use as the source for a jmp pin instruction

Source

pub fn set_clkdiv_int_frac(&self, div_int: u32, div_frac: u32)

Set the clock divider for a state machine.

div_int => Integer part of the divisor div_frac => Fractional part in 1/256ths

Source

pub fn set_fifo_join(&self, fifo_join: PioFifoJoin)

Setup the FIFO joining in a state machine.

fifo_join => specifies the join type - see the PioFifoJoin type

Source

pub fn set_side_set_pins( &self, sideset_base: u32, bit_count: u32, optional: bool, pindirs: bool, )

Set every config for the SIDESET pins.

sideset_base => the starting location for the SIDESET pins bit_count => number of SIDESET bits per instruction - max 5 optional => true to use the topmost sideset bit as a flag for whether to apply side set on that instruction => false to use sideset with every instruction pindirs => true to affect pin direction => false to affect value of a pin

Source

pub fn set_pins_dirs(&self, pin: u32, count: u32, is_out: bool)

Use a state machine to set the same pin direction for multiple consecutive pins for the PIO instance. This is the pio_sm_set_consecutive_pindirs function from the pico sdk, renamed to be more clear.

pin => starting pin count => how many pins (including the base) should be changed is_out => true to set the pin as OUT => false to set the pin as IN

Source

pub fn set_pins(&self, pins: &[&RPGpioPin<'_>], high: bool)

Sets pin output values. Pauses the state machine to run SET commands and temporarily unsets the OUT_STICKY bit to avoid side effects.

pins => pins to set the value for high => true to set the pin high

Source

pub fn set_wrap(&self, wrap_target: u32, wrap: u32)

Set the wrap addresses for a state machine.

wrap_target => the instruction memory address to wrap to wrap => the instruction memory address after which the program counters wraps to the target

Source

pub fn init(&self)

Resets the state machine to a consistent state and configures it.

Source

pub fn restart(&self)

Restart a state machine.

Source

pub fn clear_fifos(&self)

Clear a state machine’s TX and RX FIFOs.

Source

pub fn clkdiv_restart(&self)

Restart a state machine’s clock divider.

Source

pub fn tx_full(&self) -> bool

Returns true if the TX FIFO is full.

Source

pub fn rx_empty(&self) -> bool

Returns true if the RX FIFO is empty.

Source

pub fn tx_empty(&self) -> bool

Returns true if the TX FIFO is empty.

Source

pub fn exec(&self, instr: u16)

Immediately execute an instruction on a state machine.

=> instr: the instruction to execute Implicitly restricted size of instr to u16, cause it’s the size pio asm instr

Source

pub fn exec_program(&self, program: LoadedProgram, wrap: bool)

Executes a program on a state machine. Jumps to the instruction at given address and runs the program.

=> program: a program loaded to PIO => wrap: true to wrap the program, so it runs in loop

Source

pub fn set_mov_status(&self, status_sel: PioMovStatusType, status_n: u32)

Set source for ‘mov status’ in a state machine.

status_sel => comparison used for the MOV x, STATUS instruction status_n => comparison level for the MOV x, STATUS instruction

Source

pub fn set_enabled(&self, enabled: bool)

Set a state machine’s state to enabled or to disabled.

enabled => true to enable the state machine

Source

pub fn is_enabled(&self) -> bool

Is state machine enabled.

Source

pub fn push(&self, data: u32) -> Result<(), ErrorCode>

Write a word of data to a state machine’s TX FIFO. If the FIFO is full, the client will be notified when space is available.

=> data: the data to write to the FIFO

Source

pub fn push_blocking(&self, data: u32) -> Result<(), ErrorCode>

Wait until a state machine’s TX FIFO is empty, then write a word of data to it. If state machine is disabled and there is no space, an error will be returned. If SM is stalled on RX or in loop, this will block forever.

=> data: the data to write to the FIFO

Source

pub fn pull(&self) -> Result<u32, ErrorCode>

Read a word of data from a state machine’s RX FIFO. If the FIFO is empty, the client will be notified when data is available.

Source

pub fn pull_blocking(&self) -> Result<u32, ErrorCode>

Reads a word of data from a state machine’s RX FIFO. If state machine is disabled and there is no space, an error will be returned. If SM is stalled on TX or in loop, this will block forever.

Auto Trait Implementations§

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