@@ -222,7 +222,9 @@ macro_rules! usart {
222222 pub fn $usart( usart: $USART, pins: ( TXPIN , RXPIN ) , baud_rate: Bps , clocks: Clocks ) -> Self
223223 {
224224 let mut serial = Serial { usart, pins } ;
225- serial. enable( baud_rate, clocks) ;
225+ serial. configure( baud_rate, clocks) ;
226+ // Enable transmission and receiving
227+ serial. usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
226228 serial
227229 }
228230 }
@@ -236,7 +238,9 @@ macro_rules! usart {
236238 {
237239 let rxpin = ( ) ;
238240 let mut serial = Serial { usart, pins: ( txpin, rxpin) } ;
239- serial. enable( baud_rate, clocks) ;
241+ serial. configure( baud_rate, clocks) ;
242+ // Enable transmission
243+ serial. usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
240244 serial
241245 }
242246 }
@@ -250,13 +254,15 @@ macro_rules! usart {
250254 {
251255 let txpin = ( ) ;
252256 let mut serial = Serial { usart, pins: ( txpin, rxpin) } ;
253- serial. enable( baud_rate, clocks) ;
257+ serial. configure( baud_rate, clocks) ;
258+ // Enable receiving
259+ serial. usart. cr1. modify( |_, w| w. re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
254260 serial
255261 }
256262 }
257263
258264 impl <TXPIN , RXPIN > Serial <$USART, TXPIN , RXPIN > {
259- fn enable ( & mut self , baud_rate: Bps , clocks: Clocks ) {
265+ fn configure ( & mut self , baud_rate: Bps , clocks: Clocks ) {
260266 // NOTE(unsafe) This executes only during initialisation
261267 let rcc = unsafe { & ( * crate :: stm32:: RCC :: ptr( ) ) } ;
262268
@@ -270,9 +276,6 @@ macro_rules! usart {
270276 // Reset other registers to disable advanced USART features
271277 self . usart. cr2. reset( ) ;
272278 self . usart. cr3. reset( ) ;
273-
274- // Enable transmission and receiving
275- self . usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
276279 }
277280
278281 /// Starts listening for an interrupt event
0 commit comments