diff options
| author | pennae <[email protected]> | 2023-05-03 09:42:42 +0200 |
|---|---|---|
| committer | pennae <[email protected]> | 2023-05-03 11:25:58 +0200 |
| commit | 906d2b2db78d287ad818ab2a7abb1fec572ac6f6 (patch) | |
| tree | 2e920e24d99bc1d8fab1da080376c74f4ceeed9f | |
| parent | 79985f003646d379f2aea2738dc0291770e701c5 (diff) | |
rp/pio: PioStateMachine{Instance, => ,Instance}
next step: get rid of the insance trait entirely
| -rw-r--r-- | embassy-rp/src/pio.rs | 44 | ||||
| -rw-r--r-- | embassy-rp/src/pio_instr_util.rs | 20 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_async.rs | 12 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_dma.rs | 2 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_hd44780.rs | 2 | ||||
| -rw-r--r-- | examples/rp/src/bin/ws2812-pio.rs | 4 |
6 files changed, 42 insertions, 42 deletions
diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs index ffd8d53dd..a2e3d3a91 100644 --- a/embassy-rp/src/pio.rs +++ b/embassy-rp/src/pio.rs | |||
| @@ -97,13 +97,13 @@ pub(crate) unsafe fn init() { | |||
| 97 | 97 | ||
| 98 | /// Future that waits for TX-FIFO to become writable | 98 | /// Future that waits for TX-FIFO to become writable |
| 99 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 99 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 100 | pub struct FifoOutFuture<'a, PIO: PioInstance, SM: PioStateMachine + Unpin> { | 100 | pub struct FifoOutFuture<'a, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> { |
| 101 | sm: &'a mut SM, | 101 | sm: &'a mut SM, |
| 102 | pio: PhantomData<PIO>, | 102 | pio: PhantomData<PIO>, |
| 103 | value: u32, | 103 | value: u32, |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | impl<'a, PIO: PioInstance, SM: PioStateMachine + Unpin> FifoOutFuture<'a, PIO, SM> { | 106 | impl<'a, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> FifoOutFuture<'a, PIO, SM> { |
| 107 | pub fn new(sm: &'a mut SM, value: u32) -> Self { | 107 | pub fn new(sm: &'a mut SM, value: u32) -> Self { |
| 108 | FifoOutFuture { | 108 | FifoOutFuture { |
| 109 | sm, | 109 | sm, |
| @@ -113,7 +113,7 @@ impl<'a, PIO: PioInstance, SM: PioStateMachine + Unpin> FifoOutFuture<'a, PIO, S | |||
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | impl<'d, PIO: PioInstance, SM: PioStateMachine + Unpin> Future for FifoOutFuture<'d, PIO, SM> { | 116 | impl<'d, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> Future for FifoOutFuture<'d, PIO, SM> { |
| 117 | type Output = (); | 117 | type Output = (); |
| 118 | fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | 118 | fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| 119 | //debug!("Poll {},{}", PIO::PIO_NO, SM); | 119 | //debug!("Poll {},{}", PIO::PIO_NO, SM); |
| @@ -133,7 +133,7 @@ impl<'d, PIO: PioInstance, SM: PioStateMachine + Unpin> Future for FifoOutFuture | |||
| 133 | } | 133 | } |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | impl<'d, PIO: PioInstance, SM: PioStateMachine + Unpin> Drop for FifoOutFuture<'d, PIO, SM> { | 136 | impl<'d, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> Drop for FifoOutFuture<'d, PIO, SM> { |
| 137 | fn drop(&mut self) { | 137 | fn drop(&mut self) { |
| 138 | unsafe { | 138 | unsafe { |
| 139 | PIO::PIO.irqs(0).inte().write_clear(|m| { | 139 | PIO::PIO.irqs(0).inte().write_clear(|m| { |
| @@ -145,12 +145,12 @@ impl<'d, PIO: PioInstance, SM: PioStateMachine + Unpin> Drop for FifoOutFuture<' | |||
| 145 | 145 | ||
| 146 | /// Future that waits for RX-FIFO to become readable | 146 | /// Future that waits for RX-FIFO to become readable |
| 147 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 147 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 148 | pub struct FifoInFuture<'a, PIO: PioInstance, SM: PioStateMachine> { | 148 | pub struct FifoInFuture<'a, PIO: PioInstance, SM: PioStateMachineInstance> { |
| 149 | sm: &'a mut SM, | 149 | sm: &'a mut SM, |
| 150 | pio: PhantomData<PIO>, | 150 | pio: PhantomData<PIO>, |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | impl<'a, PIO: PioInstance, SM: PioStateMachine> FifoInFuture<'a, PIO, SM> { | 153 | impl<'a, PIO: PioInstance, SM: PioStateMachineInstance> FifoInFuture<'a, PIO, SM> { |
| 154 | pub fn new(sm: &'a mut SM) -> Self { | 154 | pub fn new(sm: &'a mut SM) -> Self { |
| 155 | FifoInFuture { | 155 | FifoInFuture { |
| 156 | sm, | 156 | sm, |
| @@ -159,7 +159,7 @@ impl<'a, PIO: PioInstance, SM: PioStateMachine> FifoInFuture<'a, PIO, SM> { | |||
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | impl<'d, PIO: PioInstance, SM: PioStateMachine> Future for FifoInFuture<'d, PIO, SM> { | 162 | impl<'d, PIO: PioInstance, SM: PioStateMachineInstance> Future for FifoInFuture<'d, PIO, SM> { |
| 163 | type Output = u32; | 163 | type Output = u32; |
| 164 | fn poll(mut self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | 164 | fn poll(mut self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| 165 | //debug!("Poll {},{}", PIO::PIO_NO, SM); | 165 | //debug!("Poll {},{}", PIO::PIO_NO, SM); |
| @@ -178,7 +178,7 @@ impl<'d, PIO: PioInstance, SM: PioStateMachine> Future for FifoInFuture<'d, PIO, | |||
| 178 | } | 178 | } |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | impl<'d, PIO: PioInstance, SM: PioStateMachine> Drop for FifoInFuture<'d, PIO, SM> { | 181 | impl<'d, PIO: PioInstance, SM: PioStateMachineInstance> Drop for FifoInFuture<'d, PIO, SM> { |
| 182 | fn drop(&mut self) { | 182 | fn drop(&mut self) { |
| 183 | unsafe { | 183 | unsafe { |
| 184 | PIO::PIO.irqs(0).inte().write_clear(|m| { | 184 | PIO::PIO.irqs(0).inte().write_clear(|m| { |
| @@ -312,11 +312,11 @@ impl<'l, PIO: PioInstance> Pin<'l, PIO> { | |||
| 312 | } | 312 | } |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | pub struct PioStateMachineInstance<'d, PIO: PioInstance, const SM: usize> { | 315 | pub struct PioStateMachine<'d, PIO: PioInstance, const SM: usize> { |
| 316 | pio: PhantomData<&'d PIO>, | 316 | pio: PhantomData<&'d PIO>, |
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | impl<'d, PIO: PioInstance, const SM: usize> Drop for PioStateMachineInstance<'d, PIO, SM> { | 319 | impl<'d, PIO: PioInstance, const SM: usize> Drop for PioStateMachine<'d, PIO, SM> { |
| 320 | fn drop(&mut self) { | 320 | fn drop(&mut self) { |
| 321 | unsafe { | 321 | unsafe { |
| 322 | PIO::PIO.ctrl().write_clear(|w| w.set_sm_enable(1 << SM)); | 322 | PIO::PIO.ctrl().write_clear(|w| w.set_sm_enable(1 << SM)); |
| @@ -325,13 +325,13 @@ impl<'d, PIO: PioInstance, const SM: usize> Drop for PioStateMachineInstance<'d, | |||
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | impl<'d, PIO: PioInstance, const SM: usize> sealed::PioStateMachine for PioStateMachineInstance<'d, PIO, SM> { | 328 | impl<'d, PIO: PioInstance, const SM: usize> sealed::PioStateMachineInstance for PioStateMachine<'d, PIO, SM> { |
| 329 | type Pio = PIO; | 329 | type Pio = PIO; |
| 330 | const SM: usize = SM; | 330 | const SM: usize = SM; |
| 331 | } | 331 | } |
| 332 | impl<'d, PIO: PioInstance, const SM: usize> PioStateMachine for PioStateMachineInstance<'d, PIO, SM> {} | 332 | impl<'d, PIO: PioInstance, const SM: usize> PioStateMachineInstance for PioStateMachine<'d, PIO, SM> {} |
| 333 | 333 | ||
| 334 | pub trait PioStateMachine: sealed::PioStateMachine + Sized + Unpin { | 334 | pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unpin { |
| 335 | fn restart(&mut self) { | 335 | fn restart(&mut self) { |
| 336 | let mask = 1u8 << Self::SM; | 336 | let mask = 1u8 << Self::SM; |
| 337 | unsafe { | 337 | unsafe { |
| @@ -892,10 +892,10 @@ impl<'d, PIO: PioInstance> PioCommon<'d, PIO> { | |||
| 892 | 892 | ||
| 893 | pub struct Pio<'d, PIO: PioInstance> { | 893 | pub struct Pio<'d, PIO: PioInstance> { |
| 894 | pub common: PioCommon<'d, PIO>, | 894 | pub common: PioCommon<'d, PIO>, |
| 895 | pub sm0: PioStateMachineInstance<'d, PIO, 0>, | 895 | pub sm0: PioStateMachine<'d, PIO, 0>, |
| 896 | pub sm1: PioStateMachineInstance<'d, PIO, 1>, | 896 | pub sm1: PioStateMachine<'d, PIO, 1>, |
| 897 | pub sm2: PioStateMachineInstance<'d, PIO, 2>, | 897 | pub sm2: PioStateMachine<'d, PIO, 2>, |
| 898 | pub sm3: PioStateMachineInstance<'d, PIO, 3>, | 898 | pub sm3: PioStateMachine<'d, PIO, 3>, |
| 899 | } | 899 | } |
| 900 | 900 | ||
| 901 | impl<'d, PIO: PioInstance> Pio<'d, PIO> { | 901 | impl<'d, PIO: PioInstance> Pio<'d, PIO> { |
| @@ -907,10 +907,10 @@ impl<'d, PIO: PioInstance> Pio<'d, PIO> { | |||
| 907 | instructions_used: 0, | 907 | instructions_used: 0, |
| 908 | pio: PhantomData, | 908 | pio: PhantomData, |
| 909 | }, | 909 | }, |
| 910 | sm0: PioStateMachineInstance { pio: PhantomData }, | 910 | sm0: PioStateMachine { pio: PhantomData }, |
| 911 | sm1: PioStateMachineInstance { pio: PhantomData }, | 911 | sm1: PioStateMachine { pio: PhantomData }, |
| 912 | sm2: PioStateMachineInstance { pio: PhantomData }, | 912 | sm2: PioStateMachine { pio: PhantomData }, |
| 913 | sm3: PioStateMachineInstance { pio: PhantomData }, | 913 | sm3: PioStateMachine { pio: PhantomData }, |
| 914 | } | 914 | } |
| 915 | } | 915 | } |
| 916 | } | 916 | } |
| @@ -944,7 +944,7 @@ fn on_pio_drop<PIO: PioInstance>() { | |||
| 944 | mod sealed { | 944 | mod sealed { |
| 945 | use super::*; | 945 | use super::*; |
| 946 | 946 | ||
| 947 | pub trait PioStateMachine { | 947 | pub trait PioStateMachineInstance { |
| 948 | type Pio: super::PioInstance; | 948 | type Pio: super::PioInstance; |
| 949 | const SM: usize; | 949 | const SM: usize; |
| 950 | 950 | ||
diff --git a/embassy-rp/src/pio_instr_util.rs b/embassy-rp/src/pio_instr_util.rs index ae26ff1dc..f5e7d7abd 100644 --- a/embassy-rp/src/pio_instr_util.rs +++ b/embassy-rp/src/pio_instr_util.rs | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | use pio::{InSource, InstructionOperands, JmpCondition, OutDestination, SetDestination}; | 1 | use pio::{InSource, InstructionOperands, JmpCondition, OutDestination, SetDestination}; |
| 2 | 2 | ||
| 3 | use crate::pio::PioStateMachine; | 3 | use crate::pio::PioStateMachineInstance; |
| 4 | 4 | ||
| 5 | pub fn set_x<SM: PioStateMachine>(sm: &mut SM, value: u32) { | 5 | pub fn set_x<SM: PioStateMachineInstance>(sm: &mut SM, value: u32) { |
| 6 | const OUT: u16 = InstructionOperands::OUT { | 6 | const OUT: u16 = InstructionOperands::OUT { |
| 7 | destination: OutDestination::X, | 7 | destination: OutDestination::X, |
| 8 | bit_count: 32, | 8 | bit_count: 32, |
| @@ -12,7 +12,7 @@ pub fn set_x<SM: PioStateMachine>(sm: &mut SM, value: u32) { | |||
| 12 | sm.exec_instr(OUT); | 12 | sm.exec_instr(OUT); |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | pub fn get_x<SM: PioStateMachine>(sm: &mut SM) -> u32 { | 15 | pub fn get_x<SM: PioStateMachineInstance>(sm: &mut SM) -> u32 { |
| 16 | const IN: u16 = InstructionOperands::IN { | 16 | const IN: u16 = InstructionOperands::IN { |
| 17 | source: InSource::X, | 17 | source: InSource::X, |
| 18 | bit_count: 32, | 18 | bit_count: 32, |
| @@ -22,7 +22,7 @@ pub fn get_x<SM: PioStateMachine>(sm: &mut SM) -> u32 { | |||
| 22 | sm.pull_rx() | 22 | sm.pull_rx() |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | pub fn set_y<SM: PioStateMachine>(sm: &mut SM, value: u32) { | 25 | pub fn set_y<SM: PioStateMachineInstance>(sm: &mut SM, value: u32) { |
| 26 | const OUT: u16 = InstructionOperands::OUT { | 26 | const OUT: u16 = InstructionOperands::OUT { |
| 27 | destination: OutDestination::Y, | 27 | destination: OutDestination::Y, |
| 28 | bit_count: 32, | 28 | bit_count: 32, |
| @@ -32,7 +32,7 @@ pub fn set_y<SM: PioStateMachine>(sm: &mut SM, value: u32) { | |||
| 32 | sm.exec_instr(OUT); | 32 | sm.exec_instr(OUT); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | pub fn get_y<SM: PioStateMachine>(sm: &mut SM) -> u32 { | 35 | pub fn get_y<SM: PioStateMachineInstance>(sm: &mut SM) -> u32 { |
| 36 | const IN: u16 = InstructionOperands::IN { | 36 | const IN: u16 = InstructionOperands::IN { |
| 37 | source: InSource::Y, | 37 | source: InSource::Y, |
| 38 | bit_count: 32, | 38 | bit_count: 32, |
| @@ -43,7 +43,7 @@ pub fn get_y<SM: PioStateMachine>(sm: &mut SM) -> u32 { | |||
| 43 | sm.pull_rx() | 43 | sm.pull_rx() |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | pub fn set_pindir<SM: PioStateMachine>(sm: &mut SM, data: u8) { | 46 | pub fn set_pindir<SM: PioStateMachineInstance>(sm: &mut SM, data: u8) { |
| 47 | let set: u16 = InstructionOperands::SET { | 47 | let set: u16 = InstructionOperands::SET { |
| 48 | destination: SetDestination::PINDIRS, | 48 | destination: SetDestination::PINDIRS, |
| 49 | data, | 49 | data, |
| @@ -52,7 +52,7 @@ pub fn set_pindir<SM: PioStateMachine>(sm: &mut SM, data: u8) { | |||
| 52 | sm.exec_instr(set); | 52 | sm.exec_instr(set); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | pub fn set_pin<SM: PioStateMachine>(sm: &mut SM, data: u8) { | 55 | pub fn set_pin<SM: PioStateMachineInstance>(sm: &mut SM, data: u8) { |
| 56 | let set: u16 = InstructionOperands::SET { | 56 | let set: u16 = InstructionOperands::SET { |
| 57 | destination: SetDestination::PINS, | 57 | destination: SetDestination::PINS, |
| 58 | data, | 58 | data, |
| @@ -61,7 +61,7 @@ pub fn set_pin<SM: PioStateMachine>(sm: &mut SM, data: u8) { | |||
| 61 | sm.exec_instr(set); | 61 | sm.exec_instr(set); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | pub fn set_out_pin<SM: PioStateMachine>(sm: &mut SM, data: u32) { | 64 | pub fn set_out_pin<SM: PioStateMachineInstance>(sm: &mut SM, data: u32) { |
| 65 | const OUT: u16 = InstructionOperands::OUT { | 65 | const OUT: u16 = InstructionOperands::OUT { |
| 66 | destination: OutDestination::PINS, | 66 | destination: OutDestination::PINS, |
| 67 | bit_count: 32, | 67 | bit_count: 32, |
| @@ -70,7 +70,7 @@ pub fn set_out_pin<SM: PioStateMachine>(sm: &mut SM, data: u32) { | |||
| 70 | sm.push_tx(data); | 70 | sm.push_tx(data); |
| 71 | sm.exec_instr(OUT); | 71 | sm.exec_instr(OUT); |
| 72 | } | 72 | } |
| 73 | pub fn set_out_pindir<SM: PioStateMachine>(sm: &mut SM, data: u32) { | 73 | pub fn set_out_pindir<SM: PioStateMachineInstance>(sm: &mut SM, data: u32) { |
| 74 | const OUT: u16 = InstructionOperands::OUT { | 74 | const OUT: u16 = InstructionOperands::OUT { |
| 75 | destination: OutDestination::PINDIRS, | 75 | destination: OutDestination::PINDIRS, |
| 76 | bit_count: 32, | 76 | bit_count: 32, |
| @@ -80,7 +80,7 @@ pub fn set_out_pindir<SM: PioStateMachine>(sm: &mut SM, data: u32) { | |||
| 80 | sm.exec_instr(OUT); | 80 | sm.exec_instr(OUT); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | pub fn exec_jmp<SM: PioStateMachine>(sm: &mut SM, to_addr: u8) { | 83 | pub fn exec_jmp<SM: PioStateMachineInstance>(sm: &mut SM, to_addr: u8) { |
| 84 | let jmp: u16 = InstructionOperands::JMP { | 84 | let jmp: u16 = InstructionOperands::JMP { |
| 85 | address: to_addr, | 85 | address: to_addr, |
| 86 | condition: JmpCondition::Always, | 86 | condition: JmpCondition::Always, |
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs index 154cc6b65..8c02f9f16 100644 --- a/examples/rp/src/bin/pio_async.rs +++ b/examples/rp/src/bin/pio_async.rs | |||
| @@ -9,7 +9,7 @@ use embassy_rp::pio_instr_util; | |||
| 9 | use embassy_rp::relocate::RelocatedProgram; | 9 | use embassy_rp::relocate::RelocatedProgram; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn setup_pio_task_sm0(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, 0>, pin: impl PioPin) { | 12 | fn setup_pio_task_sm0(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachine<PIO0, 0>, pin: impl PioPin) { |
| 13 | // Setup sm0 | 13 | // Setup sm0 |
| 14 | 14 | ||
| 15 | // Send data serially to pin | 15 | // Send data serially to pin |
| @@ -37,7 +37,7 @@ fn setup_pio_task_sm0(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstanc | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | #[embassy_executor::task] | 39 | #[embassy_executor::task] |
| 40 | async fn pio_task_sm0(mut sm: PioStateMachineInstance<'static, PIO0, 0>) { | 40 | async fn pio_task_sm0(mut sm: PioStateMachine<'static, PIO0, 0>) { |
| 41 | sm.set_enable(true); | 41 | sm.set_enable(true); |
| 42 | 42 | ||
| 43 | let mut v = 0x0f0caffa; | 43 | let mut v = 0x0f0caffa; |
| @@ -48,7 +48,7 @@ async fn pio_task_sm0(mut sm: PioStateMachineInstance<'static, PIO0, 0>) { | |||
| 48 | } | 48 | } |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | fn setup_pio_task_sm1(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, 1>) { | 51 | fn setup_pio_task_sm1(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachine<PIO0, 1>) { |
| 52 | // Setupm sm1 | 52 | // Setupm sm1 |
| 53 | 53 | ||
| 54 | // Read 0b10101 repeatedly until ISR is full | 54 | // Read 0b10101 repeatedly until ISR is full |
| @@ -67,7 +67,7 @@ fn setup_pio_task_sm1(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstanc | |||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | #[embassy_executor::task] | 69 | #[embassy_executor::task] |
| 70 | async fn pio_task_sm1(mut sm: PioStateMachineInstance<'static, PIO0, 1>) { | 70 | async fn pio_task_sm1(mut sm: PioStateMachine<'static, PIO0, 1>) { |
| 71 | sm.set_enable(true); | 71 | sm.set_enable(true); |
| 72 | loop { | 72 | loop { |
| 73 | let rx = sm.wait_pull().await; | 73 | let rx = sm.wait_pull().await; |
| @@ -75,7 +75,7 @@ async fn pio_task_sm1(mut sm: PioStateMachineInstance<'static, PIO0, 1>) { | |||
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | fn setup_pio_task_sm2(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, 2>) { | 78 | fn setup_pio_task_sm2(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachine<PIO0, 2>) { |
| 79 | // Setup sm2 | 79 | // Setup sm2 |
| 80 | 80 | ||
| 81 | // Repeatedly trigger IRQ 3 | 81 | // Repeatedly trigger IRQ 3 |
| @@ -99,7 +99,7 @@ fn setup_pio_task_sm2(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstanc | |||
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | #[embassy_executor::task] | 101 | #[embassy_executor::task] |
| 102 | async fn pio_task_sm2(mut sm: PioStateMachineInstance<'static, PIO0, 2>) { | 102 | async fn pio_task_sm2(mut sm: PioStateMachine<'static, PIO0, 2>) { |
| 103 | sm.set_enable(true); | 103 | sm.set_enable(true); |
| 104 | loop { | 104 | loop { |
| 105 | sm.wait_irq(3).await; | 105 | sm.wait_irq(3).await; |
diff --git a/examples/rp/src/bin/pio_dma.rs b/examples/rp/src/bin/pio_dma.rs index 0f1f6df12..a351e2c7c 100644 --- a/examples/rp/src/bin/pio_dma.rs +++ b/examples/rp/src/bin/pio_dma.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_rp::pio::{Pio, PioStateMachine, ShiftDirection}; | 7 | use embassy_rp::pio::{Pio, PioStateMachineInstance, ShiftDirection}; |
| 8 | use embassy_rp::relocate::RelocatedProgram; | 8 | use embassy_rp::relocate::RelocatedProgram; |
| 9 | use embassy_rp::{pio_instr_util, Peripheral}; | 9 | use embassy_rp::{pio_instr_util, Peripheral}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/rp/src/bin/pio_hd44780.rs b/examples/rp/src/bin/pio_hd44780.rs index 6d56bc233..249711a32 100644 --- a/examples/rp/src/bin/pio_hd44780.rs +++ b/examples/rp/src/bin/pio_hd44780.rs | |||
| @@ -64,7 +64,7 @@ async fn main(_spawner: Spawner) { | |||
| 64 | 64 | ||
| 65 | pub struct HD44780<'l> { | 65 | pub struct HD44780<'l> { |
| 66 | dma: PeripheralRef<'l, AnyChannel>, | 66 | dma: PeripheralRef<'l, AnyChannel>, |
| 67 | sm: PioStateMachineInstance<'l, PIO0, 0>, | 67 | sm: PioStateMachine<'l, PIO0, 0>, |
| 68 | 68 | ||
| 69 | buf: [u8; 40], | 69 | buf: [u8; 40], |
| 70 | } | 70 | } |
diff --git a/examples/rp/src/bin/ws2812-pio.rs b/examples/rp/src/bin/ws2812-pio.rs index 8276fad64..c141560e5 100644 --- a/examples/rp/src/bin/ws2812-pio.rs +++ b/examples/rp/src/bin/ws2812-pio.rs | |||
| @@ -13,11 +13,11 @@ use embassy_time::{Duration, Timer}; | |||
| 13 | use smart_leds::RGB8; | 13 | use smart_leds::RGB8; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | pub struct Ws2812<'d, P: PioInstance, const S: usize> { | 15 | pub struct Ws2812<'d, P: PioInstance, const S: usize> { |
| 16 | sm: PioStateMachineInstance<'d, P, S>, | 16 | sm: PioStateMachine<'d, P, S>, |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | impl<'d, P: PioInstance, const S: usize> Ws2812<'d, P, S> { | 19 | impl<'d, P: PioInstance, const S: usize> Ws2812<'d, P, S> { |
| 20 | pub fn new(mut pio: PioCommon<'d, P>, mut sm: PioStateMachineInstance<'d, P, S>, pin: impl PioPin) -> Self { | 20 | pub fn new(mut pio: PioCommon<'d, P>, mut sm: PioStateMachine<'d, P, S>, pin: impl PioPin) -> Self { |
| 21 | // Setup sm0 | 21 | // Setup sm0 |
| 22 | 22 | ||
| 23 | // prepare the PIO program | 23 | // prepare the PIO program |
