@@ -56,7 +56,7 @@ use crate::pac::UART8;
56
56
#[ cfg( feature = "uart9" ) ]
57
57
use crate :: pac:: UART9 ;
58
58
59
- use crate :: gpio:: Alternate ;
59
+ use crate :: gpio:: { Alternate , NoPin } ;
60
60
use crate :: rcc:: Clocks ;
61
61
62
62
use crate :: dma:: traits:: PeriAddress ;
@@ -192,13 +192,13 @@ where
192
192
}
193
193
194
194
/// A filler type for when the Tx pin is unnecessary
195
- pub struct NoTx ;
195
+ pub type NoTx = NoPin ;
196
196
/// A filler type for when the Rx pin is unnecessary
197
- pub struct NoRx ;
197
+ pub type NoRx = NoPin ;
198
198
199
- impl PinTx < USART1 > for NoTx { }
199
+ impl < USART > PinTx < USART > for NoPin where USART : Instance { }
200
200
201
- impl PinRx < USART1 > for NoRx { }
201
+ impl < USART > PinRx < USART > for NoPin where USART : Instance { }
202
202
203
203
impl PinTx < USART1 > for gpioa:: PA9 < Alternate < 7 > > { }
204
204
@@ -224,10 +224,6 @@ impl PinTx<USART1> for gpiob::PB6<Alternate<7>> {}
224
224
225
225
impl PinRx < USART1 > for gpiob:: PB7 < Alternate < 7 > > { }
226
226
227
- impl PinTx < USART2 > for NoTx { }
228
-
229
- impl PinRx < USART2 > for NoRx { }
230
-
231
227
impl PinTx < USART2 > for gpioa:: PA2 < Alternate < 7 > > { }
232
228
233
229
impl PinRx < USART2 > for gpioa:: PA3 < Alternate < 7 > > { }
@@ -270,10 +266,6 @@ impl PinTx<USART2> for gpiod::PD5<Alternate<7>> {}
270
266
) ) ]
271
267
impl PinRx < USART2 > for gpiod:: PD6 < Alternate < 7 > > { }
272
268
273
- #[ cfg( feature = "usart3" ) ]
274
- impl PinTx < USART3 > for NoTx { }
275
- #[ cfg( feature = "usart3" ) ]
276
- impl PinRx < USART3 > for NoRx { }
277
269
#[ cfg( feature = "usart3" ) ]
278
270
impl PinTx < USART3 > for gpiob:: PB10 < Alternate < 7 > > { }
279
271
#[ cfg( feature = "usart3" ) ]
@@ -354,10 +346,6 @@ impl PinTx<USART3> for gpiod::PD8<Alternate<7>> {}
354
346
) ) ]
355
347
impl PinRx < USART3 > for gpiod:: PD9 < Alternate < 7 > > { }
356
348
357
- #[ cfg( feature = "uart4" ) ]
358
- impl PinTx < UART4 > for NoTx { }
359
- #[ cfg( feature = "uart4" ) ]
360
- impl PinRx < UART4 > for NoRx { }
361
349
#[ cfg( feature = "uart4" ) ]
362
350
impl PinTx < UART4 > for gpioa:: PA0 < Alternate < 8 > > { }
363
351
#[ cfg( feature = "uart4" ) ]
@@ -403,10 +391,6 @@ impl PinTx<UART4> for gpiod::PD10<Alternate<8>> {}
403
391
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
404
392
impl PinRx < UART4 > for gpioc:: PC11 < Alternate < 8 > > { }
405
393
406
- #[ cfg( feature = "uart5" ) ]
407
- impl PinTx < UART5 > for NoTx { }
408
- #[ cfg( feature = "uart5" ) ]
409
- impl PinRx < UART5 > for NoRx { }
410
394
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
411
395
impl PinTx < UART5 > for gpiob:: PB6 < Alternate < 11 > > { }
412
396
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
@@ -428,9 +412,6 @@ impl PinTx<UART5> for gpioe::PE8<Alternate<8>> {}
428
412
#[ cfg( any( feature = "stm32f446" ) ) ]
429
413
impl PinRx < UART5 > for gpioe:: PE7 < Alternate < 8 > > { }
430
414
431
- impl PinTx < USART6 > for NoTx { }
432
-
433
- impl PinRx < USART6 > for NoRx { }
434
415
#[ cfg( any(
435
416
feature = "stm32f401" ,
436
417
feature = "stm32f410" ,
@@ -488,10 +469,6 @@ impl PinTx<USART6> for gpiog::PG14<Alternate<8>> {}
488
469
) ) ]
489
470
impl PinRx < USART6 > for gpiog:: PG9 < Alternate < 8 > > { }
490
471
491
- #[ cfg( feature = "uart7" ) ]
492
- impl PinTx < UART7 > for NoTx { }
493
- #[ cfg( feature = "uart7" ) ]
494
- impl PinRx < UART7 > for NoRx { }
495
472
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
496
473
impl PinTx < UART7 > for gpioa:: PA15 < Alternate < 8 > > { }
497
474
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
@@ -509,10 +486,6 @@ impl PinTx<UART7> for gpiof::PF7<Alternate<8>> {}
509
486
#[ cfg( all( feature = "uart7" , feature = "gpiof" ) ) ]
510
487
impl PinRx < UART7 > for gpiof:: PF6 < Alternate < 8 > > { }
511
488
512
- #[ cfg( feature = "uart8" ) ]
513
- impl PinTx < UART8 > for NoTx { }
514
- #[ cfg( feature = "uart8" ) ]
515
- impl PinRx < UART8 > for NoRx { }
516
489
#[ cfg( all( feature = "uart8" , feature = "gpioe" ) ) ]
517
490
impl PinTx < UART8 > for gpioe:: PE1 < Alternate < 8 > > { }
518
491
#[ cfg( all( feature = "uart8" , feature = "gpioe" ) ) ]
@@ -522,10 +495,6 @@ impl PinTx<UART8> for gpiof::PF9<Alternate<8>> {}
522
495
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
523
496
impl PinRx < UART8 > for gpiof:: PF8 < Alternate < 8 > > { }
524
497
525
- #[ cfg( feature = "uart9" ) ]
526
- impl PinTx < UART9 > for NoTx { }
527
- #[ cfg( feature = "uart9" ) ]
528
- impl PinRx < UART9 > for NoRx { }
529
498
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
530
499
impl PinTx < UART9 > for gpiod:: PD15 < Alternate < 11 > > { }
531
500
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
@@ -535,10 +504,6 @@ impl PinTx<UART9> for gpiog::PG1<Alternate<11>> {}
535
504
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
536
505
impl PinRx < UART9 > for gpiog:: PG0 < Alternate < 11 > > { }
537
506
538
- #[ cfg( feature = "uart10" ) ]
539
- impl PinTx < UART10 > for NoTx { }
540
- #[ cfg( feature = "uart10" ) ]
541
- impl PinRx < UART10 > for NoRx { }
542
507
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
543
508
impl PinTx < UART10 > for gpioe:: PE3 < Alternate < 11 > > { }
544
509
#[ cfg( any( feature = "stm32f413" , feature = "stm32f423" ) ) ]
@@ -567,9 +532,10 @@ pub struct Tx<USART, WORD = u8> {
567
532
_word : PhantomData < WORD > ,
568
533
}
569
534
570
- impl < USART , PINS , WORD > Serial < USART , PINS , WORD >
535
+ impl < USART , TX , RX , WORD > Serial < USART , ( TX , RX ) , WORD >
571
536
where
572
- PINS : Pins < USART > ,
537
+ TX : PinTx < USART > ,
538
+ RX : PinRx < USART > ,
573
539
USART : Instance ,
574
540
{
575
541
/*
@@ -579,7 +545,7 @@ where
579
545
*/
580
546
pub fn new (
581
547
usart : USART ,
582
- pins : PINS ,
548
+ pins : ( TX , RX ) ,
583
549
config : config:: Config ,
584
550
clocks : Clocks ,
585
551
) -> Result < Self , config:: InvalidConfig > {
@@ -696,9 +662,9 @@ where
696
662
}
697
663
}
698
664
699
- impl < USART , TX , WORD > Serial < USART , ( TX , NoRx ) , WORD >
665
+ impl < USART , TX , WORD > Serial < USART , ( TX , NoPin ) , WORD >
700
666
where
701
- ( TX , NoRx ) : Pins < USART > ,
667
+ TX : PinTx < USART > ,
702
668
USART : Instance ,
703
669
{
704
670
pub fn tx (
@@ -707,13 +673,13 @@ where
707
673
config : config:: Config ,
708
674
clocks : Clocks ,
709
675
) -> Result < Tx < USART , WORD > , config:: InvalidConfig > {
710
- Self :: new ( usart, ( tx_pin, NoRx ) , config, clocks) . map ( |s| s. split ( ) . 0 )
676
+ Self :: new ( usart, ( tx_pin, NoPin ) , config, clocks) . map ( |s| s. split ( ) . 0 )
711
677
}
712
678
}
713
679
714
- impl < USART , RX , WORD > Serial < USART , ( NoTx , RX ) , WORD >
680
+ impl < USART , RX , WORD > Serial < USART , ( NoPin , RX ) , WORD >
715
681
where
716
- ( NoTx , RX ) : Pins < USART > ,
682
+ RX : PinRx < USART > ,
717
683
USART : Instance ,
718
684
{
719
685
pub fn rx (
@@ -722,7 +688,7 @@ where
722
688
config : config:: Config ,
723
689
clocks : Clocks ,
724
690
) -> Result < Rx < USART , WORD > , config:: InvalidConfig > {
725
- Self :: new ( usart, ( NoTx , rx_pin) , config, clocks) . map ( |s| s. split ( ) . 1 )
691
+ Self :: new ( usart, ( NoPin , rx_pin) , config, clocks) . map ( |s| s. split ( ) . 1 )
726
692
}
727
693
}
728
694
@@ -1220,15 +1186,16 @@ macro_rules! halUsart {
1220
1186
}
1221
1187
}
1222
1188
1223
- impl <USART , PINS > Serial <USART , PINS >
1189
+ impl <USART , TX , RX > Serial <USART , ( TX , RX ) >
1224
1190
where
1225
- PINS : Pins <USART >,
1191
+ TX : PinTx <USART >,
1192
+ RX : PinRx <USART >,
1226
1193
USART : Instance ,
1227
1194
{
1228
1195
#[ deprecated( since = "0.10.0" ) ]
1229
1196
pub fn $usartX(
1230
1197
usart: USART ,
1231
- pins: PINS ,
1198
+ pins: ( TX , RX ) ,
1232
1199
config: config:: Config ,
1233
1200
clocks: Clocks ,
1234
1201
) -> Result <Self , config:: InvalidConfig > {
@@ -1275,15 +1242,16 @@ macro_rules! halUart {
1275
1242
}
1276
1243
}
1277
1244
1278
- impl <USART , PINS > Serial <USART , PINS >
1245
+ impl <USART , TX , RX > Serial <USART , ( TX , RX ) >
1279
1246
where
1280
- PINS : Pins <USART >,
1247
+ TX : PinTx <USART >,
1248
+ RX : PinRx <USART >,
1281
1249
USART : Instance ,
1282
1250
{
1283
1251
#[ deprecated( since = "0.10.0" ) ]
1284
1252
pub fn $usartX(
1285
1253
usart: USART ,
1286
- pins: PINS ,
1254
+ pins: ( TX , RX ) ,
1287
1255
config: config:: Config ,
1288
1256
clocks: Clocks ,
1289
1257
) -> Result <Self , config:: InvalidConfig > {
0 commit comments