aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-05-02 17:55:40 +0200
committerpennae <[email protected]>2023-05-02 18:01:18 +0200
commit7a36072a15b2164a903ae3f36ee251eaf311216d (patch)
tree7b301f16b9ec2e46e103b16af3c093c772c78d93 /examples
parenta167c77d3928e1304ccccec6ddf7572d1e3c4cd9 (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.rs14
-rw-r--r--examples/rp/src/bin/pio_hd44780.rs4
-rw-r--r--examples/rp/src/bin/ws2812-pio.rs6
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;
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::peripherals::PIO0;
8use embassy_rp::pio::{Pio, PioCommon, PioStateMachine, PioStateMachineInstance, ShiftDirection, Sm0, Sm1, Sm2}; 8use embassy_rp::pio::{Pio, PioCommon, PioStateMachine, PioStateMachineInstance, ShiftDirection};
9use embassy_rp::pio_instr_util; 9use embassy_rp::pio_instr_util;
10use embassy_rp::relocate::RelocatedProgram; 10use embassy_rp::relocate::RelocatedProgram;
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13fn setup_pio_task_sm0(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm0>, pin: AnyPin) { 13fn 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]
41async fn pio_task_sm0(mut sm: PioStateMachineInstance<'static, PIO0, Sm0>) { 41async 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
52fn setup_pio_task_sm1(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm1>) { 52fn 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]
71async fn pio_task_sm1(mut sm: PioStateMachineInstance<'static, PIO0, Sm1>) { 71async 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
79fn setup_pio_task_sm2(pio: &mut PioCommon<PIO0>, sm: &mut PioStateMachineInstance<PIO0, Sm2>) { 79fn 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]
103async fn pio_task_sm2(mut sm: PioStateMachineInstance<'static, PIO0, Sm2>) { 103async 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;
8use embassy_rp::dma::{AnyChannel, Channel}; 8use 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::{FifoJoin, Pio, PioStateMachine, PioStateMachineInstance, ShiftDirection, SmInstanceBase}; 11use embassy_rp::pio::{FifoJoin, Pio, PioStateMachine, PioStateMachineInstance, ShiftDirection};
12use embassy_rp::pwm::{Config, Pwm}; 12use embassy_rp::pwm::{Config, Pwm};
13use embassy_rp::relocate::RelocatedProgram; 13use embassy_rp::relocate::RelocatedProgram;
14use embassy_rp::{into_ref, Peripheral, PeripheralRef}; 14use embassy_rp::{into_ref, Peripheral, PeripheralRef};
@@ -65,7 +65,7 @@ async fn main(_spawner: Spawner) {
65 65
66pub struct HD44780<'l> { 66pub 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::*;
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, Pio, PioCommon, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection, SmInstance, 9 FifoJoin, Pio, PioCommon, PioInstance, PioStateMachine, PioStateMachineInstance, ShiftDirection,
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 embassy_time::{Duration, Timer}; 13use embassy_time::{Duration, Timer};
14use smart_leds::RGB8; 14use smart_leds::RGB8;
15use {defmt_rtt as _, panic_probe as _}; 15use {defmt_rtt as _, panic_probe as _};
16pub struct Ws2812<'d, P: PioInstance, S: SmInstance> { 16pub struct Ws2812<'d, P: PioInstance, const S: usize> {
17 sm: PioStateMachineInstance<'d, P, S>, 17 sm: PioStateMachineInstance<'d, P, S>,
18} 18}
19 19
20impl<'d, P: PioInstance, S: SmInstance> Ws2812<'d, P, S> { 20impl<'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