PIOBuilder

Struct PIOBuilder 

Source
pub struct PIOBuilder<P> { /* private fields */ }
Expand description

Builder to deploy a fully configured PIO program on one of the state machines.

Implementations§

Source§

impl<P> PIOBuilder<P>
where P: PIOExt,

Source

pub fn from_installed_program(p: InstalledProgram<P>) -> PIOBuilder<P>

Set config settings based on information from the given InstalledProgram. Additional configuration may be needed in addition to this.

Note: This was formerly called from_program. The new function has a different default shift direction, ShiftDirection::Right, matching the hardware reset value.

Source

pub fn from_program(p: InstalledProgram<P>) -> PIOBuilder<P>

👎Deprecated: please use from_installed_program instead and update shift direction if necessary

Set config settings based on information from the given InstalledProgram. Additional configuration may be needed in addition to this.

Note: The shift direction for both input and output shift registers defaults to ShiftDirection::Left, which is different from the rp235x reset value. The alternative Self::from_installed_program, fixes this.

Source

pub fn set_mov_status_config(self, mov_status: MovStatusConfig) -> PIOBuilder<P>

Set the config for when the status register is set to true.

See MovStatusConfig for more info.

Source

pub fn set_pins(self, base: u8, count: u8) -> PIOBuilder<P>

Set the pins asserted by SET instruction.

The least-significant bit of SET instruction asserts the state of the pin indicated by base, the next bit asserts the state of the next pin, and so on up to count pins. The pin numbers are considered modulo 32.

Source

pub fn out_pins(self, base: u8, count: u8) -> PIOBuilder<P>

Set the pins asserted by OUT instruction.

The least-significant bit of OUT instruction asserts the state of the pin indicated by base, the next bit asserts the state of the next pin, and so on up to count pins. The pin numbers are considered modulo 32.

Source

pub fn in_pin_base(self, base: u8) -> PIOBuilder<P>

Set the pins used by IN instruction.

The IN instruction reads the least significant bit from the pin indicated by base, the next bit from the next pin, and so on. The pin numbers are considered modulo 32.

Source

pub fn jmp_pin(self, pin: u8) -> PIOBuilder<P>

Set the pin used by JMP PIN instruction.

When the pin set by this function is high, the jump is taken, otherwise not.

Source

pub fn side_set_pin_base(self, base: u8) -> PIOBuilder<P>

Set the pins used by side-set instructions.

The least-significant side-set bit asserts the state of the pin indicated by base, the next bit asserts the state of the next pin, and so on up to pio::SideSet::bits() bits as configured in pio::Program.

Source

pub fn buffers(self, buffers: Buffers) -> PIOBuilder<P>

Set buffer sharing.

See Buffers for more information.

Source

pub fn clock_divisor(self, divisor: f32) -> PIOBuilder<P>

👎Deprecated since 0.7.0: Pulls in floating points. Use the fixed point alternative: clock_divisor_fixed_point

Set the clock divisor.

The is based on the sys_clk. Set 1 for full speed. A clock divisor of n will cause the state machine to run 1 cycle every n clock cycles. For small values of n, a fractional divisor may introduce unacceptable jitter.

Source

pub fn clock_divisor_fixed_point(self, int: u16, frac: u8) -> PIOBuilder<P>

The clock is based on the sys_clk and will execute an instruction every int + (frac/256) ticks.

A clock divisor of n will cause the state machine to run 1 cycle every n clock cycles. If the integer part is 0 then the fractional part must be 0. This is interpreted by the device as the integer 65536.

For small values of int, a fractional divisor may introduce unacceptable jitter.

Source

pub fn out_sticky(self, out_sticky: bool) -> PIOBuilder<P>

Set the output sticky state.

When the output is set to be sticky, the PIO hardware continuously asserts the most recent OUT/SET to the pins.

Source

pub fn inline_out(self, inline_out: Option<u8>) -> PIOBuilder<P>

Set the inline OUT enable bit.

When set to value, the given bit of OUT instruction’s data is used as an auxiliary write enable. When used with Self::out_sticky, writes with enable 0 will deassert the latest pin write.

Source

pub fn autopush(self, autopush: bool) -> PIOBuilder<P>

Set the autopush state.

When autopush is enabled, the IN instruction automatically pushes the data once the number of bits reaches threshold set by Self::push_threshold.

Source

pub fn in_count(self, count: u8) -> PIOBuilder<P>

Set the number of pins which are not masked to 0 when read by an IN PINS, WAIT PIN or MOV x, PINS instruction.

For example, an IN_COUNT of 5 means that the 5 LSBs of the IN pin group are visible (bits 4:0), but the remaining 27 MSBs are masked to 0. A count of 32 is encoded with a field value of 0, so the default behaviour is to not perform any masking.

Source

pub fn push_threshold(self, threshold: u8) -> PIOBuilder<P>

Set the number of bits pushed into ISR before autopush or conditional push will take place.

Source

pub fn autopull(self, autopull: bool) -> PIOBuilder<P>

Set the autopull state.

When autopull is enabled, the OUT instruction automatically pulls the data once the number of bits reaches threshold set by Self::pull_threshold.

Source

pub fn pull_threshold(self, threshold: u8) -> PIOBuilder<P>

Set the number of bits pulled from out of OSR before autopull or conditional pull will take place.

Source

pub fn in_shift_direction(self, direction: ShiftDirection) -> PIOBuilder<P>

Set the ISR shift direction for IN instruction.

For example ShiftDirection::Right means that ISR is shifted to right, i.e. data enters from left.

Source

pub fn out_shift_direction(self, direction: ShiftDirection) -> PIOBuilder<P>

Set the OSR shift direction for OUT instruction.

For example ShiftDirection::Right means that OSR is shifted to right, i.e. data is taken from the right side.

Source

pub fn build<SM>( self, sm: UninitStateMachine<(P, SM)>, ) -> (StateMachine<(P, SM), Stopped>, Rx<(P, SM)>, Tx<(P, SM)>)

Build the config and deploy it to a StateMachine.

Trait Implementations§

Source§

impl<P> Debug for PIOBuilder<P>
where P: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Freeze for PIOBuilder<P>

§

impl<P> RefUnwindSafe for PIOBuilder<P>
where P: RefUnwindSafe,

§

impl<P> Send for PIOBuilder<P>
where P: Send,

§

impl<P> Sync for PIOBuilder<P>
where P: Sync,

§

impl<P> Unpin for PIOBuilder<P>
where P: Unpin,

§

impl<P> UnwindSafe for PIOBuilder<P>
where P: UnwindSafe,

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

Source§

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

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

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.