16
16
//use cortex_m;
17
17
use fugit:: { ExtU32 , HertzU32 } ;
18
18
use rp2040_hal:: {
19
- gpio:: { Function , Pin , PinId } ,
19
+ gpio:: { Function , Pin , PinId , PullType , * } ,
20
20
pio:: { PIOExt , StateMachineIndex , Tx , UninitStateMachine , PIO } ,
21
21
//timer::CountDown,
22
22
} ;
@@ -54,26 +54,27 @@ use rp2040_hal::{
54
54
///// delay_for_at_least_60_microseconds();
55
55
///// };
56
56
/////```
57
- //pub struct Ws2812Direct<P, SM, I>
58
- pub struct Ws2812Direct < P , SM >
57
+ pub struct Ws2812Direct < P , SM , I , F >
59
58
where
60
- // I: PinId,
59
+ I : PinId ,
61
60
P : PIOExt ,
61
+ F : Function ,
62
62
SM : StateMachineIndex ,
63
63
{
64
64
tx : Tx < ( P , SM ) > ,
65
+ _pin : Pin < I , F , DynPullType >
65
66
}
66
67
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 >
69
69
where
70
- // I: PinId,
70
+ I : PinId ,
71
71
P : PIOExt ,
72
+ F : Function ,
72
73
SM : StateMachineIndex ,
73
74
{
74
75
/// Creates a new instance of this driver.
75
76
pub fn new (
76
- // pin: Pin<I, Function<P> >,
77
+ pin : Pin < I , F , DynPullType > ,
77
78
pio : & mut PIO < P > ,
78
79
sm : UninitStateMachine < ( P , SM ) > ,
79
80
clock_freq : fugit:: HertzU32 ,
@@ -130,7 +131,7 @@ where
130
131
// only use TX FIFO
131
132
. buffers ( rp2040_hal:: pio:: Buffers :: OnlyTx )
132
133
// Pin configuration
133
- // .side_set_pin_base(I::DYN .num)
134
+ . side_set_pin_base ( pin . id ( ) . num )
134
135
// OSR config
135
136
. out_shift_direction ( rp2040_hal:: pio:: ShiftDirection :: Left )
136
137
. autopull ( true )
@@ -139,11 +140,11 @@ where
139
140
. build ( sm) ;
140
141
141
142
// 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 ) ] ) ;
143
144
144
145
sm. start ( ) ;
145
146
146
- Self { tx }
147
+ Self { tx, _pin : pin }
147
148
}
148
149
}
149
150
0 commit comments