diff options
| author | pennae <[email protected]> | 2023-04-26 20:27:31 +0200 |
|---|---|---|
| committer | pennae <[email protected]> | 2023-05-02 18:01:18 +0200 |
| commit | a167c77d3928e1304ccccec6ddf7572d1e3c4cd9 (patch) | |
| tree | ec8a96813449bd4d0c0de22eb625bce661a39106 /examples | |
| parent | 8839f3f62ab85a1abd066fcbfa15693965e6fae8 (diff) | |
rp/pio: make PioCommon a struct
the PioCommon trait does not serve much of a purpose; there can be only
two implementations and they only differ in a few associated constants.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp/src/bin/pio_async.rs | 10 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_dma.rs | 2 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_hd44780.rs | 4 | ||||
| -rw-r--r-- | examples/rp/src/bin/ws2812-pio.rs | 9 |
4 files changed, 8 insertions, 17 deletions
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs index 69a22f238..50b001b69 100644 --- a/examples/rp/src/bin/pio_async.rs +++ b/examples/rp/src/bin/pio_async.rs | |||
| @@ -5,14 +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::{ | 8 | use embassy_rp::pio::{Pio, PioCommon, PioStateMachine, PioStateMachineInstance, ShiftDirection, Sm0, Sm1, Sm2}; |
| 9 | Pio, PioCommon, PioCommonInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection, Sm0, Sm1, Sm2, | ||
| 10 | }; | ||
| 11 | use embassy_rp::pio_instr_util; | 9 | use embassy_rp::pio_instr_util; |
| 12 | use embassy_rp::relocate::RelocatedProgram; | 10 | use embassy_rp::relocate::RelocatedProgram; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 12 | ||
| 15 | fn setup_pio_task_sm0(pio: &mut PioCommonInstance<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm0>, pin: AnyPin) { | 13 | fn setup_pio_task_sm0(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm0>, pin: AnyPin) { |
| 16 | // Setup sm0 | 14 | // Setup sm0 |
| 17 | 15 | ||
| 18 | // Send data serially to pin | 16 | // Send data serially to pin |
| @@ -51,7 +49,7 @@ async fn pio_task_sm0(mut sm: PioStateMachineInstance<'static, PIO0, Sm0>) { | |||
| 51 | } | 49 | } |
| 52 | } | 50 | } |
| 53 | 51 | ||
| 54 | fn setup_pio_task_sm1(pio: &mut PioCommonInstance<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm1>) { | 52 | fn setup_pio_task_sm1(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm1>) { |
| 55 | // Setupm sm1 | 53 | // Setupm sm1 |
| 56 | 54 | ||
| 57 | // Read 0b10101 repeatedly until ISR is full | 55 | // Read 0b10101 repeatedly until ISR is full |
| @@ -78,7 +76,7 @@ async fn pio_task_sm1(mut sm: PioStateMachineInstance<'static, PIO0, Sm1>) { | |||
| 78 | } | 76 | } |
| 79 | } | 77 | } |
| 80 | 78 | ||
| 81 | fn setup_pio_task_sm2(pio: &mut PioCommonInstance<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm2>) { | 79 | fn setup_pio_task_sm2(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm2>) { |
| 82 | // Setup sm2 | 80 | // Setup sm2 |
| 83 | 81 | ||
| 84 | // Repeatedly trigger IRQ 3 | 82 | // Repeatedly trigger IRQ 3 |
diff --git a/examples/rp/src/bin/pio_dma.rs b/examples/rp/src/bin/pio_dma.rs index 33c320b8f..0f1f6df12 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, PioCommon, PioStateMachine, ShiftDirection}; | 7 | use embassy_rp::pio::{Pio, PioStateMachine, 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 994d4600a..20c6a0565 100644 --- a/examples/rp/src/bin/pio_hd44780.rs +++ b/examples/rp/src/bin/pio_hd44780.rs | |||
| @@ -8,9 +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::{ | 11 | use embassy_rp::pio::{FifoJoin, Pio, PioStateMachine, PioStateMachineInstance, ShiftDirection, SmInstanceBase}; |
| 12 | FifoJoin, Pio, PioCommon, PioStateMachine, PioStateMachineInstance, ShiftDirection, SmInstanceBase, | ||
| 13 | }; | ||
| 14 | use embassy_rp::pwm::{Config, Pwm}; | 12 | use embassy_rp::pwm::{Config, Pwm}; |
| 15 | use embassy_rp::relocate::RelocatedProgram; | 13 | use embassy_rp::relocate::RelocatedProgram; |
| 16 | use embassy_rp::{into_ref, Peripheral, PeripheralRef}; | 14 | use embassy_rp::{into_ref, Peripheral, PeripheralRef}; |
diff --git a/examples/rp/src/bin/ws2812-pio.rs b/examples/rp/src/bin/ws2812-pio.rs index 42c731bd7..a2121df42 100644 --- a/examples/rp/src/bin/ws2812-pio.rs +++ b/examples/rp/src/bin/ws2812-pio.rs | |||
| @@ -6,8 +6,7 @@ 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, PioCommonInstance, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection, | 9 | FifoJoin, Pio, PioCommon, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection, SmInstance, |
| 10 | SmInstance, | ||
| 11 | }; | 10 | }; |
| 12 | use embassy_rp::pio_instr_util; | 11 | use embassy_rp::pio_instr_util; |
| 13 | use embassy_rp::relocate::RelocatedProgram; | 12 | use embassy_rp::relocate::RelocatedProgram; |
| @@ -19,11 +18,7 @@ pub struct Ws2812<'d, P: PioInstance, S: SmInstance> { | |||
| 19 | } | 18 | } |
| 20 | 19 | ||
| 21 | impl<'d, P: PioInstance, S: SmInstance> Ws2812<'d, P, S> { | 20 | impl<'d, P: PioInstance, S: SmInstance> Ws2812<'d, P, S> { |
| 22 | pub fn new( | 21 | pub fn new(mut pio: PioCommon<'d, P>, mut sm: PioStateMachineInstance<'d, P, S>, pin: gpio::AnyPin) -> Self { |
| 23 | mut pio: PioCommonInstance<'d, P>, | ||
| 24 | mut sm: PioStateMachineInstance<'d, P, S>, | ||
| 25 | pin: gpio::AnyPin, | ||
| 26 | ) -> Self { | ||
| 27 | // Setup sm0 | 22 | // Setup sm0 |
| 28 | 23 | ||
| 29 | // prepare the PIO program | 24 | // prepare the PIO program |
