@@ -17,7 +17,7 @@ use cortex_m;
17
17
use embedded_hal:: timer:: CountDown ;
18
18
use fugit:: { ExtU32 , HertzU32 } ;
19
19
use rp2040_hal:: {
20
- gpio:: { Function , FunctionConfig , Pin , PinId , ValidPinMode } ,
20
+ gpio:: AnyPin ,
21
21
pio:: { PIOExt , StateMachineIndex , Tx , UninitStateMachine , PIO } ,
22
22
} ;
23
23
use smart_leds_trait:: SmartLedsWrite ;
@@ -56,25 +56,23 @@ use smart_leds_trait::SmartLedsWrite;
56
56
///```
57
57
pub struct Ws2812Direct < P , SM , I >
58
58
where
59
- I : PinId ,
60
- P : PIOExt + FunctionConfig ,
61
- Function < P > : ValidPinMode < I > ,
59
+ I : AnyPin < Function = P :: PinFunction > ,
60
+ P : PIOExt ,
62
61
SM : StateMachineIndex ,
63
62
{
64
63
tx : Tx < ( P , SM ) > ,
65
- _pin : Pin < I , Function < P > > ,
64
+ _pin : I ,
66
65
}
67
66
68
67
impl < P , SM , I > Ws2812Direct < P , SM , I >
69
68
where
70
- I : PinId ,
71
- P : PIOExt + FunctionConfig ,
72
- Function < P > : ValidPinMode < I > ,
69
+ I : AnyPin < Function = P :: PinFunction > ,
70
+ P : PIOExt ,
73
71
SM : StateMachineIndex ,
74
72
{
75
73
/// Creates a new instance of this driver.
76
74
pub fn new (
77
- pin : Pin < I , Function < P > > ,
75
+ pin : I ,
78
76
pio : & mut PIO < P > ,
79
77
sm : UninitStateMachine < ( P , SM ) > ,
80
78
clock_freq : fugit:: HertzU32 ,
@@ -127,11 +125,12 @@ where
127
125
let int: u16 = int as u16 ;
128
126
let frac: u8 = frac as u8 ;
129
127
128
+ let pin = pin. into ( ) ;
130
129
let ( mut sm, _, tx) = rp2040_hal:: pio:: PIOBuilder :: from_program ( installed)
131
130
// only use TX FIFO
132
131
. buffers ( rp2040_hal:: pio:: Buffers :: OnlyTx )
133
132
// Pin configuration
134
- . side_set_pin_base ( I :: DYN . num )
133
+ . side_set_pin_base ( pin . id ( ) . num )
135
134
// OSR config
136
135
. out_shift_direction ( rp2040_hal:: pio:: ShiftDirection :: Left )
137
136
. autopull ( true )
@@ -140,19 +139,18 @@ where
140
139
. build ( sm) ;
141
140
142
141
// Prepare pin's direction.
143
- sm. set_pindirs ( [ ( I :: DYN . num , rp2040_hal:: pio:: PinDir :: Output ) ] ) ;
142
+ sm. set_pindirs ( [ ( pin . id ( ) . num , rp2040_hal:: pio:: PinDir :: Output ) ] ) ;
144
143
145
144
sm. start ( ) ;
146
145
147
- Self { tx, _pin : pin }
146
+ Self { tx, _pin : I :: from ( pin) }
148
147
}
149
148
}
150
149
151
150
impl < P , SM , I > SmartLedsWrite for Ws2812Direct < P , SM , I >
152
151
where
153
- I : PinId ,
154
- P : PIOExt + FunctionConfig ,
155
- Function < P > : ValidPinMode < I > ,
152
+ I : AnyPin < Function = P :: PinFunction > ,
153
+ P : PIOExt ,
156
154
SM : StateMachineIndex ,
157
155
{
158
156
type Color = smart_leds_trait:: RGB8 ;
@@ -214,10 +212,9 @@ where
214
212
///```
215
213
pub struct Ws2812 < P , SM , C , I >
216
214
where
217
- I : PinId ,
218
215
C : CountDown ,
219
- P : PIOExt + FunctionConfig ,
220
- Function < P > : ValidPinMode < I > ,
216
+ I : AnyPin < Function = P :: PinFunction > ,
217
+ P : PIOExt ,
221
218
SM : StateMachineIndex ,
222
219
{
223
220
driver : Ws2812Direct < P , SM , I > ,
@@ -226,15 +223,14 @@ where
226
223
227
224
impl < P , SM , C , I > Ws2812 < P , SM , C , I >
228
225
where
229
- I : PinId ,
230
226
C : CountDown ,
231
- P : PIOExt + FunctionConfig ,
232
- Function < P > : ValidPinMode < I > ,
227
+ I : AnyPin < Function = P :: PinFunction > ,
228
+ P : PIOExt ,
233
229
SM : StateMachineIndex ,
234
230
{
235
231
/// Creates a new instance of this driver.
236
232
pub fn new (
237
- pin : Pin < I , Function < P > > ,
233
+ pin : I ,
238
234
pio : & mut PIO < P > ,
239
235
sm : UninitStateMachine < ( P , SM ) > ,
240
236
clock_freq : fugit:: HertzU32 ,
@@ -248,9 +244,8 @@ where
248
244
249
245
impl < ' timer , P , SM , I > SmartLedsWrite for Ws2812 < P , SM , rp2040_hal:: timer:: CountDown < ' timer > , I >
250
246
where
251
- I : PinId ,
252
- P : PIOExt + FunctionConfig ,
253
- Function < P > : ValidPinMode < I > ,
247
+ I : AnyPin < Function = P :: PinFunction > ,
248
+ P : PIOExt ,
254
249
SM : StateMachineIndex ,
255
250
{
256
251
type Color = smart_leds_trait:: RGB8 ;
0 commit comments