pub struct StateMachine { /* private fields */ }
Implementations§
Source§impl StateMachine
impl StateMachine
Sourcepub fn config(&self, config: &StateMachineConfiguration)
pub fn config(&self, config: &StateMachineConfiguration)
State machine configuration with any config structure.
Sourcepub fn set_tx_client(&self, client: &'static dyn PioTxClient)
pub fn set_tx_client(&self, client: &'static dyn PioTxClient)
Set tx client for a state machine.
Sourcepub fn set_rx_client(&self, client: &'static dyn PioRxClient)
pub fn set_rx_client(&self, client: &'static dyn PioRxClient)
Set rx client for a state machine.
Sourcepub fn set_in_pins(&self, in_base: u32)
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
Sourcepub fn set_set_pins(&self, set_base: u32, set_count: u32)
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
Sourcepub fn set_out_pins(&self, out_base: u32, out_count: u32)
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
Sourcepub fn set_in_shift(
&self,
shift_right: bool,
autopush: bool,
push_threshold: u32,
)
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
Sourcepub fn set_out_shift(
&self,
shift_right: bool,
autopull: bool,
pull_threshold: u32,
)
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
Sourcepub fn set_out_special(
&self,
sticky: bool,
has_enable_pin: bool,
enable_pin_index: u32,
)
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
Sourcepub fn set_jmp_pin(&self, pin: u32)
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
Sourcepub fn set_clkdiv_int_frac(&self, div_int: u32, div_frac: u32)
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
Sourcepub fn set_fifo_join(&self, fifo_join: PioFifoJoin)
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
Sourcepub fn set_side_set_pins(
&self,
sideset_base: u32,
bit_count: u32,
optional: bool,
pindirs: bool,
)
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
Sourcepub fn set_pins_dirs(&self, pin: u32, count: u32, is_out: bool)
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
Sourcepub fn set_pins(&self, pins: &[&RPGpioPin<'_>], high: bool)
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
Sourcepub fn set_wrap(&self, wrap_target: u32, wrap: u32)
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
Sourcepub fn clear_fifos(&self)
pub fn clear_fifos(&self)
Clear a state machine’s TX and RX FIFOs.
Sourcepub fn clkdiv_restart(&self)
pub fn clkdiv_restart(&self)
Restart a state machine’s clock divider.
Sourcepub fn exec(&self, instr: u16)
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
Sourcepub fn exec_program(&self, program: LoadedProgram, wrap: bool)
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
Sourcepub fn set_mov_status(&self, status_sel: PioMovStatusType, status_n: u32)
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
Sourcepub fn set_enabled(&self, enabled: bool)
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
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Is state machine enabled.
Sourcepub fn push(&self, data: u32) -> Result<(), ErrorCode>
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
Sourcepub fn push_blocking(&self, data: u32) -> Result<(), ErrorCode>
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
Sourcepub fn pull(&self) -> Result<u32, ErrorCode>
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.
Sourcepub fn pull_blocking(&self) -> Result<u32, ErrorCode>
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.