@@ -198,7 +198,9 @@ macro_rules! usart {
198198 pub fn $usart( usart: $USART, pins: ( TXPIN , RXPIN ) , baud_rate: Bps , clocks: Clocks ) -> Self
199199 {
200200 let mut serial = Serial { usart, pins } ;
201- serial. enable( baud_rate, clocks) ;
201+ serial. configure( baud_rate, clocks) ;
202+ // Enable transmission and receiving
203+ serial. usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
202204 serial
203205 }
204206 }
@@ -212,7 +214,9 @@ macro_rules! usart {
212214 {
213215 let rxpin = ( ) ;
214216 let mut serial = Serial { usart, pins: ( txpin, rxpin) } ;
215- serial. enable( baud_rate, clocks) ;
217+ serial. configure( baud_rate, clocks) ;
218+ // Enable transmission
219+ serial. usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
216220 serial
217221 }
218222 }
@@ -226,13 +230,15 @@ macro_rules! usart {
226230 {
227231 let txpin = ( ) ;
228232 let mut serial = Serial { usart, pins: ( txpin, rxpin) } ;
229- serial. enable( baud_rate, clocks) ;
233+ serial. configure( baud_rate, clocks) ;
234+ // Enable receiving
235+ serial. usart. cr1. modify( |_, w| w. re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
230236 serial
231237 }
232238 }
233239
234240 impl <TXPIN , RXPIN > Serial <$USART, TXPIN , RXPIN > {
235- fn enable ( & mut self , baud_rate: Bps , clocks: Clocks ) {
241+ fn configure ( & mut self , baud_rate: Bps , clocks: Clocks ) {
236242 // NOTE(unsafe) This executes only during initialisation
237243 let rcc = unsafe { & ( * crate :: stm32:: RCC :: ptr( ) ) } ;
238244
@@ -246,9 +252,6 @@ macro_rules! usart {
246252 // Reset other registers to disable advanced USART features
247253 self . usart. cr2. reset( ) ;
248254 self . usart. cr3. reset( ) ;
249-
250- // Enable transmission and receiving
251- self . usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
252255 }
253256
254257 /// Starts listening for an interrupt event
0 commit comments