@@ -99,7 +99,7 @@ impl Pins<USART2> for (PA2<Alternate<PushPull>>, PA3<Input<Floating>>) {
99
99
}
100
100
101
101
impl Pins < USART2 > for ( PD5 < Alternate < PushPull > > , PD6 < Input < Floating > > ) {
102
- const REMAP : u8 = 0 ;
102
+ const REMAP : u8 = 1 ;
103
103
}
104
104
105
105
impl Pins < USART3 > for ( PB10 < Alternate < PushPull > > , PB11 < Input < Floating > > ) {
@@ -181,6 +181,8 @@ use crate::pac::usart1 as uart_base;
181
181
pub struct Serial < USART , PINS > {
182
182
usart : USART ,
183
183
pins : PINS ,
184
+ tx : Tx < USART > ,
185
+ rx : Rx < USART > ,
184
186
}
185
187
186
188
pub trait Instance :
@@ -315,7 +317,7 @@ where
315
317
/// Separates the serial struct into separate channel objects for sending (Tx) and
316
318
/// receiving (Rx)
317
319
pub fn split ( self ) -> ( Tx < USART > , Rx < USART > ) {
318
- ( Tx :: new ( ) , Rx :: new ( ) )
320
+ ( self . tx , self . rx )
319
321
}
320
322
}
321
323
@@ -365,7 +367,7 @@ macro_rules! hal {
365
367
PINS : Pins <$USARTX>,
366
368
{
367
369
#[ allow( unused_unsafe) ]
368
- Serial { usart, pins } . init( config, clocks, || {
370
+ Serial { usart, pins, tx : Tx :: new ( ) , rx : Rx :: new ( ) } . init( config, clocks, || {
369
371
mapr. modify_mapr( |_, w| unsafe {
370
372
#[ allow( clippy:: redundant_closure_call) ]
371
373
w. $usartX_remap( ) . $bit( ( $closure) ( PINS :: REMAP ) )
@@ -506,7 +508,7 @@ where
506
508
type Error = Error ;
507
509
508
510
fn read ( & mut self ) -> nb:: Result < u8 , Error > {
509
- Rx :: < USART > :: new ( ) . read ( )
511
+ self . rx . read ( )
510
512
}
511
513
}
512
514
@@ -517,11 +519,11 @@ where
517
519
type Error = Infallible ;
518
520
519
521
fn flush ( & mut self ) -> nb:: Result < ( ) , Self :: Error > {
520
- Tx :: < USART > :: new ( ) . flush ( )
522
+ self . tx . flush ( )
521
523
}
522
524
523
525
fn write ( & mut self , byte : u8 ) -> nb:: Result < ( ) , Self :: Error > {
524
- Tx :: < USART > :: new ( ) . write ( byte)
526
+ self . tx . write ( byte)
525
527
}
526
528
}
527
529
0 commit comments