embassy-rp

Crates

git

Versions

rp2040

Flavors

Struct Assembler

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

Source

pub fn new() -> Assembler<PROGRAM_SIZE>

Create a new Assembler.

Source

pub fn new_with_side_set(side_set: SideSet) -> Assembler<PROGRAM_SIZE>

Create a new Assembler with SideSet settings.

Source

pub fn assemble(self) -> ArrayVec<u16, PROGRAM_SIZE>

Assemble the program into PIO instructions.

Source

pub fn version(&self) -> PioVersion

Check the program for instructions and operands available only on the RP2350.

Source

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.

Source

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.

Source

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>

Source

pub fn label(&mut self) -> Label

Create a new unbound Label.

Source

pub fn label_at_offset(&mut self, offset: u8) -> Label

Create a new label bound to given offset.

Source

pub fn bind(&mut self, label: &mut Label)

Bind label to the current instruction position.

Source§

impl<const PROGRAM_SIZE: usize> Assembler<PROGRAM_SIZE>

Source

pub fn jmp(&mut self, condition: JmpCondition, label: &mut Label)

Emit a jmp instruction to label for condition.

Source

pub fn jmp_with_delay( &mut self, condition: JmpCondition, label: &mut Label, delay: u8, )

Emit a jmp instruction to label for condition.

Source

pub fn jmp_with_side_set( &mut self, condition: JmpCondition, label: &mut Label, side_set: u8, )

Emit a jmp instruction to label for condition.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn in(&mut self, source: InSource, bit_count: u8)

Emit an in instruction from source with bit_count.

Source

pub fn in_with_delay(&mut self, source: InSource, bit_count: u8, delay: u8)

Emit an in instruction from source with bit_count.

Source

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.

Source

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.

Source

pub fn out(&mut self, destination: OutDestination, bit_count: u8)

Emit an out instruction to source with bit_count.

Source

pub fn out_with_delay( &mut self, destination: OutDestination, bit_count: u8, delay: u8, )

Emit an out instruction to source with bit_count.

Source

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.

Source

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.

Source

pub fn push(&mut self, if_full: bool, block: bool)

Emit a push instruction with if_full and block.

Source

pub fn push_with_delay(&mut self, if_full: bool, block: bool, delay: u8)

Emit a push instruction with if_full and block.

Source

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.

Source

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.

Source

pub fn pull(&mut self, if_empty: bool, block: bool)

Emit a pull instruction with if_empty and block.

Source

pub fn pull_with_delay(&mut self, if_empty: bool, block: bool, delay: u8)

Emit a pull instruction with if_empty and block.

Source

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.

Source

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.

Source

pub fn mov( &mut self, destination: MovDestination, op: MovOperation, source: MovSource, )

Emit a mov instruction to destination using op from source.

Source

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.

Source

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.

Source

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.

Source

pub fn mov_to_rx(&mut self, fifo_index: MovRxIndex)

Emit a mov to rx instruction.

Source

pub fn mov_to_rx_with_delay(&mut self, fifo_index: MovRxIndex, delay: u8)

Emit a mov to rx instruction.

Source

pub fn mov_to_rx_with_side_set(&mut self, fifo_index: MovRxIndex, side_set: u8)

Emit a mov to rx instruction.

Source

pub fn mov_to_rx_with_delay_and_side_set( &mut self, fifo_index: MovRxIndex, delay: u8, side_set: u8, )

Emit a mov to rx instruction.

Source

pub fn mov_from_rx(&mut self, fifo_index: MovRxIndex)

Emit a mov from rx instruction.

Source

pub fn mov_from_rx_with_delay(&mut self, fifo_index: MovRxIndex, delay: u8)

Emit a mov from rx instruction.

Source

pub fn mov_from_rx_with_side_set( &mut self, fifo_index: MovRxIndex, side_set: u8, )

Emit a mov from rx instruction.

Source

pub fn mov_from_rx_with_delay_and_side_set( &mut self, fifo_index: MovRxIndex, delay: u8, side_set: u8, )

Emit a mov from rx instruction.

Source

pub fn irq( &mut self, clear: bool, wait: bool, index: u8, index_mode: IrqIndexMode, )

Emit an irq instruction using clear and wait with index which may be relative.

Source

pub fn irq_with_delay( &mut self, clear: bool, wait: bool, index: u8, index_mode: IrqIndexMode, delay: u8, )

Emit an irq instruction using clear and wait with index which may be relative.

Source

pub fn irq_with_side_set( &mut self, clear: bool, wait: bool, index: u8, index_mode: IrqIndexMode, side_set: u8, )

Emit an irq instruction using clear and wait with index which may be relative.

Source

pub fn irq_with_delay_and_side_set( &mut self, clear: bool, wait: bool, index: u8, index_mode: IrqIndexMode, delay: u8, side_set: u8, )

Emit an irq instruction using clear and wait with index which may be relative.

Source

pub fn set(&mut self, destination: SetDestination, data: u8)

Emit a set instruction

Source

pub fn set_with_delay( &mut self, destination: SetDestination, data: u8, delay: u8, )

Emit a set instruction

Source

pub fn set_with_side_set( &mut self, destination: SetDestination, data: u8, side_set: u8, )

Emit a set instruction

Source

pub fn set_with_delay_and_side_set( &mut self, destination: SetDestination, data: u8, delay: u8, side_set: u8, )

Emit a set instruction

Source

pub fn nop(&mut self)

Emit a mov instruction from Y to Y without operation effectively acting as a nop instruction.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<const PROGRAM_SIZE: usize> Debug for Assembler<PROGRAM_SIZE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const PROGRAM_SIZE: usize> Freeze for Assembler<PROGRAM_SIZE>

§

impl<const PROGRAM_SIZE: usize> RefUnwindSafe for Assembler<PROGRAM_SIZE>

§

impl<const PROGRAM_SIZE: usize> Send for Assembler<PROGRAM_SIZE>

§

impl<const PROGRAM_SIZE: usize> Sync for Assembler<PROGRAM_SIZE>

§

impl<const PROGRAM_SIZE: usize> Unpin for Assembler<PROGRAM_SIZE>

§

impl<const PROGRAM_SIZE: usize> UnwindSafe for Assembler<PROGRAM_SIZE>

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.