@@ -17,7 +17,7 @@ use cortex_m;
1717use embedded_hal:: timer:: CountDown ;
1818use fugit:: { ExtU32 , HertzU32 } ;
1919use rp2040_hal:: {
20- gpio:: { Function , FunctionConfig , Pin , PinId , ValidPinMode } ,
20+ gpio:: AnyPin ,
2121 pio:: { PIOExt , StateMachineIndex , Tx , UninitStateMachine , PIO } ,
2222} ;
2323use smart_leds_trait:: SmartLedsWrite ;
@@ -56,25 +56,23 @@ use smart_leds_trait::SmartLedsWrite;
5656///```
5757pub struct Ws2812Direct < P , SM , I >
5858where
59- I : PinId ,
60- P : PIOExt + FunctionConfig ,
61- Function < P > : ValidPinMode < I > ,
59+ I : AnyPin < Function = P :: PinFunction > ,
60+ P : PIOExt ,
6261 SM : StateMachineIndex ,
6362{
6463 tx : Tx < ( P , SM ) > ,
65- _pin : Pin < I , Function < P > > ,
64+ _pin : I ,
6665}
6766
6867impl < P , SM , I > Ws2812Direct < P , SM , I >
6968where
70- I : PinId ,
71- P : PIOExt + FunctionConfig ,
72- Function < P > : ValidPinMode < I > ,
69+ I : AnyPin < Function = P :: PinFunction > ,
70+ P : PIOExt ,
7371 SM : StateMachineIndex ,
7472{
7573 /// Creates a new instance of this driver.
7674 pub fn new (
77- pin : Pin < I , Function < P > > ,
75+ pin : I ,
7876 pio : & mut PIO < P > ,
7977 sm : UninitStateMachine < ( P , SM ) > ,
8078 clock_freq : fugit:: HertzU32 ,
@@ -127,11 +125,12 @@ where
127125 let int: u16 = int as u16 ;
128126 let frac: u8 = frac as u8 ;
129127
128+ let pin = pin. into ( ) ;
130129 let ( mut sm, _, tx) = rp2040_hal:: pio:: PIOBuilder :: from_program ( installed)
131130 // only use TX FIFO
132131 . buffers ( rp2040_hal:: pio:: Buffers :: OnlyTx )
133132 // Pin configuration
134- . side_set_pin_base ( I :: DYN . num )
133+ . side_set_pin_base ( pin . id ( ) . num )
135134 // OSR config
136135 . out_shift_direction ( rp2040_hal:: pio:: ShiftDirection :: Left )
137136 . autopull ( true )
@@ -140,19 +139,18 @@ where
140139 . build ( sm) ;
141140
142141 // 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 ) ] ) ;
144143
145144 sm. start ( ) ;
146145
147- Self { tx, _pin : pin }
146+ Self { tx, _pin : I :: from ( pin) }
148147 }
149148}
150149
151150impl < P , SM , I > SmartLedsWrite for Ws2812Direct < P , SM , I >
152151where
153- I : PinId ,
154- P : PIOExt + FunctionConfig ,
155- Function < P > : ValidPinMode < I > ,
152+ I : AnyPin < Function = P :: PinFunction > ,
153+ P : PIOExt ,
156154 SM : StateMachineIndex ,
157155{
158156 type Color = smart_leds_trait:: RGB8 ;
@@ -214,10 +212,9 @@ where
214212///```
215213pub struct Ws2812 < P , SM , C , I >
216214where
217- I : PinId ,
218215 C : CountDown ,
219- P : PIOExt + FunctionConfig ,
220- Function < P > : ValidPinMode < I > ,
216+ I : AnyPin < Function = P :: PinFunction > ,
217+ P : PIOExt ,
221218 SM : StateMachineIndex ,
222219{
223220 driver : Ws2812Direct < P , SM , I > ,
@@ -226,15 +223,14 @@ where
226223
227224impl < P , SM , C , I > Ws2812 < P , SM , C , I >
228225where
229- I : PinId ,
230226 C : CountDown ,
231- P : PIOExt + FunctionConfig ,
232- Function < P > : ValidPinMode < I > ,
227+ I : AnyPin < Function = P :: PinFunction > ,
228+ P : PIOExt ,
233229 SM : StateMachineIndex ,
234230{
235231 /// Creates a new instance of this driver.
236232 pub fn new (
237- pin : Pin < I , Function < P > > ,
233+ pin : I ,
238234 pio : & mut PIO < P > ,
239235 sm : UninitStateMachine < ( P , SM ) > ,
240236 clock_freq : fugit:: HertzU32 ,
@@ -248,9 +244,8 @@ where
248244
249245impl < ' timer , P , SM , I > SmartLedsWrite for Ws2812 < P , SM , rp2040_hal:: timer:: CountDown < ' timer > , I >
250246where
251- I : PinId ,
252- P : PIOExt + FunctionConfig ,
253- Function < P > : ValidPinMode < I > ,
247+ I : AnyPin < Function = P :: PinFunction > ,
248+ P : PIOExt ,
254249 SM : StateMachineIndex ,
255250{
256251 type Color = smart_leds_trait:: RGB8 ;
0 commit comments