diff options
| author | pennae <[email protected]> | 2023-05-02 17:55:40 +0200 |
|---|---|---|
| committer | pennae <[email protected]> | 2023-05-02 18:01:18 +0200 |
| commit | 7a36072a15b2164a903ae3f36ee251eaf311216d (patch) | |
| tree | 7b301f16b9ec2e46e103b16af3c093c772c78d93 /examples | |
| parent | a167c77d3928e1304ccccec6ddf7572d1e3c4cd9 (diff) | |
rp/pio: drop SmInstance{,Base}
these are just overly convoluted ways of writing down numbers.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp/src/bin/pio_async.rs | 14 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_hd44780.rs | 4 | ||||
| -rw-r--r-- | examples/rp/src/bin/ws2812-pio.rs | 6 |
3 files changed, 12 insertions, 12 deletions
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs index 50b001b69..5fea7034b 100644 --- a/examples/rp/src/bin/pio_async.rs +++ b/examples/rp/src/bin/pio_async.rs | |||
| @@ -5,12 +5,12 @@ use defmt::info; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_rp::gpio::{AnyPin, Pin}; | 6 | use embassy_rp::gpio::{AnyPin, Pin}; |
| 7 | use embassy_rp::peripherals::PIO0; | 7 | use embassy_rp::peripherals::PIO0; |
| 8 | use embassy_rp::pio::{Pio, PioCommon, PioStateMachine, PioStateMachineInstance, ShiftDirection, Sm0, Sm1, Sm2}; | 8 | use embassy_rp::pio::{Pio, PioCommon, PioStateMachine, PioStateMachineInstance, ShiftDirection}; |
| 9 | use embassy_rp::pio_instr_util; | 9 | use embassy_rp::pio_instr_util; |
| 10 | use embassy_rp::relocate::RelocatedProgram; | 10 | use embassy_rp::relocate::RelocatedProgram; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | fn setup_pio_task_sm0(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm0>, pin: AnyPin) { | 13 | fn setup_pio_task_sm0(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, 0>, pin: AnyPin) { |
| 14 | // Setup sm0 | 14 | // Setup sm0 |
| 15 | 15 | ||
| 16 | // Send data serially to pin | 16 | // Send data serially to pin |
| @@ -38,7 +38,7 @@ fn setup_pio_task_sm0(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstanc | |||
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | #[embassy_executor::task] | 40 | #[embassy_executor::task] |
| 41 | async fn pio_task_sm0(mut sm: PioStateMachineInstance<'static, PIO0, Sm0>) { | 41 | async fn pio_task_sm0(mut sm: PioStateMachineInstance<'static, PIO0, 0>) { |
| 42 | sm.set_enable(true); | 42 | sm.set_enable(true); |
| 43 | 43 | ||
| 44 | let mut v = 0x0f0caffa; | 44 | let mut v = 0x0f0caffa; |
| @@ -49,7 +49,7 @@ async fn pio_task_sm0(mut sm: PioStateMachineInstance<'static, PIO0, Sm0>) { | |||
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | fn setup_pio_task_sm1(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm1>) { | 52 | fn setup_pio_task_sm1(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, 1>) { |
| 53 | // Setupm sm1 | 53 | // Setupm sm1 |
| 54 | 54 | ||
| 55 | // Read 0b10101 repeatedly until ISR is full | 55 | // Read 0b10101 repeatedly until ISR is full |
| @@ -68,7 +68,7 @@ fn setup_pio_task_sm1(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstanc | |||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | #[embassy_executor::task] | 70 | #[embassy_executor::task] |
| 71 | async fn pio_task_sm1(mut sm: PioStateMachineInstance<'static, PIO0, Sm1>) { | 71 | async fn pio_task_sm1(mut sm: PioStateMachineInstance<'static, PIO0, 1>) { |
| 72 | sm.set_enable(true); | 72 | sm.set_enable(true); |
| 73 | loop { | 73 | loop { |
| 74 | let rx = sm.wait_pull().await; | 74 | let rx = sm.wait_pull().await; |
| @@ -76,7 +76,7 @@ async fn pio_task_sm1(mut sm: PioStateMachineInstance<'static, PIO0, Sm1>) { | |||
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | fn setup_pio_task_sm2(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm2>) { | 79 | fn setup_pio_task_sm2(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, 2>) { |
| 80 | // Setup sm2 | 80 | // Setup sm2 |
| 81 | 81 | ||
| 82 | // Repeatedly trigger IRQ 3 | 82 | // Repeatedly trigger IRQ 3 |
| @@ -100,7 +100,7 @@ fn setup_pio_task_sm2(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstanc | |||
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | #[embassy_executor::task] | 102 | #[embassy_executor::task] |
| 103 | async fn pio_task_sm2(mut sm: PioStateMachineInstance<'static, PIO0, Sm2>) { | 103 | async fn pio_task_sm2(mut sm: PioStateMachineInstance<'static, PIO0, 2>) { |
| 104 | sm.set_enable(true); | 104 | sm.set_enable(true); |
| 105 | loop { | 105 | loop { |
| 106 | sm.wait_irq(3).await; | 106 | sm.wait_irq(3).await; |
diff --git a/examples/rp/src/bin/pio_hd44780.rs b/examples/rp/src/bin/pio_hd44780.rs index 20c6a0565..59b4c1f52 100644 --- a/examples/rp/src/bin/pio_hd44780.rs +++ b/examples/rp/src/bin/pio_hd44780.rs | |||
| @@ -8,7 +8,7 @@ use embassy_executor::Spawner; | |||
| 8 | use embassy_rp::dma::{AnyChannel, Channel}; | 8 | use embassy_rp::dma::{AnyChannel, Channel}; |
| 9 | use embassy_rp::gpio::Pin; | 9 | use embassy_rp::gpio::Pin; |
| 10 | use embassy_rp::peripherals::PIO0; | 10 | use embassy_rp::peripherals::PIO0; |
| 11 | use embassy_rp::pio::{FifoJoin, Pio, PioStateMachine, PioStateMachineInstance, ShiftDirection, SmInstanceBase}; | 11 | use embassy_rp::pio::{FifoJoin, Pio, PioStateMachine, PioStateMachineInstance, ShiftDirection}; |
| 12 | use embassy_rp::pwm::{Config, Pwm}; | 12 | use embassy_rp::pwm::{Config, Pwm}; |
| 13 | use embassy_rp::relocate::RelocatedProgram; | 13 | use embassy_rp::relocate::RelocatedProgram; |
| 14 | use embassy_rp::{into_ref, Peripheral, PeripheralRef}; | 14 | use embassy_rp::{into_ref, Peripheral, PeripheralRef}; |
| @@ -65,7 +65,7 @@ async fn main(_spawner: Spawner) { | |||
| 65 | 65 | ||
| 66 | pub struct HD44780<'l> { | 66 | pub struct HD44780<'l> { |
| 67 | dma: PeripheralRef<'l, AnyChannel>, | 67 | dma: PeripheralRef<'l, AnyChannel>, |
| 68 | sm: PioStateMachineInstance<'l, PIO0, SmInstanceBase<0>>, | 68 | sm: PioStateMachineInstance<'l, PIO0, 0>, |
| 69 | 69 | ||
| 70 | buf: [u8; 40], | 70 | buf: [u8; 40], |
| 71 | } | 71 | } |
diff --git a/examples/rp/src/bin/ws2812-pio.rs b/examples/rp/src/bin/ws2812-pio.rs index a2121df42..0975559d7 100644 --- a/examples/rp/src/bin/ws2812-pio.rs +++ b/examples/rp/src/bin/ws2812-pio.rs | |||
| @@ -6,18 +6,18 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::gpio::{self, Pin}; | 7 | use embassy_rp::gpio::{self, Pin}; |
| 8 | use embassy_rp::pio::{ | 8 | use embassy_rp::pio::{ |
| 9 | FifoJoin, Pio, PioCommon, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection, SmInstance, | 9 | FifoJoin, Pio, PioCommon, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection, |
| 10 | }; | 10 | }; |
| 11 | use embassy_rp::pio_instr_util; | 11 | use embassy_rp::pio_instr_util; |
| 12 | use embassy_rp::relocate::RelocatedProgram; | 12 | use embassy_rp::relocate::RelocatedProgram; |
| 13 | use embassy_time::{Duration, Timer}; | 13 | use embassy_time::{Duration, Timer}; |
| 14 | use smart_leds::RGB8; | 14 | use smart_leds::RGB8; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | pub struct Ws2812<'d, P: PioInstance, S: SmInstance> { | 16 | pub struct Ws2812<'d, P: PioInstance, const S: usize> { |
| 17 | sm: PioStateMachineInstance<'d, P, S>, | 17 | sm: PioStateMachineInstance<'d, P, S>, |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | impl<'d, P: PioInstance, S: SmInstance> Ws2812<'d, P, S> { | 20 | impl<'d, P: PioInstance, const S: usize> Ws2812<'d, P, S> { |
| 21 | pub fn new(mut pio: PioCommon<'d, P>, mut sm: PioStateMachineInstance<'d, P, S>, pin: gpio::AnyPin) -> Self { | 21 | pub fn new(mut pio: PioCommon<'d, P>, mut sm: PioStateMachineInstance<'d, P, S>, pin: gpio::AnyPin) -> Self { |
| 22 | // Setup sm0 | 22 | // Setup sm0 |
| 23 | 23 | ||
