From 8ebe6e5f2029026594c703820c11d703da2c0334 Mon Sep 17 00:00:00 2001 From: pennae Date: Wed, 3 May 2023 17:16:35 +0200 Subject: [PATCH] rp/pio: drop Pio prefix from almost all names it's only any good for PioPin because there it follows a pattern of gpio pin alternate functions being named like that, everything else can just as well be referred to as `pio::Thing` --- embassy-rp/src/pio.rs | 158 ++++++++++++++--------------- embassy-rp/src/pio_instr_util.rs | 20 ++-- examples/rp/src/bin/pio_async.rs | 14 +-- examples/rp/src/bin/pio_hd44780.rs | 4 +- examples/rp/src/bin/ws2812-pio.rs | 10 +- 5 files changed, 103 insertions(+), 103 deletions(-) diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs index 2cf4761a..31273b5d 100644 --- a/embassy-rp/src/pio.rs +++ b/embassy-rp/src/pio.rs @@ -96,18 +96,18 @@ pub(crate) unsafe fn init() { /// Future that waits for TX-FIFO to become writable #[must_use = "futures do nothing unless you `.await` or poll them"] -pub struct FifoOutFuture<'a, 'd, PIO: PioInstance, const SM: usize> { - sm_tx: &'a mut PioStateMachineTx<'d, PIO, SM>, +pub struct FifoOutFuture<'a, 'd, PIO: Instance, const SM: usize> { + sm_tx: &'a mut StateMachineTx<'d, PIO, SM>, value: u32, } -impl<'a, 'd, PIO: PioInstance, const SM: usize> FifoOutFuture<'a, 'd, PIO, SM> { - pub fn new(sm: &'a mut PioStateMachineTx<'d, PIO, SM>, value: u32) -> Self { +impl<'a, 'd, PIO: Instance, const SM: usize> FifoOutFuture<'a, 'd, PIO, SM> { + pub fn new(sm: &'a mut StateMachineTx<'d, PIO, SM>, value: u32) -> Self { FifoOutFuture { sm_tx: sm, value } } } -impl<'a, 'd, PIO: PioInstance, const SM: usize> Future for FifoOutFuture<'a, 'd, PIO, SM> { +impl<'a, 'd, PIO: Instance, const SM: usize> Future for FifoOutFuture<'a, 'd, PIO, SM> { type Output = (); fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll { //debug!("Poll {},{}", PIO::PIO_NO, SM); @@ -127,7 +127,7 @@ impl<'a, 'd, PIO: PioInstance, const SM: usize> Future for FifoOutFuture<'a, 'd, } } -impl<'a, 'd, PIO: PioInstance, const SM: usize> Drop for FifoOutFuture<'a, 'd, PIO, SM> { +impl<'a, 'd, PIO: Instance, const SM: usize> Drop for FifoOutFuture<'a, 'd, PIO, SM> { fn drop(&mut self) { unsafe { PIO::PIO.irqs(0).inte().write_clear(|m| { @@ -139,17 +139,17 @@ impl<'a, 'd, PIO: PioInstance, const SM: usize> Drop for FifoOutFuture<'a, 'd, P /// Future that waits for RX-FIFO to become readable #[must_use = "futures do nothing unless you `.await` or poll them"] -pub struct FifoInFuture<'a, 'd, PIO: PioInstance, const SM: usize> { - sm_rx: &'a mut PioStateMachineRx<'d, PIO, SM>, +pub struct FifoInFuture<'a, 'd, PIO: Instance, const SM: usize> { + sm_rx: &'a mut StateMachineRx<'d, PIO, SM>, } -impl<'a, 'd, PIO: PioInstance, const SM: usize> FifoInFuture<'a, 'd, PIO, SM> { - pub fn new(sm: &'a mut PioStateMachineRx<'d, PIO, SM>) -> Self { +impl<'a, 'd, PIO: Instance, const SM: usize> FifoInFuture<'a, 'd, PIO, SM> { + pub fn new(sm: &'a mut StateMachineRx<'d, PIO, SM>) -> Self { FifoInFuture { sm_rx: sm } } } -impl<'a, 'd, PIO: PioInstance, const SM: usize> Future for FifoInFuture<'a, 'd, PIO, SM> { +impl<'a, 'd, PIO: Instance, const SM: usize> Future for FifoInFuture<'a, 'd, PIO, SM> { type Output = u32; fn poll(mut self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll { //debug!("Poll {},{}", PIO::PIO_NO, SM); @@ -168,7 +168,7 @@ impl<'a, 'd, PIO: PioInstance, const SM: usize> Future for FifoInFuture<'a, 'd, } } -impl<'a, 'd, PIO: PioInstance, const SM: usize> Drop for FifoInFuture<'a, 'd, PIO, SM> { +impl<'a, 'd, PIO: Instance, const SM: usize> Drop for FifoInFuture<'a, 'd, PIO, SM> { fn drop(&mut self) { unsafe { PIO::PIO.irqs(0).inte().write_clear(|m| { @@ -180,12 +180,12 @@ impl<'a, 'd, PIO: PioInstance, const SM: usize> Drop for FifoInFuture<'a, 'd, PI /// Future that waits for IRQ #[must_use = "futures do nothing unless you `.await` or poll them"] -pub struct IrqFuture<'a, 'd, PIO: PioInstance> { - pio: PhantomData<&'a PioIrq<'d, PIO, 0>>, +pub struct IrqFuture<'a, 'd, PIO: Instance> { + pio: PhantomData<&'a Irq<'d, PIO, 0>>, irq_no: u8, } -impl<'a, 'd, PIO: PioInstance> Future for IrqFuture<'a, 'd, PIO> { +impl<'a, 'd, PIO: Instance> Future for IrqFuture<'a, 'd, PIO> { type Output = (); fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll { //debug!("Poll {},{}", PIO::PIO_NO, SM); @@ -215,7 +215,7 @@ impl<'a, 'd, PIO: PioInstance> Future for IrqFuture<'a, 'd, PIO> { } } -impl<'a, 'd, PIO: PioInstance> Drop for IrqFuture<'a, 'd, PIO> { +impl<'a, 'd, PIO: Instance> Drop for IrqFuture<'a, 'd, PIO> { fn drop(&mut self) { unsafe { PIO::PIO.irqs(0).inte().write_clear(|m| { @@ -225,12 +225,12 @@ impl<'a, 'd, PIO: PioInstance> Drop for IrqFuture<'a, 'd, PIO> { } } -pub struct Pin<'l, PIO: PioInstance> { +pub struct Pin<'l, PIO: Instance> { pin: PeripheralRef<'l, AnyPin>, pio: PhantomData, } -impl<'l, PIO: PioInstance> Pin<'l, PIO> { +impl<'l, PIO: Instance> Pin<'l, PIO> { /// Set the pin's drive strength. #[inline] pub fn set_drive_strength(&mut self, strength: Drive) { @@ -293,11 +293,11 @@ impl<'l, PIO: PioInstance> Pin<'l, PIO> { } } -pub struct PioStateMachineRx<'d, PIO: PioInstance, const SM: usize> { +pub struct StateMachineRx<'d, PIO: Instance, const SM: usize> { pio: PhantomData<&'d PIO>, } -impl<'d, PIO: PioInstance, const SM: usize> PioStateMachineRx<'d, PIO, SM> { +impl<'d, PIO: Instance, const SM: usize> StateMachineRx<'d, PIO, SM> { pub fn empty(&self) -> bool { unsafe { PIO::PIO.fstat().read().rxempty() & (1u8 << SM) != 0 } } @@ -370,11 +370,11 @@ impl<'d, PIO: PioInstance, const SM: usize> PioStateMachineRx<'d, PIO, SM> { } } -pub struct PioStateMachineTx<'d, PIO: PioInstance, const SM: usize> { +pub struct StateMachineTx<'d, PIO: Instance, const SM: usize> { pio: PhantomData<&'d PIO>, } -impl<'d, PIO: PioInstance, const SM: usize> PioStateMachineTx<'d, PIO, SM> { +impl<'d, PIO: Instance, const SM: usize> StateMachineTx<'d, PIO, SM> { pub fn empty(&self) -> bool { unsafe { PIO::PIO.fstat().read().txempty() & (1u8 << SM) != 0 } } @@ -445,12 +445,12 @@ impl<'d, PIO: PioInstance, const SM: usize> PioStateMachineTx<'d, PIO, SM> { } } -pub struct PioStateMachine<'d, PIO: PioInstance, const SM: usize> { - rx: PioStateMachineRx<'d, PIO, SM>, - tx: PioStateMachineTx<'d, PIO, SM>, +pub struct StateMachine<'d, PIO: Instance, const SM: usize> { + rx: StateMachineRx<'d, PIO, SM>, + tx: StateMachineTx<'d, PIO, SM>, } -impl<'d, PIO: PioInstance, const SM: usize> Drop for PioStateMachine<'d, PIO, SM> { +impl<'d, PIO: Instance, const SM: usize> Drop for StateMachine<'d, PIO, SM> { fn drop(&mut self) { unsafe { PIO::PIO.ctrl().write_clear(|w| w.set_sm_enable(1 << SM)); @@ -459,7 +459,7 @@ impl<'d, PIO: PioInstance, const SM: usize> Drop for PioStateMachine<'d, PIO, SM } } -impl<'d, PIO: PioInstance + 'd, const SM: usize> PioStateMachine<'d, PIO, SM> { +impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> { #[inline(always)] fn this_sm() -> crate::pac::pio::StateMachine { PIO::PIO.sm(SM) @@ -771,35 +771,35 @@ impl<'d, PIO: PioInstance + 'd, const SM: usize> PioStateMachine<'d, PIO, SM> { } } - pub fn rx(&mut self) -> &mut PioStateMachineRx<'d, PIO, SM> { + pub fn rx(&mut self) -> &mut StateMachineRx<'d, PIO, SM> { &mut self.rx } - pub fn tx(&mut self) -> &mut PioStateMachineTx<'d, PIO, SM> { + pub fn tx(&mut self) -> &mut StateMachineTx<'d, PIO, SM> { &mut self.tx } - pub fn rx_tx(&mut self) -> (&mut PioStateMachineRx<'d, PIO, SM>, &mut PioStateMachineTx<'d, PIO, SM>) { + pub fn rx_tx(&mut self) -> (&mut StateMachineRx<'d, PIO, SM>, &mut StateMachineTx<'d, PIO, SM>) { (&mut self.rx, &mut self.tx) } } -pub struct PioCommon<'d, PIO: PioInstance> { +pub struct Common<'d, PIO: Instance> { instructions_used: u32, pio: PhantomData<&'d PIO>, } -impl<'d, PIO: PioInstance> Drop for PioCommon<'d, PIO> { +impl<'d, PIO: Instance> Drop for Common<'d, PIO> { fn drop(&mut self) { on_pio_drop::(); } } -pub struct PioInstanceMemory<'d, PIO: PioInstance> { +pub struct InstanceMemory<'d, PIO: Instance> { used_mask: u32, pio: PhantomData<&'d PIO>, } -impl<'d, PIO: PioInstance> PioCommon<'d, PIO> { - pub fn write_instr(&mut self, start: usize, instrs: I) -> PioInstanceMemory<'d, PIO> +impl<'d, PIO: Instance> Common<'d, PIO> { + pub fn write_instr(&mut self, start: usize, instrs: I) -> InstanceMemory<'d, PIO> where I: Iterator, { @@ -820,16 +820,16 @@ impl<'d, PIO: PioInstance> PioCommon<'d, PIO> { used_mask |= mask; } self.instructions_used |= used_mask; - PioInstanceMemory { + InstanceMemory { used_mask, pio: PhantomData, } } - /// Free instruction memory previously allocated with [`PioCommon::write_instr`]. + /// Free instruction memory previously allocated with [`Common::write_instr`]. /// This is always possible but unsafe if any state machine is still using this /// bit of memory. - pub unsafe fn free_instr(&mut self, instrs: PioInstanceMemory) { + pub unsafe fn free_instr(&mut self, instrs: InstanceMemory) { self.instructions_used &= !instrs.used_mask; } @@ -848,8 +848,8 @@ impl<'d, PIO: PioInstance> PioCommon<'d, PIO> { } /// Register a pin for PIO usage. Pins will be released from the PIO block - /// (i.e., have their `FUNCSEL` reset to `NULL`) when the [`PioCommon`] *and* - /// all [`PioStateMachine`]s for this block have been dropped. **Other members + /// (i.e., have their `FUNCSEL` reset to `NULL`) when the [`Common`] *and* + /// all [`StateMachine`]s for this block have been dropped. **Other members /// of [`Pio`] do not keep pin registrations alive.** pub fn make_pio_pin(&mut self, pin: impl Peripheral

+ 'd) -> Pin<'d, PIO> { into_ref!(pin); @@ -865,11 +865,11 @@ impl<'d, PIO: PioInstance> PioCommon<'d, PIO> { } } -pub struct PioIrq<'d, PIO: PioInstance, const N: usize> { +pub struct Irq<'d, PIO: Instance, const N: usize> { pio: PhantomData<&'d PIO>, } -impl<'d, PIO: PioInstance, const N: usize> PioIrq<'d, PIO, N> { +impl<'d, PIO: Instance, const N: usize> Irq<'d, PIO, N> { pub fn wait<'a>(&'a mut self) -> IrqFuture<'a, 'd, PIO> { IrqFuture { pio: PhantomData, @@ -879,11 +879,11 @@ impl<'d, PIO: PioInstance, const N: usize> PioIrq<'d, PIO, N> { } #[derive(Clone)] -pub struct PioIrqFlags<'d, PIO: PioInstance> { +pub struct IrqFlags<'d, PIO: Instance> { pio: PhantomData<&'d PIO>, } -impl<'d, PIO: PioInstance> PioIrqFlags<'d, PIO> { +impl<'d, PIO: Instance> IrqFlags<'d, PIO> { pub fn check(&self, irq_no: u8) -> bool { assert!(irq_no < 8); self.check_any(1 << irq_no) @@ -916,48 +916,48 @@ impl<'d, PIO: PioInstance> PioIrqFlags<'d, PIO> { } } -pub struct Pio<'d, PIO: PioInstance> { - pub common: PioCommon<'d, PIO>, - pub irq_flags: PioIrqFlags<'d, PIO>, - pub irq0: PioIrq<'d, PIO, 0>, - pub irq1: PioIrq<'d, PIO, 1>, - pub irq2: PioIrq<'d, PIO, 2>, - pub irq3: PioIrq<'d, PIO, 3>, - pub sm0: PioStateMachine<'d, PIO, 0>, - pub sm1: PioStateMachine<'d, PIO, 1>, - pub sm2: PioStateMachine<'d, PIO, 2>, - pub sm3: PioStateMachine<'d, PIO, 3>, +pub struct Pio<'d, PIO: Instance> { + pub common: Common<'d, PIO>, + pub irq_flags: IrqFlags<'d, PIO>, + pub irq0: Irq<'d, PIO, 0>, + pub irq1: Irq<'d, PIO, 1>, + pub irq2: Irq<'d, PIO, 2>, + pub irq3: Irq<'d, PIO, 3>, + pub sm0: StateMachine<'d, PIO, 0>, + pub sm1: StateMachine<'d, PIO, 1>, + pub sm2: StateMachine<'d, PIO, 2>, + pub sm3: StateMachine<'d, PIO, 3>, } -impl<'d, PIO: PioInstance> Pio<'d, PIO> { +impl<'d, PIO: Instance> Pio<'d, PIO> { pub fn new(_pio: impl Peripheral

+ 'd) -> Self { PIO::state().users.store(5, Ordering::Release); PIO::state().used_pins.store(0, Ordering::Release); Self { - common: PioCommon { + common: Common { instructions_used: 0, pio: PhantomData, }, - irq_flags: PioIrqFlags { pio: PhantomData }, - irq0: PioIrq { pio: PhantomData }, - irq1: PioIrq { pio: PhantomData }, - irq2: PioIrq { pio: PhantomData }, - irq3: PioIrq { pio: PhantomData }, - sm0: PioStateMachine { - rx: PioStateMachineRx { pio: PhantomData }, - tx: PioStateMachineTx { pio: PhantomData }, + irq_flags: IrqFlags { pio: PhantomData }, + irq0: Irq { pio: PhantomData }, + irq1: Irq { pio: PhantomData }, + irq2: Irq { pio: PhantomData }, + irq3: Irq { pio: PhantomData }, + sm0: StateMachine { + rx: StateMachineRx { pio: PhantomData }, + tx: StateMachineTx { pio: PhantomData }, }, - sm1: PioStateMachine { - rx: PioStateMachineRx { pio: PhantomData }, - tx: PioStateMachineTx { pio: PhantomData }, + sm1: StateMachine { + rx: StateMachineRx { pio: PhantomData }, + tx: StateMachineTx { pio: PhantomData }, }, - sm2: PioStateMachine { - rx: PioStateMachineRx { pio: PhantomData }, - tx: PioStateMachineTx { pio: PhantomData }, + sm2: StateMachine { + rx: StateMachineRx { pio: PhantomData }, + tx: StateMachineTx { pio: PhantomData }, }, - sm3: PioStateMachine { - rx: PioStateMachineRx { pio: PhantomData }, - tx: PioStateMachineTx { pio: PhantomData }, + sm3: StateMachine { + rx: StateMachineRx { pio: PhantomData }, + tx: StateMachineTx { pio: PhantomData }, }, } } @@ -974,7 +974,7 @@ pub struct State { used_pins: AtomicU32, } -fn on_pio_drop() { +fn on_pio_drop() { let state = PIO::state(); if state.users.fetch_sub(1, Ordering::AcqRel) == 1 { let used_pins = state.used_pins.load(Ordering::Relaxed); @@ -994,7 +994,7 @@ mod sealed { pub trait PioPin {} - pub trait PioInstance { + pub trait Instance { const PIO_NO: u8; const PIO: &'static crate::pac::pio::Pio; const FUNCSEL: crate::pac::io::vals::Gpio0ctrlFuncsel; @@ -1011,16 +1011,16 @@ mod sealed { } } -pub trait PioInstance: sealed::PioInstance + Sized + Unpin {} +pub trait Instance: sealed::Instance + Sized + Unpin {} macro_rules! impl_pio { ($name:ident, $pio:expr, $pac:ident, $funcsel:ident) => { - impl sealed::PioInstance for peripherals::$name { + impl sealed::Instance for peripherals::$name { const PIO_NO: u8 = $pio; const PIO: &'static pac::pio::Pio = &pac::$pac; const FUNCSEL: pac::io::vals::Gpio0ctrlFuncsel = pac::io::vals::Gpio0ctrlFuncsel::$funcsel; } - impl PioInstance for peripherals::$name {} + impl Instance for peripherals::$name {} }; } diff --git a/embassy-rp/src/pio_instr_util.rs b/embassy-rp/src/pio_instr_util.rs index 81abdb66..e425cf09 100644 --- a/embassy-rp/src/pio_instr_util.rs +++ b/embassy-rp/src/pio_instr_util.rs @@ -1,8 +1,8 @@ use pio::{InSource, InstructionOperands, JmpCondition, OutDestination, SetDestination}; -use crate::pio::{PioInstance, PioStateMachine}; +use crate::pio::{Instance, StateMachine}; -pub fn set_x(sm: &mut PioStateMachine, value: u32) { +pub fn set_x(sm: &mut StateMachine, value: u32) { const OUT: u16 = InstructionOperands::OUT { destination: OutDestination::X, bit_count: 32, @@ -12,7 +12,7 @@ pub fn set_x(sm: &mut PioStateMachine(sm: &mut PioStateMachine) -> u32 { +pub fn get_x(sm: &mut StateMachine) -> u32 { const IN: u16 = InstructionOperands::IN { source: InSource::X, bit_count: 32, @@ -22,7 +22,7 @@ pub fn get_x(sm: &mut PioStateMachine(sm: &mut PioStateMachine, value: u32) { +pub fn set_y(sm: &mut StateMachine, value: u32) { const OUT: u16 = InstructionOperands::OUT { destination: OutDestination::Y, bit_count: 32, @@ -32,7 +32,7 @@ pub fn set_y(sm: &mut PioStateMachine(sm: &mut PioStateMachine) -> u32 { +pub fn get_y(sm: &mut StateMachine) -> u32 { const IN: u16 = InstructionOperands::IN { source: InSource::Y, bit_count: 32, @@ -43,7 +43,7 @@ pub fn get_y(sm: &mut PioStateMachine(sm: &mut PioStateMachine, data: u8) { +pub fn set_pindir(sm: &mut StateMachine, data: u8) { let set: u16 = InstructionOperands::SET { destination: SetDestination::PINDIRS, data, @@ -52,7 +52,7 @@ pub fn set_pindir(sm: &mut PioStateMachine(sm: &mut PioStateMachine, data: u8) { +pub fn set_pin(sm: &mut StateMachine, data: u8) { let set: u16 = InstructionOperands::SET { destination: SetDestination::PINS, data, @@ -61,7 +61,7 @@ pub fn set_pin(sm: &mut PioStateMachine(sm: &mut PioStateMachine, data: u32) { +pub fn set_out_pin(sm: &mut StateMachine, data: u32) { const OUT: u16 = InstructionOperands::OUT { destination: OutDestination::PINS, bit_count: 32, @@ -70,7 +70,7 @@ pub fn set_out_pin(sm: &mut PioStateMachine

(sm: &mut PioStateMachine, data: u32) { +pub fn set_out_pindir(sm: &mut StateMachine, data: u32) { const OUT: u16 = InstructionOperands::OUT { destination: OutDestination::PINDIRS, bit_count: 32, @@ -80,7 +80,7 @@ pub fn set_out_pindir(sm: &mut PioStateMachin sm.exec_instr(OUT); } -pub fn exec_jmp(sm: &mut PioStateMachine, to_addr: u8) { +pub fn exec_jmp(sm: &mut StateMachine, to_addr: u8) { let jmp: u16 = InstructionOperands::JMP { address: to_addr, condition: JmpCondition::Always, diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs index 4e0ab5e3..461ea3ff 100644 --- a/examples/rp/src/bin/pio_async.rs +++ b/examples/rp/src/bin/pio_async.rs @@ -4,12 +4,12 @@ use defmt::info; use embassy_executor::Spawner; use embassy_rp::peripherals::PIO0; -use embassy_rp::pio::{Pio, PioCommon, PioIrq, PioPin, PioStateMachine, ShiftDirection}; +use embassy_rp::pio::{Common, Irq, Pio, PioPin, ShiftDirection, StateMachine}; use embassy_rp::pio_instr_util; use embassy_rp::relocate::RelocatedProgram; use {defmt_rtt as _, panic_probe as _}; -fn setup_pio_task_sm0(pio: &mut PioCommon, sm: &mut PioStateMachine, pin: impl PioPin) { +fn setup_pio_task_sm0(pio: &mut Common, sm: &mut StateMachine, pin: impl PioPin) { // Setup sm0 // Send data serially to pin @@ -37,7 +37,7 @@ fn setup_pio_task_sm0(pio: &mut PioCommon, sm: &mut PioStateMachine) { +async fn pio_task_sm0(mut sm: StateMachine<'static, PIO0, 0>) { sm.set_enable(true); let mut v = 0x0f0caffa; @@ -48,7 +48,7 @@ async fn pio_task_sm0(mut sm: PioStateMachine<'static, PIO0, 0>) { } } -fn setup_pio_task_sm1(pio: &mut PioCommon, sm: &mut PioStateMachine) { +fn setup_pio_task_sm1(pio: &mut Common, sm: &mut StateMachine) { // Setupm sm1 // Read 0b10101 repeatedly until ISR is full @@ -67,7 +67,7 @@ fn setup_pio_task_sm1(pio: &mut PioCommon, sm: &mut PioStateMachine) { +async fn pio_task_sm1(mut sm: StateMachine<'static, PIO0, 1>) { sm.set_enable(true); loop { let rx = sm.rx().wait_pull().await; @@ -75,7 +75,7 @@ async fn pio_task_sm1(mut sm: PioStateMachine<'static, PIO0, 1>) { } } -fn setup_pio_task_sm2(pio: &mut PioCommon, sm: &mut PioStateMachine) { +fn setup_pio_task_sm2(pio: &mut Common, sm: &mut StateMachine) { // Setup sm2 // Repeatedly trigger IRQ 3 @@ -99,7 +99,7 @@ fn setup_pio_task_sm2(pio: &mut PioCommon, sm: &mut PioStateMachine, mut sm: PioStateMachine<'static, PIO0, 2>) { +async fn pio_task_sm2(mut irq: Irq<'static, PIO0, 3>, mut sm: StateMachine<'static, PIO0, 2>) { sm.set_enable(true); loop { irq.wait().await; diff --git a/examples/rp/src/bin/pio_hd44780.rs b/examples/rp/src/bin/pio_hd44780.rs index f76d334e..17b2440c 100644 --- a/examples/rp/src/bin/pio_hd44780.rs +++ b/examples/rp/src/bin/pio_hd44780.rs @@ -7,7 +7,7 @@ use core::fmt::Write; use embassy_executor::Spawner; use embassy_rp::dma::{AnyChannel, Channel}; use embassy_rp::peripherals::PIO0; -use embassy_rp::pio::{FifoJoin, Pio, PioPin, PioStateMachine, ShiftDirection}; +use embassy_rp::pio::{FifoJoin, Pio, PioPin, ShiftDirection, StateMachine}; use embassy_rp::pwm::{Config, Pwm}; use embassy_rp::relocate::RelocatedProgram; use embassy_rp::{into_ref, Peripheral, PeripheralRef}; @@ -64,7 +64,7 @@ async fn main(_spawner: Spawner) { pub struct HD44780<'l> { dma: PeripheralRef<'l, AnyChannel>, - sm: PioStateMachine<'l, PIO0, 0>, + sm: StateMachine<'l, PIO0, 0>, buf: [u8; 40], } diff --git a/examples/rp/src/bin/ws2812-pio.rs b/examples/rp/src/bin/ws2812-pio.rs index c9c701a7..2e6860d8 100644 --- a/examples/rp/src/bin/ws2812-pio.rs +++ b/examples/rp/src/bin/ws2812-pio.rs @@ -4,18 +4,18 @@ use defmt::*; use embassy_executor::Spawner; -use embassy_rp::pio::{FifoJoin, Pio, PioCommon, PioInstance, PioPin, PioStateMachine, ShiftDirection}; +use embassy_rp::pio::{Common, FifoJoin, Instance, Pio, PioPin, ShiftDirection, StateMachine}; use embassy_rp::pio_instr_util; use embassy_rp::relocate::RelocatedProgram; use embassy_time::{Duration, Timer}; use smart_leds::RGB8; use {defmt_rtt as _, panic_probe as _}; -pub struct Ws2812<'d, P: PioInstance, const S: usize> { - sm: PioStateMachine<'d, P, S>, +pub struct Ws2812<'d, P: Instance, const S: usize> { + sm: StateMachine<'d, P, S>, } -impl<'d, P: PioInstance, const S: usize> Ws2812<'d, P, S> { - pub fn new(mut pio: PioCommon<'d, P>, mut sm: PioStateMachine<'d, P, S>, pin: impl PioPin) -> Self { +impl<'d, P: Instance, const S: usize> Ws2812<'d, P, S> { + pub fn new(mut pio: Common<'d, P>, mut sm: StateMachine<'d, P, S>, pin: impl PioPin) -> Self { // Setup sm0 // prepare the PIO program