aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src/pio_programs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-rp/src/pio_programs
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-rp/src/pio_programs')
-rw-r--r--embassy-rp/src/pio_programs/hd44780.rs24
-rw-r--r--embassy-rp/src/pio_programs/i2s.rs39
-rw-r--r--embassy-rp/src/pio_programs/onewire.rs3
-rw-r--r--embassy-rp/src/pio_programs/pwm.rs4
-rw-r--r--embassy-rp/src/pio_programs/rotary_encoder.rs5
-rw-r--r--embassy-rp/src/pio_programs/stepper.rs9
-rw-r--r--embassy-rp/src/pio_programs/uart.rs45
-rw-r--r--embassy-rp/src/pio_programs/ws2812.rs15
8 files changed, 68 insertions, 76 deletions
diff --git a/embassy-rp/src/pio_programs/hd44780.rs b/embassy-rp/src/pio_programs/hd44780.rs
index 6997b91f3..5846a8027 100644
--- a/embassy-rp/src/pio_programs/hd44780.rs
+++ b/embassy-rp/src/pio_programs/hd44780.rs
@@ -5,7 +5,7 @@ use crate::pio::{
5 Common, Config, Direction, FifoJoin, Instance, Irq, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, 5 Common, Config, Direction, FifoJoin, Instance, Irq, LoadedProgram, PioPin, ShiftConfig, ShiftDirection,
6 StateMachine, 6 StateMachine,
7}; 7};
8use crate::{into_ref, Peripheral, PeripheralRef}; 8use crate::Peri;
9 9
10/// This struct represents a HD44780 program that takes command words (<wait:24> <command:4> <0:4>) 10/// This struct represents a HD44780 program that takes command words (<wait:24> <command:4> <0:4>)
11pub struct PioHD44780CommandWordProgram<'a, PIO: Instance> { 11pub struct PioHD44780CommandWordProgram<'a, PIO: Instance> {
@@ -99,7 +99,7 @@ impl<'a, PIO: Instance> PioHD44780CommandSequenceProgram<'a, PIO> {
99 99
100/// Pio backed HD44780 driver 100/// Pio backed HD44780 driver
101pub struct PioHD44780<'l, P: Instance, const S: usize> { 101pub struct PioHD44780<'l, P: Instance, const S: usize> {
102 dma: PeripheralRef<'l, AnyChannel>, 102 dma: Peri<'l, AnyChannel>,
103 sm: StateMachine<'l, P, S>, 103 sm: StateMachine<'l, P, S>,
104 104
105 buf: [u8; 40], 105 buf: [u8; 40],
@@ -111,19 +111,17 @@ impl<'l, P: Instance, const S: usize> PioHD44780<'l, P, S> {
111 common: &mut Common<'l, P>, 111 common: &mut Common<'l, P>,
112 mut sm: StateMachine<'l, P, S>, 112 mut sm: StateMachine<'l, P, S>,
113 mut irq: Irq<'l, P, S>, 113 mut irq: Irq<'l, P, S>,
114 dma: impl Peripheral<P = impl Channel> + 'l, 114 mut dma: Peri<'l, impl Channel>,
115 rs: impl PioPin, 115 rs: Peri<'l, impl PioPin>,
116 rw: impl PioPin, 116 rw: Peri<'l, impl PioPin>,
117 e: impl PioPin, 117 e: Peri<'l, impl PioPin>,
118 db4: impl PioPin, 118 db4: Peri<'l, impl PioPin>,
119 db5: impl PioPin, 119 db5: Peri<'l, impl PioPin>,
120 db6: impl PioPin, 120 db6: Peri<'l, impl PioPin>,
121 db7: impl PioPin, 121 db7: Peri<'l, impl PioPin>,
122 word_prg: &PioHD44780CommandWordProgram<'l, P>, 122 word_prg: &PioHD44780CommandWordProgram<'l, P>,
123 seq_prg: &PioHD44780CommandSequenceProgram<'l, P>, 123 seq_prg: &PioHD44780CommandSequenceProgram<'l, P>,
124 ) -> PioHD44780<'l, P, S> { 124 ) -> PioHD44780<'l, P, S> {
125 into_ref!(dma);
126
127 let rs = common.make_pio_pin(rs); 125 let rs = common.make_pio_pin(rs);
128 let rw = common.make_pio_pin(rw); 126 let rw = common.make_pio_pin(rw);
129 let e = common.make_pio_pin(e); 127 let e = common.make_pio_pin(e);
@@ -176,7 +174,7 @@ impl<'l, P: Instance, const S: usize> PioHD44780<'l, P, S> {
176 sm.tx().dma_push(dma.reborrow(), &[0x81u8, 0x0f, 1], false).await; 174 sm.tx().dma_push(dma.reborrow(), &[0x81u8, 0x0f, 1], false).await;
177 175
178 Self { 176 Self {
179 dma: dma.map_into(), 177 dma: dma.into(),
180 sm, 178 sm,
181 buf: [0x20; 40], 179 buf: [0x20; 40],
182 } 180 }
diff --git a/embassy-rp/src/pio_programs/i2s.rs b/embassy-rp/src/pio_programs/i2s.rs
index 17e321405..b967f0160 100644
--- a/embassy-rp/src/pio_programs/i2s.rs
+++ b/embassy-rp/src/pio_programs/i2s.rs
@@ -6,16 +6,16 @@ use crate::dma::{AnyChannel, Channel, Transfer};
6use crate::pio::{ 6use crate::pio::{
7 Common, Config, Direction, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, 7 Common, Config, Direction, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine,
8}; 8};
9use crate::{into_ref, Peripheral, PeripheralRef}; 9use crate::Peri;
10 10
11/// This struct represents an i2s output driver program 11/// This struct represents an i2s output driver program
12pub struct PioI2sOutProgram<'a, PIO: Instance> { 12pub struct PioI2sOutProgram<'d, PIO: Instance> {
13 prg: LoadedProgram<'a, PIO>, 13 prg: LoadedProgram<'d, PIO>,
14} 14}
15 15
16impl<'a, PIO: Instance> PioI2sOutProgram<'a, PIO> { 16impl<'d, PIO: Instance> PioI2sOutProgram<'d, PIO> {
17 /// Load the program into the given pio 17 /// Load the program into the given pio
18 pub fn new(common: &mut Common<'a, PIO>) -> Self { 18 pub fn new(common: &mut Common<'d, PIO>) -> Self {
19 let prg = pio::pio_asm!( 19 let prg = pio::pio_asm!(
20 ".side_set 2", 20 ".side_set 2",
21 " set x, 14 side 0b01", // side 0bWB - W = Word Clock, B = Bit Clock 21 " set x, 14 side 0b01", // side 0bWB - W = Word Clock, B = Bit Clock
@@ -37,27 +37,25 @@ impl<'a, PIO: Instance> PioI2sOutProgram<'a, PIO> {
37} 37}
38 38
39/// Pio backed I2s output driver 39/// Pio backed I2s output driver
40pub struct PioI2sOut<'a, P: Instance, const S: usize> { 40pub struct PioI2sOut<'d, P: Instance, const S: usize> {
41 dma: PeripheralRef<'a, AnyChannel>, 41 dma: Peri<'d, AnyChannel>,
42 sm: StateMachine<'a, P, S>, 42 sm: StateMachine<'d, P, S>,
43} 43}
44 44
45impl<'a, P: Instance, const S: usize> PioI2sOut<'a, P, S> { 45impl<'d, P: Instance, const S: usize> PioI2sOut<'d, P, S> {
46 /// Configure a state machine to output I2s 46 /// Configure a state machine to output I2s
47 pub fn new( 47 pub fn new(
48 common: &mut Common<'a, P>, 48 common: &mut Common<'d, P>,
49 mut sm: StateMachine<'a, P, S>, 49 mut sm: StateMachine<'d, P, S>,
50 dma: impl Peripheral<P = impl Channel> + 'a, 50 dma: Peri<'d, impl Channel>,
51 data_pin: impl PioPin, 51 data_pin: Peri<'d, impl PioPin>,
52 bit_clock_pin: impl PioPin, 52 bit_clock_pin: Peri<'d, impl PioPin>,
53 lr_clock_pin: impl PioPin, 53 lr_clock_pin: Peri<'d, impl PioPin>,
54 sample_rate: u32, 54 sample_rate: u32,
55 bit_depth: u32, 55 bit_depth: u32,
56 channels: u32, 56 channels: u32,
57 program: &PioI2sOutProgram<'a, P>, 57 program: &PioI2sOutProgram<'d, P>,
58 ) -> Self { 58 ) -> Self {
59 into_ref!(dma);
60
61 let data_pin = common.make_pio_pin(data_pin); 59 let data_pin = common.make_pio_pin(data_pin);
62 let bit_clock_pin = common.make_pio_pin(bit_clock_pin); 60 let bit_clock_pin = common.make_pio_pin(bit_clock_pin);
63 let left_right_clock_pin = common.make_pio_pin(lr_clock_pin); 61 let left_right_clock_pin = common.make_pio_pin(lr_clock_pin);
@@ -82,10 +80,7 @@ impl<'a, P: Instance, const S: usize> PioI2sOut<'a, P, S> {
82 80
83 sm.set_enable(true); 81 sm.set_enable(true);
84 82
85 Self { 83 Self { dma: dma.into(), sm }
86 dma: dma.map_into(),
87 sm,
88 }
89 } 84 }
90 85
91 /// Return an in-prograss dma transfer future. Awaiting it will guarentee a complete transfer. 86 /// Return an in-prograss dma transfer future. Awaiting it will guarentee a complete transfer.
diff --git a/embassy-rp/src/pio_programs/onewire.rs b/embassy-rp/src/pio_programs/onewire.rs
index 040333e76..00783aab0 100644
--- a/embassy-rp/src/pio_programs/onewire.rs
+++ b/embassy-rp/src/pio_programs/onewire.rs
@@ -1,6 +1,7 @@
1//! OneWire pio driver 1//! OneWire pio driver
2 2
3use crate::pio::{Common, Config, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine}; 3use crate::pio::{Common, Config, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine};
4use crate::Peri;
4 5
5/// This struct represents an onewire driver program 6/// This struct represents an onewire driver program
6pub struct PioOneWireProgram<'a, PIO: Instance> { 7pub struct PioOneWireProgram<'a, PIO: Instance> {
@@ -69,7 +70,7 @@ impl<'d, PIO: Instance, const SM: usize> PioOneWire<'d, PIO, SM> {
69 pub fn new( 70 pub fn new(
70 common: &mut Common<'d, PIO>, 71 common: &mut Common<'d, PIO>,
71 mut sm: StateMachine<'d, PIO, SM>, 72 mut sm: StateMachine<'d, PIO, SM>,
72 pin: impl PioPin, 73 pin: Peri<'d, impl PioPin>,
73 program: &PioOneWireProgram<'d, PIO>, 74 program: &PioOneWireProgram<'d, PIO>,
74 ) -> Self { 75 ) -> Self {
75 let pin = common.make_pio_pin(pin); 76 let pin = common.make_pio_pin(pin);
diff --git a/embassy-rp/src/pio_programs/pwm.rs b/embassy-rp/src/pio_programs/pwm.rs
index 01ffe012a..f0f837bc5 100644
--- a/embassy-rp/src/pio_programs/pwm.rs
+++ b/embassy-rp/src/pio_programs/pwm.rs
@@ -4,9 +4,9 @@ use core::time::Duration;
4 4
5use pio::InstructionOperands; 5use pio::InstructionOperands;
6 6
7use crate::clocks;
8use crate::gpio::Level; 7use crate::gpio::Level;
9use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, Pin, PioPin, StateMachine}; 8use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, Pin, PioPin, StateMachine};
9use crate::{clocks, Peri};
10 10
11/// This converts the duration provided into the number of cycles the PIO needs to run to make it take the same time 11/// This converts the duration provided into the number of cycles the PIO needs to run to make it take the same time
12fn to_pio_cycles(duration: Duration) -> u32 { 12fn to_pio_cycles(duration: Duration) -> u32 {
@@ -52,7 +52,7 @@ impl<'d, T: Instance, const SM: usize> PioPwm<'d, T, SM> {
52 pub fn new( 52 pub fn new(
53 pio: &mut Common<'d, T>, 53 pio: &mut Common<'d, T>,
54 mut sm: StateMachine<'d, T, SM>, 54 mut sm: StateMachine<'d, T, SM>,
55 pin: impl PioPin, 55 pin: Peri<'d, impl PioPin>,
56 program: &PioPwmProgram<'d, T>, 56 program: &PioPwmProgram<'d, T>,
57 ) -> Self { 57 ) -> Self {
58 let pin = pio.make_pio_pin(pin); 58 let pin = pio.make_pio_pin(pin);
diff --git a/embassy-rp/src/pio_programs/rotary_encoder.rs b/embassy-rp/src/pio_programs/rotary_encoder.rs
index f2fb02aca..e520da8a3 100644
--- a/embassy-rp/src/pio_programs/rotary_encoder.rs
+++ b/embassy-rp/src/pio_programs/rotary_encoder.rs
@@ -6,6 +6,7 @@ use crate::gpio::Pull;
6use crate::pio::{ 6use crate::pio::{
7 Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, 7 Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine,
8}; 8};
9use crate::Peri;
9 10
10/// This struct represents an Encoder program loaded into pio instruction memory. 11/// This struct represents an Encoder program loaded into pio instruction memory.
11pub struct PioEncoderProgram<'a, PIO: Instance> { 12pub struct PioEncoderProgram<'a, PIO: Instance> {
@@ -33,8 +34,8 @@ impl<'d, T: Instance, const SM: usize> PioEncoder<'d, T, SM> {
33 pub fn new( 34 pub fn new(
34 pio: &mut Common<'d, T>, 35 pio: &mut Common<'d, T>,
35 mut sm: StateMachine<'d, T, SM>, 36 mut sm: StateMachine<'d, T, SM>,
36 pin_a: impl PioPin, 37 pin_a: Peri<'d, impl PioPin>,
37 pin_b: impl PioPin, 38 pin_b: Peri<'d, impl PioPin>,
38 program: &PioEncoderProgram<'d, T>, 39 program: &PioEncoderProgram<'d, T>,
39 ) -> Self { 40 ) -> Self {
40 let mut pin_a = pio.make_pio_pin(pin_a); 41 let mut pin_a = pio.make_pio_pin(pin_a);
diff --git a/embassy-rp/src/pio_programs/stepper.rs b/embassy-rp/src/pio_programs/stepper.rs
index c8f74167d..495191659 100644
--- a/embassy-rp/src/pio_programs/stepper.rs
+++ b/embassy-rp/src/pio_programs/stepper.rs
@@ -7,6 +7,7 @@ use fixed::types::extra::U8;
7use fixed::FixedU32; 7use fixed::FixedU32;
8 8
9use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine}; 9use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine};
10use crate::Peri;
10 11
11/// This struct represents a Stepper driver program loaded into pio instruction memory. 12/// This struct represents a Stepper driver program loaded into pio instruction memory.
12pub struct PioStepperProgram<'a, PIO: Instance> { 13pub struct PioStepperProgram<'a, PIO: Instance> {
@@ -50,10 +51,10 @@ impl<'d, T: Instance, const SM: usize> PioStepper<'d, T, SM> {
50 pio: &mut Common<'d, T>, 51 pio: &mut Common<'d, T>,
51 mut sm: StateMachine<'d, T, SM>, 52 mut sm: StateMachine<'d, T, SM>,
52 irq: Irq<'d, T, SM>, 53 irq: Irq<'d, T, SM>,
53 pin0: impl PioPin, 54 pin0: Peri<'d, impl PioPin>,
54 pin1: impl PioPin, 55 pin1: Peri<'d, impl PioPin>,
55 pin2: impl PioPin, 56 pin2: Peri<'d, impl PioPin>,
56 pin3: impl PioPin, 57 pin3: Peri<'d, impl PioPin>,
57 program: &PioStepperProgram<'d, T>, 58 program: &PioStepperProgram<'d, T>,
58 ) -> Self { 59 ) -> Self {
59 let pin0 = pio.make_pio_pin(pin0); 60 let pin0 = pio.make_pio_pin(pin0);
diff --git a/embassy-rp/src/pio_programs/uart.rs b/embassy-rp/src/pio_programs/uart.rs
index 641daca61..04e39a571 100644
--- a/embassy-rp/src/pio_programs/uart.rs
+++ b/embassy-rp/src/pio_programs/uart.rs
@@ -10,15 +10,16 @@ use crate::gpio::Level;
10use crate::pio::{ 10use crate::pio::{
11 Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, 11 Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine,
12}; 12};
13use crate::Peri;
13 14
14/// This struct represents a uart tx program loaded into pio instruction memory. 15/// This struct represents a uart tx program loaded into pio instruction memory.
15pub struct PioUartTxProgram<'a, PIO: Instance> { 16pub struct PioUartTxProgram<'d, PIO: Instance> {
16 prg: LoadedProgram<'a, PIO>, 17 prg: LoadedProgram<'d, PIO>,
17} 18}
18 19
19impl<'a, PIO: Instance> PioUartTxProgram<'a, PIO> { 20impl<'d, PIO: Instance> PioUartTxProgram<'d, PIO> {
20 /// Load the uart tx program into the given pio 21 /// Load the uart tx program into the given pio
21 pub fn new(common: &mut Common<'a, PIO>) -> Self { 22 pub fn new(common: &mut Common<'d, PIO>) -> Self {
22 let prg = pio::pio_asm!( 23 let prg = pio::pio_asm!(
23 r#" 24 r#"
24 .side_set 1 opt 25 .side_set 1 opt
@@ -41,18 +42,18 @@ impl<'a, PIO: Instance> PioUartTxProgram<'a, PIO> {
41} 42}
42 43
43/// PIO backed Uart transmitter 44/// PIO backed Uart transmitter
44pub struct PioUartTx<'a, PIO: Instance, const SM: usize> { 45pub struct PioUartTx<'d, PIO: Instance, const SM: usize> {
45 sm_tx: StateMachine<'a, PIO, SM>, 46 sm_tx: StateMachine<'d, PIO, SM>,
46} 47}
47 48
48impl<'a, PIO: Instance, const SM: usize> PioUartTx<'a, PIO, SM> { 49impl<'d, PIO: Instance, const SM: usize> PioUartTx<'d, PIO, SM> {
49 /// Configure a pio state machine to use the loaded tx program. 50 /// Configure a pio state machine to use the loaded tx program.
50 pub fn new( 51 pub fn new(
51 baud: u32, 52 baud: u32,
52 common: &mut Common<'a, PIO>, 53 common: &mut Common<'d, PIO>,
53 mut sm_tx: StateMachine<'a, PIO, SM>, 54 mut sm_tx: StateMachine<'d, PIO, SM>,
54 tx_pin: impl PioPin, 55 tx_pin: Peri<'d, impl PioPin>,
55 program: &PioUartTxProgram<'a, PIO>, 56 program: &PioUartTxProgram<'d, PIO>,
56 ) -> Self { 57 ) -> Self {
57 let tx_pin = common.make_pio_pin(tx_pin); 58 let tx_pin = common.make_pio_pin(tx_pin);
58 sm_tx.set_pins(Level::High, &[&tx_pin]); 59 sm_tx.set_pins(Level::High, &[&tx_pin]);
@@ -92,13 +93,13 @@ impl<PIO: Instance, const SM: usize> Write for PioUartTx<'_, PIO, SM> {
92} 93}
93 94
94/// This struct represents a Uart Rx program loaded into pio instruction memory. 95/// This struct represents a Uart Rx program loaded into pio instruction memory.
95pub struct PioUartRxProgram<'a, PIO: Instance> { 96pub struct PioUartRxProgram<'d, PIO: Instance> {
96 prg: LoadedProgram<'a, PIO>, 97 prg: LoadedProgram<'d, PIO>,
97} 98}
98 99
99impl<'a, PIO: Instance> PioUartRxProgram<'a, PIO> { 100impl<'d, PIO: Instance> PioUartRxProgram<'d, PIO> {
100 /// Load the uart rx program into the given pio 101 /// Load the uart rx program into the given pio
101 pub fn new(common: &mut Common<'a, PIO>) -> Self { 102 pub fn new(common: &mut Common<'d, PIO>) -> Self {
102 let prg = pio::pio_asm!( 103 let prg = pio::pio_asm!(
103 r#" 104 r#"
104 ; Slightly more fleshed-out 8n1 UART receiver which handles framing errors and 105 ; Slightly more fleshed-out 8n1 UART receiver which handles framing errors and
@@ -130,18 +131,18 @@ impl<'a, PIO: Instance> PioUartRxProgram<'a, PIO> {
130} 131}
131 132
132/// PIO backed Uart reciever 133/// PIO backed Uart reciever
133pub struct PioUartRx<'a, PIO: Instance, const SM: usize> { 134pub struct PioUartRx<'d, PIO: Instance, const SM: usize> {
134 sm_rx: StateMachine<'a, PIO, SM>, 135 sm_rx: StateMachine<'d, PIO, SM>,
135} 136}
136 137
137impl<'a, PIO: Instance, const SM: usize> PioUartRx<'a, PIO, SM> { 138impl<'d, PIO: Instance, const SM: usize> PioUartRx<'d, PIO, SM> {
138 /// Configure a pio state machine to use the loaded rx program. 139 /// Configure a pio state machine to use the loaded rx program.
139 pub fn new( 140 pub fn new(
140 baud: u32, 141 baud: u32,
141 common: &mut Common<'a, PIO>, 142 common: &mut Common<'d, PIO>,
142 mut sm_rx: StateMachine<'a, PIO, SM>, 143 mut sm_rx: StateMachine<'d, PIO, SM>,
143 rx_pin: impl PioPin, 144 rx_pin: Peri<'d, impl PioPin>,
144 program: &PioUartRxProgram<'a, PIO>, 145 program: &PioUartRxProgram<'d, PIO>,
145 ) -> Self { 146 ) -> Self {
146 let mut cfg = Config::default(); 147 let mut cfg = Config::default();
147 cfg.use_program(&program.prg, &[]); 148 cfg.use_program(&program.prg, &[]);
diff --git a/embassy-rp/src/pio_programs/ws2812.rs b/embassy-rp/src/pio_programs/ws2812.rs
index 2462a64e6..578937e11 100644
--- a/embassy-rp/src/pio_programs/ws2812.rs
+++ b/embassy-rp/src/pio_programs/ws2812.rs
@@ -9,7 +9,7 @@ use crate::dma::{AnyChannel, Channel};
9use crate::pio::{ 9use crate::pio::{
10 Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, 10 Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine,
11}; 11};
12use crate::{into_ref, Peripheral, PeripheralRef}; 12use crate::Peri;
13 13
14const T1: u8 = 2; // start bit 14const T1: u8 = 2; // start bit
15const T2: u8 = 5; // data bit 15const T2: u8 = 5; // data bit
@@ -53,7 +53,7 @@ impl<'a, PIO: Instance> PioWs2812Program<'a, PIO> {
53/// Pio backed ws2812 driver 53/// Pio backed ws2812 driver
54/// Const N is the number of ws2812 leds attached to this pin 54/// Const N is the number of ws2812 leds attached to this pin
55pub struct PioWs2812<'d, P: Instance, const S: usize, const N: usize> { 55pub struct PioWs2812<'d, P: Instance, const S: usize, const N: usize> {
56 dma: PeripheralRef<'d, AnyChannel>, 56 dma: Peri<'d, AnyChannel>,
57 sm: StateMachine<'d, P, S>, 57 sm: StateMachine<'d, P, S>,
58} 58}
59 59
@@ -62,12 +62,10 @@ impl<'d, P: Instance, const S: usize, const N: usize> PioWs2812<'d, P, S, N> {
62 pub fn new( 62 pub fn new(
63 pio: &mut Common<'d, P>, 63 pio: &mut Common<'d, P>,
64 mut sm: StateMachine<'d, P, S>, 64 mut sm: StateMachine<'d, P, S>,
65 dma: impl Peripheral<P = impl Channel> + 'd, 65 dma: Peri<'d, impl Channel>,
66 pin: impl PioPin, 66 pin: Peri<'d, impl PioPin>,
67 program: &PioWs2812Program<'d, P>, 67 program: &PioWs2812Program<'d, P>,
68 ) -> Self { 68 ) -> Self {
69 into_ref!(dma);
70
71 // Setup sm0 69 // Setup sm0
72 let mut cfg = Config::default(); 70 let mut cfg = Config::default();
73 71
@@ -95,10 +93,7 @@ impl<'d, P: Instance, const S: usize, const N: usize> PioWs2812<'d, P, S, N> {
95 sm.set_config(&cfg); 93 sm.set_config(&cfg);
96 sm.set_enable(true); 94 sm.set_enable(true);
97 95
98 Self { 96 Self { dma: dma.into(), sm }
99 dma: dma.map_into(),
100 sm,
101 }
102 } 97 }
103 98
104 /// Write a buffer of [smart_leds::RGB8] to the ws2812 string 99 /// Write a buffer of [smart_leds::RGB8] to the ws2812 string