@@ -6,12 +6,15 @@ use nb::block;
66use  super :: { 
77    config,  CFlag ,  Error ,  Event ,  Flag ,  Rx ,  RxISR ,  RxListen ,  Serial ,  SerialExt ,  Tx ,  TxISR ,  TxListen , 
88} ; 
9- use  crate :: dma:: { 
10-     traits:: { DMASet ,  PeriAddress } , 
11-     MemoryToPeripheral ,  PeripheralToMemory , 
12- } ; 
13- use  crate :: gpio:: { alt:: SerialAsync  as  CommonPins ,  NoPin ,  PushPull } ; 
9+ use  crate :: gpio:: { alt:: SerialAsync  as  CommonPins ,  NoPin ,  PushPull ,  SerialFlowControl } ; 
1410use  crate :: rcc:: { self ,  Clocks } ; 
11+ use  crate :: { 
12+     dma:: { 
13+         traits:: { DMASet ,  PeriAddress } , 
14+         MemoryToPeripheral ,  PeripheralToMemory , 
15+     } , 
16+     gpio:: alt:: SerialFlowControl , 
17+ } ; 
1518
1619#[ cfg( feature = "uart4" ) ]  
1720pub ( crate )  use  crate :: pac:: uart4:: RegisterBlock  as  RegisterBlockUart ; 
@@ -147,6 +150,9 @@ pub trait RegisterBlockImpl: crate::Sealed {
147150        self . listen_event ( Some ( Event :: TxEmpty . into ( ) ) ,  None ) 
148151    } 
149152
153+     fn  enable_rts ( & self ,  state :  bool ) ; 
154+     fn  enable_cts ( & self ,  state :  bool ) ; 
155+ 
150156    // PeriAddress 
151157    fn  peri_address ( & self )  -> u32 ; 
152158} 
@@ -260,6 +266,14 @@ macro_rules! uartCommon {
260266            } ) ; 
261267        } 
262268
269+         fn  enable_rts( & self ,  state:  bool )  { 
270+             self . cr3( ) . modify( |_,  w| w. rtse( ) . bit( state) ) ; 
271+         } 
272+ 
273+         fn  enable_cts( & self ,  state:  bool )  { 
274+             self . cr3( ) . modify( |_,  w| w. ctse( ) . bit( state) ) ; 
275+         } 
276+ 
263277        fn  peri_address( & self )  -> u32  { 
264278            self . dr( ) . as_ptr( )  as  u32 
265279        } 
@@ -513,6 +527,31 @@ where {
513527    uartCommon !  { } 
514528} 
515529
530+ impl < UART :  Instance  + SerialFlowControl ,  WORD >  Serial < UART ,  WORD >  { 
531+     pub  fn  with_rts ( self ,  rts :  impl  Into < UART :: Rts > )  -> Self  { 
532+         self . rx . usart . enable_rts ( true ) ; 
533+         let  _rts = rts. into ( ) ; 
534+         self 
535+     } 
536+     pub  fn  with_cts ( self ,  cts :  impl  Into < UART :: Cts > )  -> Self  { 
537+         self . tx . usart . enable_cts ( true ) ; 
538+         let  _cts = cts. into ( ) ; 
539+         self 
540+     } 
541+     pub  fn  enable_request_to_send ( & mut  self )  { 
542+         self . rx . usart . enable_rts ( true ) ; 
543+     } 
544+     pub  fn  disable_request_to_send ( & mut  self )  { 
545+         self . rx . usart . enable_rts ( false ) ; 
546+     } 
547+     pub  fn  enable_clear_to_send ( & mut  self )  { 
548+         self . tx . usart . enable_cts ( true ) ; 
549+     } 
550+     pub  fn  disable_clear_to_send ( & mut  self )  { 
551+         self . tx . usart . enable_cts ( false ) ; 
552+     } 
553+ } 
554+ 
516555impl < UART :  Instance ,  WORD >  RxISR  for  Serial < UART ,  WORD > 
517556where 
518557    Rx < UART ,  WORD > :  RxISR , 
0 commit comments