pub struct Assembler<const PROGRAM_SIZE: usize> { /* private fields */ }
Expand description
A PIO Assembler. See chapter three of the RP2040 Datasheet.
Implementations§
source§impl<const PROGRAM_SIZE: usize> Assembler<PROGRAM_SIZE>
impl<const PROGRAM_SIZE: usize> Assembler<PROGRAM_SIZE>
sourcepub fn new_with_side_set(side_set: SideSet) -> Self
pub fn new_with_side_set(side_set: SideSet) -> Self
Create a new Assembler with SideSet
settings.
sourcepub fn assemble(self) -> ArrayVec<u16, PROGRAM_SIZE>
pub fn assemble(self) -> ArrayVec<u16, PROGRAM_SIZE>
Assemble the program into PIO instructions.
sourcepub fn assemble_program(self) -> Program<PROGRAM_SIZE>
pub fn assemble_program(self) -> Program<PROGRAM_SIZE>
Assemble the program into Program
.
The program contains the instructions and side-set info set. You can directly compile into a program with
correct wrapping with Self::assemble_with_wrap
, or you can set the wrapping after the compilation with
Program::set_wrap
.
sourcepub fn assemble_with_wrap(
self,
source: Label,
target: Label
) -> Program<PROGRAM_SIZE>
pub fn assemble_with_wrap(
self,
source: Label,
target: Label
) -> Program<PROGRAM_SIZE>
Assemble the program into Program
with wrapping.
Takes pair of labels controlling the wrapping. The first label is the source (top) of the wrap while the second label is the target (bottom) of the wrap. The source label should be positioned after the instruction from which the wrapping happens.
sourcepub fn label_offset(&self, label: &Label) -> u8
pub fn label_offset(&self, label: &Label) -> u8
Get the offset of a label in the program.
source§impl<const PROGRAM_SIZE: usize> Assembler<PROGRAM_SIZE>
impl<const PROGRAM_SIZE: usize> Assembler<PROGRAM_SIZE>
sourcepub fn jmp(&mut self, condition: JmpCondition, label: &mut Label)
pub fn jmp(&mut self, condition: JmpCondition, label: &mut Label)
Emit a jmp
instruction to label
for condition
.
sourcepub fn jmp_with_delay(
&mut self,
condition: JmpCondition,
label: &mut Label,
delay: u8
)
pub fn jmp_with_delay(
&mut self,
condition: JmpCondition,
label: &mut Label,
delay: u8
)
Emit a jmp
instruction to label
for condition
.
sourcepub fn jmp_with_side_set(
&mut self,
condition: JmpCondition,
label: &mut Label,
side_set: u8
)
pub fn jmp_with_side_set(
&mut self,
condition: JmpCondition,
label: &mut Label,
side_set: u8
)
Emit a jmp
instruction to label
for condition
.
sourcepub fn jmp_with_delay_and_side_set(
&mut self,
condition: JmpCondition,
label: &mut Label,
delay: u8,
side_set: u8
)
pub fn jmp_with_delay_and_side_set(
&mut self,
condition: JmpCondition,
label: &mut Label,
delay: u8,
side_set: u8
)
Emit a jmp
instruction to label
for condition
.
sourcepub fn wait(&mut self, polarity: u8, source: WaitSource, index: u8, relative: bool)
pub fn wait(&mut self, polarity: u8, source: WaitSource, index: u8, relative: bool)
Emit a wait
instruction with polarity
from source
with index
which may be
relative
.
sourcepub fn wait_with_delay(
&mut self,
polarity: u8,
source: WaitSource,
index: u8,
relative: bool,
delay: u8
)
pub fn wait_with_delay(
&mut self,
polarity: u8,
source: WaitSource,
index: u8,
relative: bool,
delay: u8
)
Emit a wait
instruction with polarity
from source
with index
which may be
relative
.
sourcepub fn wait_with_side_set(
&mut self,
polarity: u8,
source: WaitSource,
index: u8,
relative: bool,
side_set: u8
)
pub fn wait_with_side_set(
&mut self,
polarity: u8,
source: WaitSource,
index: u8,
relative: bool,
side_set: u8
)
Emit a wait
instruction with polarity
from source
with index
which may be
relative
.
sourcepub fn wait_with_delay_and_side_set(
&mut self,
polarity: u8,
source: WaitSource,
index: u8,
relative: bool,
delay: u8,
side_set: u8
)
pub fn wait_with_delay_and_side_set(
&mut self,
polarity: u8,
source: WaitSource,
index: u8,
relative: bool,
delay: u8,
side_set: u8
)
Emit a wait
instruction with polarity
from source
with index
which may be
relative
.
sourcepub fn in(&mut self, source: InSource, bit_count: u8)
pub fn in(&mut self, source: InSource, bit_count: u8)
Emit an in
instruction from source
with bit_count
.
sourcepub fn in_with_delay(&mut self, source: InSource, bit_count: u8, delay: u8)
pub fn in_with_delay(&mut self, source: InSource, bit_count: u8, delay: u8)
Emit an in
instruction from source
with bit_count
.
sourcepub fn in_with_side_set(&mut self, source: InSource, bit_count: u8, side_set: u8)
pub fn in_with_side_set(&mut self, source: InSource, bit_count: u8, side_set: u8)
Emit an in
instruction from source
with bit_count
.
sourcepub fn in_with_delay_and_side_set(
&mut self,
source: InSource,
bit_count: u8,
delay: u8,
side_set: u8
)
pub fn in_with_delay_and_side_set(
&mut self,
source: InSource,
bit_count: u8,
delay: u8,
side_set: u8
)
Emit an in
instruction from source
with bit_count
.
sourcepub fn out(&mut self, destination: OutDestination, bit_count: u8)
pub fn out(&mut self, destination: OutDestination, bit_count: u8)
Emit an out
instruction to source
with bit_count
.
sourcepub fn out_with_delay(
&mut self,
destination: OutDestination,
bit_count: u8,
delay: u8
)
pub fn out_with_delay(
&mut self,
destination: OutDestination,
bit_count: u8,
delay: u8
)
Emit an out
instruction to source
with bit_count
.
sourcepub fn out_with_side_set(
&mut self,
destination: OutDestination,
bit_count: u8,
side_set: u8
)
pub fn out_with_side_set(
&mut self,
destination: OutDestination,
bit_count: u8,
side_set: u8
)
Emit an out
instruction to source
with bit_count
.
sourcepub fn out_with_delay_and_side_set(
&mut self,
destination: OutDestination,
bit_count: u8,
delay: u8,
side_set: u8
)
pub fn out_with_delay_and_side_set(
&mut self,
destination: OutDestination,
bit_count: u8,
delay: u8,
side_set: u8
)
Emit an out
instruction to source
with bit_count
.
sourcepub fn push(&mut self, if_full: bool, block: bool)
pub fn push(&mut self, if_full: bool, block: bool)
Emit a push
instruction with if_full
and block
.
sourcepub fn push_with_delay(&mut self, if_full: bool, block: bool, delay: u8)
pub fn push_with_delay(&mut self, if_full: bool, block: bool, delay: u8)
Emit a push
instruction with if_full
and block
.
sourcepub fn push_with_side_set(&mut self, if_full: bool, block: bool, side_set: u8)
pub fn push_with_side_set(&mut self, if_full: bool, block: bool, side_set: u8)
Emit a push
instruction with if_full
and block
.
sourcepub fn push_with_delay_and_side_set(
&mut self,
if_full: bool,
block: bool,
delay: u8,
side_set: u8
)
pub fn push_with_delay_and_side_set(
&mut self,
if_full: bool,
block: bool,
delay: u8,
side_set: u8
)
Emit a push
instruction with if_full
and block
.
sourcepub fn pull(&mut self, if_empty: bool, block: bool)
pub fn pull(&mut self, if_empty: bool, block: bool)
Emit a pull
instruction with if_empty
and block
.
sourcepub fn pull_with_delay(&mut self, if_empty: bool, block: bool, delay: u8)
pub fn pull_with_delay(&mut self, if_empty: bool, block: bool, delay: u8)
Emit a pull
instruction with if_empty
and block
.
sourcepub fn pull_with_side_set(&mut self, if_empty: bool, block: bool, side_set: u8)
pub fn pull_with_side_set(&mut self, if_empty: bool, block: bool, side_set: u8)
Emit a pull
instruction with if_empty
and block
.
sourcepub fn pull_with_delay_and_side_set(
&mut self,
if_empty: bool,
block: bool,
delay: u8,
side_set: u8
)
pub fn pull_with_delay_and_side_set(
&mut self,
if_empty: bool,
block: bool,
delay: u8,
side_set: u8
)
Emit a pull
instruction with if_empty
and block
.
sourcepub fn mov(
&mut self,
destination: MovDestination,
op: MovOperation,
source: MovSource
)
pub fn mov(
&mut self,
destination: MovDestination,
op: MovOperation,
source: MovSource
)
Emit a mov
instruction to destination
using op
from source
.
sourcepub fn mov_with_delay(
&mut self,
destination: MovDestination,
op: MovOperation,
source: MovSource,
delay: u8
)
pub fn mov_with_delay(
&mut self,
destination: MovDestination,
op: MovOperation,
source: MovSource,
delay: u8
)
Emit a mov
instruction to destination
using op
from source
.
sourcepub fn mov_with_side_set(
&mut self,
destination: MovDestination,
op: MovOperation,
source: MovSource,
side_set: u8
)
pub fn mov_with_side_set(
&mut self,
destination: MovDestination,
op: MovOperation,
source: MovSource,
side_set: u8
)
Emit a mov
instruction to destination
using op
from source
.
sourcepub fn mov_with_delay_and_side_set(
&mut self,
destination: MovDestination,
op: MovOperation,
source: MovSource,
delay: u8,
side_set: u8
)
pub fn mov_with_delay_and_side_set(
&mut self,
destination: MovDestination,
op: MovOperation,
source: MovSource,
delay: u8,
side_set: u8
)
Emit a mov
instruction to destination
using op
from source
.
sourcepub fn irq(&mut self, clear: bool, wait: bool, index: u8, relative: bool)
pub fn irq(&mut self, clear: bool, wait: bool, index: u8, relative: bool)
Emit an irq
instruction using clear
and wait
with index
which may be relative
.
sourcepub fn irq_with_delay(
&mut self,
clear: bool,
wait: bool,
index: u8,
relative: bool,
delay: u8
)
pub fn irq_with_delay(
&mut self,
clear: bool,
wait: bool,
index: u8,
relative: bool,
delay: u8
)
Emit an irq
instruction using clear
and wait
with index
which may be relative
.
sourcepub fn irq_with_side_set(
&mut self,
clear: bool,
wait: bool,
index: u8,
relative: bool,
side_set: u8
)
pub fn irq_with_side_set(
&mut self,
clear: bool,
wait: bool,
index: u8,
relative: bool,
side_set: u8
)
Emit an irq
instruction using clear
and wait
with index
which may be relative
.
sourcepub fn irq_with_delay_and_side_set(
&mut self,
clear: bool,
wait: bool,
index: u8,
relative: bool,
delay: u8,
side_set: u8
)
pub fn irq_with_delay_and_side_set(
&mut self,
clear: bool,
wait: bool,
index: u8,
relative: bool,
delay: u8,
side_set: u8
)
Emit an irq
instruction using clear
and wait
with index
which may be relative
.
sourcepub fn set(&mut self, destination: SetDestination, data: u8)
pub fn set(&mut self, destination: SetDestination, data: u8)
Emit a set
instruction
sourcepub fn set_with_delay(&mut self, destination: SetDestination, data: u8, delay: u8)
pub fn set_with_delay(&mut self, destination: SetDestination, data: u8, delay: u8)
Emit a set
instruction
sourcepub fn set_with_side_set(
&mut self,
destination: SetDestination,
data: u8,
side_set: u8
)
pub fn set_with_side_set(
&mut self,
destination: SetDestination,
data: u8,
side_set: u8
)
Emit a set
instruction
sourcepub fn set_with_delay_and_side_set(
&mut self,
destination: SetDestination,
data: u8,
delay: u8,
side_set: u8
)
pub fn set_with_delay_and_side_set(
&mut self,
destination: SetDestination,
data: u8,
delay: u8,
side_set: u8
)
Emit a set
instruction
sourcepub fn nop(&mut self)
pub fn nop(&mut self)
Emit a mov
instruction from Y to Y without operation effectively acting as a nop
instruction.
sourcepub fn nop_with_delay(&mut self, delay: u8)
pub fn nop_with_delay(&mut self, delay: u8)
Emit a mov
instruction from Y to Y without operation effectively acting as a nop
instruction.
sourcepub fn nop_with_side_set(&mut self, side_set: u8)
pub fn nop_with_side_set(&mut self, side_set: u8)
Emit a mov
instruction from Y to Y without operation effectively acting as a nop
instruction.
sourcepub fn nop_with_delay_and_side_set(&mut self, delay: u8, side_set: u8)
pub fn nop_with_delay_and_side_set(&mut self, delay: u8, side_set: u8)
Emit a mov
instruction from Y to Y without operation effectively acting as a nop
instruction.