@@ -222,7 +222,9 @@ macro_rules! usart {
222
222
pub fn $usart( usart: $USART, pins: ( TXPIN , RXPIN ) , baud_rate: Bps , clocks: Clocks ) -> Self
223
223
{
224
224
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( ) ) ;
226
228
serial
227
229
}
228
230
}
@@ -236,7 +238,9 @@ macro_rules! usart {
236
238
{
237
239
let rxpin = ( ) ;
238
240
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( ) ) ;
240
244
serial
241
245
}
242
246
}
@@ -250,13 +254,15 @@ macro_rules! usart {
250
254
{
251
255
let txpin = ( ) ;
252
256
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( ) ) ;
254
260
serial
255
261
}
256
262
}
257
263
258
264
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 ) {
260
266
// NOTE(unsafe) This executes only during initialisation
261
267
let rcc = unsafe { & ( * crate :: stm32:: RCC :: ptr( ) ) } ;
262
268
@@ -270,9 +276,6 @@ macro_rules! usart {
270
276
// Reset other registers to disable advanced USART features
271
277
self . usart. cr2. reset( ) ;
272
278
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( ) ) ;
276
279
}
277
280
278
281
/// Starts listening for an interrupt event
0 commit comments