aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-04-26 00:23:18 +0200
committerpennae <[email protected]>2023-05-02 15:46:21 +0200
commit3229b5e809688d99a592bbfd1f803e1fb9d62050 (patch)
tree109587dc1ef7246c2aeea8dee6875abe17c322e3 /examples
parent6cec6fa09b3bcc01ada4d5d5decd02cc2a3a8e4f (diff)
rp/pio: remove PioPeripheral
merge into PioInstance instead. PioPeripheral was mostly a wrapper around PioInstance anyway, and the way the wrapping was done required PioInstanceBase<N> types where PIO{N} could've been used instead.
Diffstat (limited to 'examples')
-rw-r--r--examples/rp/src/bin/pio_async.rs16
-rw-r--r--examples/rp/src/bin/pio_dma.rs2
-rw-r--r--examples/rp/src/bin/pio_hd44780.rs5
-rw-r--r--examples/rp/src/bin/ws2812-pio.rs4
4 files changed, 13 insertions, 14 deletions
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs
index 1b075b8fd..16a09327f 100644
--- a/examples/rp/src/bin/pio_async.rs
+++ b/examples/rp/src/bin/pio_async.rs
@@ -4,15 +4,15 @@
4use defmt::info; 4use defmt::info;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_rp::gpio::{AnyPin, Pin}; 6use embassy_rp::gpio::{AnyPin, Pin};
7use embassy_rp::peripherals::PIO0;
7use embassy_rp::pio::{ 8use embassy_rp::pio::{
8 Pio0, PioCommon, PioCommonInstance, PioPeripheral, PioStateMachine, PioStateMachineInstance, ShiftDirection, Sm0, 9 PioCommon, PioCommonInstance, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection, Sm0, Sm1, Sm2,
9 Sm1, Sm2,
10}; 10};
11use embassy_rp::pio_instr_util; 11use embassy_rp::pio_instr_util;
12use embassy_rp::relocate::RelocatedProgram; 12use embassy_rp::relocate::RelocatedProgram;
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
14 14
15fn setup_pio_task_sm0(pio: &mut PioCommonInstance<Pio0>, sm: &mut PioStateMachineInstance<Pio0, Sm0>, pin: AnyPin) { 15fn setup_pio_task_sm0(pio: &mut PioCommonInstance<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm0>, pin: AnyPin) {
16 // Setup sm0 16 // Setup sm0
17 17
18 // Send data serially to pin 18 // Send data serially to pin
@@ -40,7 +40,7 @@ fn setup_pio_task_sm0(pio: &mut PioCommonInstance<Pio0>, sm: &mut PioStateMachin
40} 40}
41 41
42#[embassy_executor::task] 42#[embassy_executor::task]
43async fn pio_task_sm0(mut sm: PioStateMachineInstance<Pio0, Sm0>) { 43async fn pio_task_sm0(mut sm: PioStateMachineInstance<PIO0, Sm0>) {
44 sm.set_enable(true); 44 sm.set_enable(true);
45 45
46 let mut v = 0x0f0caffa; 46 let mut v = 0x0f0caffa;
@@ -51,7 +51,7 @@ async fn pio_task_sm0(mut sm: PioStateMachineInstance<Pio0, Sm0>) {
51 } 51 }
52} 52}
53 53
54fn setup_pio_task_sm1(pio: &mut PioCommonInstance<Pio0>, sm: &mut PioStateMachineInstance<Pio0, Sm1>) { 54fn setup_pio_task_sm1(pio: &mut PioCommonInstance<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm1>) {
55 // Setupm sm1 55 // Setupm sm1
56 56
57 // Read 0b10101 repeatedly until ISR is full 57 // Read 0b10101 repeatedly until ISR is full
@@ -70,7 +70,7 @@ fn setup_pio_task_sm1(pio: &mut PioCommonInstance<Pio0>, sm: &mut PioStateMachin
70} 70}
71 71
72#[embassy_executor::task] 72#[embassy_executor::task]
73async fn pio_task_sm1(mut sm: PioStateMachineInstance<Pio0, Sm1>) { 73async fn pio_task_sm1(mut sm: PioStateMachineInstance<PIO0, Sm1>) {
74 sm.set_enable(true); 74 sm.set_enable(true);
75 loop { 75 loop {
76 let rx = sm.wait_pull().await; 76 let rx = sm.wait_pull().await;
@@ -78,7 +78,7 @@ async fn pio_task_sm1(mut sm: PioStateMachineInstance<Pio0, Sm1>) {
78 } 78 }
79} 79}
80 80
81fn setup_pio_task_sm2(pio: &mut PioCommonInstance<Pio0>, sm: &mut PioStateMachineInstance<Pio0, Sm2>) { 81fn setup_pio_task_sm2(pio: &mut PioCommonInstance<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm2>) {
82 // Setup sm2 82 // Setup sm2
83 83
84 // Repeatedly trigger IRQ 3 84 // Repeatedly trigger IRQ 3
@@ -102,7 +102,7 @@ fn setup_pio_task_sm2(pio: &mut PioCommonInstance<Pio0>, sm: &mut PioStateMachin
102} 102}
103 103
104#[embassy_executor::task] 104#[embassy_executor::task]
105async fn pio_task_sm2(mut sm: PioStateMachineInstance<Pio0, Sm2>) { 105async fn pio_task_sm2(mut sm: PioStateMachineInstance<PIO0, Sm2>) {
106 sm.set_enable(true); 106 sm.set_enable(true);
107 loop { 107 loop {
108 sm.wait_irq(3).await; 108 sm.wait_irq(3).await;
diff --git a/examples/rp/src/bin/pio_dma.rs b/examples/rp/src/bin/pio_dma.rs
index 7d4919f75..ccbc70fe2 100644
--- a/examples/rp/src/bin/pio_dma.rs
+++ b/examples/rp/src/bin/pio_dma.rs
@@ -4,7 +4,7 @@
4use defmt::info; 4use defmt::info;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_futures::join::join; 6use embassy_futures::join::join;
7use embassy_rp::pio::{PioCommon, PioPeripheral, PioStateMachine, ShiftDirection}; 7use embassy_rp::pio::{PioCommon, PioInstance, PioStateMachine, ShiftDirection};
8use embassy_rp::relocate::RelocatedProgram; 8use embassy_rp::relocate::RelocatedProgram;
9use embassy_rp::{pio_instr_util, Peripheral}; 9use embassy_rp::{pio_instr_util, Peripheral};
10use {defmt_rtt as _, panic_probe as _}; 10use {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 6bcd0652b..1b24897b0 100644
--- a/examples/rp/src/bin/pio_hd44780.rs
+++ b/examples/rp/src/bin/pio_hd44780.rs
@@ -9,8 +9,7 @@ use embassy_rp::dma::{AnyChannel, Channel};
9use embassy_rp::gpio::Pin; 9use embassy_rp::gpio::Pin;
10use embassy_rp::peripherals::PIO0; 10use embassy_rp::peripherals::PIO0;
11use embassy_rp::pio::{ 11use embassy_rp::pio::{
12 FifoJoin, PioCommon, PioInstanceBase, PioPeripheral, PioStateMachine, PioStateMachineInstance, ShiftDirection, 12 FifoJoin, PioCommon, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection, SmInstanceBase,
13 SmInstanceBase,
14}; 13};
15use embassy_rp::pwm::{Config, Pwm}; 14use embassy_rp::pwm::{Config, Pwm};
16use embassy_rp::relocate::RelocatedProgram; 15use embassy_rp::relocate::RelocatedProgram;
@@ -68,7 +67,7 @@ async fn main(_spawner: Spawner) {
68 67
69pub struct HD44780<'l> { 68pub struct HD44780<'l> {
70 dma: PeripheralRef<'l, AnyChannel>, 69 dma: PeripheralRef<'l, AnyChannel>,
71 sm: PioStateMachineInstance<PioInstanceBase<0>, SmInstanceBase<0>>, 70 sm: PioStateMachineInstance<PIO0, SmInstanceBase<0>>,
72 71
73 buf: [u8; 40], 72 buf: [u8; 40],
74} 73}
diff --git a/examples/rp/src/bin/ws2812-pio.rs b/examples/rp/src/bin/ws2812-pio.rs
index 041e8ae11..592caf244 100644
--- a/examples/rp/src/bin/ws2812-pio.rs
+++ b/examples/rp/src/bin/ws2812-pio.rs
@@ -6,8 +6,8 @@ use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_rp::gpio::{self, Pin}; 7use embassy_rp::gpio::{self, Pin};
8use embassy_rp::pio::{ 8use embassy_rp::pio::{
9 FifoJoin, PioCommon, PioCommonInstance, PioInstance, PioPeripheral, PioStateMachine, PioStateMachineInstance, 9 FifoJoin, PioCommon, PioCommonInstance, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection,
10 ShiftDirection, SmInstance, 10 SmInstance,
11}; 11};
12use embassy_rp::pio_instr_util; 12use embassy_rp::pio_instr_util;
13use embassy_rp::relocate::RelocatedProgram; 13use embassy_rp::relocate::RelocatedProgram;