@@ -123,17 +123,17 @@ pub struct NoDMA;
123
123
#[ derive( Debug ) ]
124
124
pub struct DMA ;
125
125
126
- pub trait SerialExt < USART , Config > {
126
+ pub trait SerialExt < Config > : Sized {
127
127
fn usart < TX , RX > (
128
128
self ,
129
129
tx : TX ,
130
130
rx : RX ,
131
- config : Config ,
131
+ config : impl Into < Config > ,
132
132
rcc : & mut Rcc ,
133
- ) -> Result < Serial < USART , TX , RX > , InvalidConfig >
133
+ ) -> Result < Serial < Self , TX , RX > , InvalidConfig >
134
134
where
135
- TX : TxPin < USART > ,
136
- RX : RxPin < USART > ;
135
+ TX : TxPin < Self > ,
136
+ RX : RxPin < Self > ;
137
137
}
138
138
139
139
impl < USART , TX , RX > fmt:: Write for Serial < USART , TX , RX >
@@ -526,17 +526,17 @@ macro_rules! uart_lp {
526
526
( $USARTX: ident,
527
527
$usartX: ident, $clk_mul: expr
528
528
) => {
529
- impl SerialExt <$USARTX , LowPowerConfig > for $USARTX {
529
+ impl SerialExt <LowPowerConfig > for $USARTX {
530
530
fn usart<TX , RX >(
531
531
self ,
532
532
tx: TX ,
533
533
rx: RX ,
534
- config: LowPowerConfig ,
534
+ config: impl Into < LowPowerConfig > ,
535
535
rcc: & mut Rcc ,
536
- ) -> Result <Serial <$USARTX , TX , RX >, InvalidConfig >
536
+ ) -> Result <Serial <Self , TX , RX >, InvalidConfig >
537
537
where
538
- TX : TxPin <$USARTX >,
539
- RX : RxPin <$USARTX >,
538
+ TX : TxPin <Self >,
539
+ RX : RxPin <Self >,
540
540
{
541
541
Serial :: $usartX( self , tx, rx, config, rcc)
542
542
}
@@ -551,9 +551,11 @@ macro_rules! uart_lp {
551
551
usart: $USARTX,
552
552
tx: TX ,
553
553
rx: RX ,
554
- config: LowPowerConfig ,
554
+ config: impl Into < LowPowerConfig > ,
555
555
rcc: & mut Rcc ,
556
556
) -> Result <Self , InvalidConfig > {
557
+ let config = config. into( ) ;
558
+
557
559
// Enable clock for USART
558
560
$USARTX:: enable( rcc) ;
559
561
$USARTX:: reset( rcc) ;
@@ -670,17 +672,17 @@ macro_rules! uart_full {
670
672
( $USARTX: ident,
671
673
$usartX: ident
672
674
) => {
673
- impl SerialExt <$USARTX , FullConfig > for $USARTX {
675
+ impl SerialExt <FullConfig > for $USARTX {
674
676
fn usart<TX , RX >(
675
677
self ,
676
678
tx: TX ,
677
679
rx: RX ,
678
- config: FullConfig ,
680
+ config: impl Into < FullConfig > ,
679
681
rcc: & mut Rcc ,
680
- ) -> Result <Serial <$USARTX , TX , RX >, InvalidConfig >
682
+ ) -> Result <Serial <Self , TX , RX >, InvalidConfig >
681
683
where
682
- TX : TxPin <$USARTX >,
683
- RX : RxPin <$USARTX >,
684
+ TX : TxPin <Self >,
685
+ RX : RxPin <Self >,
684
686
{
685
687
Serial :: $usartX( self , tx, rx, config, rcc)
686
688
}
@@ -695,9 +697,11 @@ macro_rules! uart_full {
695
697
usart: $USARTX,
696
698
tx: TX ,
697
699
rx: RX ,
698
- config: FullConfig ,
700
+ config: impl Into < FullConfig > ,
699
701
rcc: & mut Rcc ,
700
702
) -> Result <Self , InvalidConfig > {
703
+ let config = config. into( ) ;
704
+
701
705
// Enable clock for USART
702
706
$USARTX:: enable( rcc) ;
703
707
$USARTX:: reset( rcc) ;
0 commit comments