Skip to content

Commit 8f88250

Browse files
committed
WIP3
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 993b979 commit 8f88250

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/lib.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//use cortex_m;
1717
use fugit::{ExtU32, HertzU32};
1818
use rp2040_hal::{
19-
gpio::{Function, Pin, PinId},
19+
gpio::{Function, Pin, PinId, PullType, *},
2020
pio::{PIOExt, StateMachineIndex, Tx, UninitStateMachine, PIO},
2121
//timer::CountDown,
2222
};
@@ -54,26 +54,27 @@ use rp2040_hal::{
5454
///// delay_for_at_least_60_microseconds();
5555
///// };
5656
/////```
57-
//pub struct Ws2812Direct<P, SM, I>
58-
pub struct Ws2812Direct<P, SM>
57+
pub struct Ws2812Direct<P, SM, I, F>
5958
where
60-
//I: PinId,
59+
I: PinId,
6160
P: PIOExt,
61+
F: Function,
6262
SM: StateMachineIndex,
6363
{
6464
tx: Tx<(P, SM)>,
65+
_pin: Pin<I, F, DynPullType>
6566
}
6667

67-
//impl<P, SM, I> Ws2812Direct<P, SM, I>
68-
impl<P, SM> Ws2812Direct<P, SM>
68+
impl<P, SM, I, F> Ws2812Direct<P, SM, I, F>
6969
where
70-
//I: PinId,
70+
I: PinId,
7171
P: PIOExt,
72+
F: Function,
7273
SM: StateMachineIndex,
7374
{
7475
/// Creates a new instance of this driver.
7576
pub fn new(
76-
//pin: Pin<I, Function<P>>,
77+
pin: Pin<I, F, DynPullType>,
7778
pio: &mut PIO<P>,
7879
sm: UninitStateMachine<(P, SM)>,
7980
clock_freq: fugit::HertzU32,
@@ -130,7 +131,7 @@ where
130131
// only use TX FIFO
131132
.buffers(rp2040_hal::pio::Buffers::OnlyTx)
132133
// Pin configuration
133-
//.side_set_pin_base(I::DYN.num)
134+
.side_set_pin_base(pin.id().num)
134135
// OSR config
135136
.out_shift_direction(rp2040_hal::pio::ShiftDirection::Left)
136137
.autopull(true)
@@ -139,11 +140,11 @@ where
139140
.build(sm);
140141

141142
// Prepare pin's direction.
142-
//sm.set_pindirs([(I::DYN.num, rp2040_hal::pio::PinDir::Output)]);
143+
sm.set_pindirs([(pin.id().num, rp2040_hal::pio::PinDir::Output)]);
143144

144145
sm.start();
145146

146-
Self { tx }
147+
Self { tx, _pin: pin }
147148
}
148149
}
149150

0 commit comments

Comments
 (0)