@@ -239,7 +239,9 @@ macro_rules! usart {
239
239
pub fn $usart( usart: $USART, pins: ( TXPIN , RXPIN ) , baud_rate: Bps , rcc: & mut Rcc ) -> Self
240
240
{
241
241
let mut serial = Serial { usart, pins } ;
242
- serial. enable( baud_rate, rcc) ;
242
+ serial. configure( baud_rate, rcc) ;
243
+ // Enable transmission and receiving
244
+ serial. usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
243
245
serial
244
246
}
245
247
}
@@ -253,7 +255,9 @@ macro_rules! usart {
253
255
{
254
256
let rxpin = ( ) ;
255
257
let mut serial = Serial { usart, pins: ( txpin, rxpin) } ;
256
- serial. enable( baud_rate, rcc) ;
258
+ serial. configure( baud_rate, rcc) ;
259
+ // Enable transmission
260
+ serial. usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
257
261
serial
258
262
}
259
263
}
@@ -267,13 +271,15 @@ macro_rules! usart {
267
271
{
268
272
let txpin = ( ) ;
269
273
let mut serial = Serial { usart, pins: ( txpin, rxpin) } ;
270
- serial. enable( baud_rate, rcc) ;
274
+ serial. configure( baud_rate, rcc) ;
275
+ // Enable receiving
276
+ serial. usart. cr1. modify( |_, w| w. re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
271
277
serial
272
278
}
273
279
}
274
280
275
281
impl <TXPIN , RXPIN > Serial <$USART, TXPIN , RXPIN > {
276
- fn enable ( & mut self , baud_rate: Bps , rcc: & mut Rcc ) {
282
+ fn configure ( & mut self , baud_rate: Bps , rcc: & mut Rcc ) {
277
283
// Enable clock for USART
278
284
rcc. regs. $apbenr. modify( |_, w| w. $usartXen( ) . set_bit( ) ) ;
279
285
@@ -284,9 +290,6 @@ macro_rules! usart {
284
290
// Reset other registers to disable advanced USART features
285
291
self . usart. cr2. reset( ) ;
286
292
self . usart. cr3. reset( ) ;
287
-
288
- // Enable transmission and receiving
289
- self . usart. cr1. modify( |_, w| w. te( ) . set_bit( ) . re( ) . set_bit( ) . ue( ) . set_bit( ) ) ;
290
293
}
291
294
292
295
/// Starts listening for an interrupt event
0 commit comments