@@ -198,7 +198,9 @@ macro_rules! usart {
198
198
pub fn $usart( usart: $USART, pins: ( TXPIN , RXPIN ) , baud_rate: Bps , clocks: Clocks ) -> Self
199
199
{
200
200
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( ) ) ;
202
204
serial
203
205
}
204
206
}
@@ -212,7 +214,9 @@ macro_rules! usart {
212
214
{
213
215
let rxpin = ( ) ;
214
216
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( ) ) ;
216
220
serial
217
221
}
218
222
}
@@ -226,13 +230,15 @@ macro_rules! usart {
226
230
{
227
231
let txpin = ( ) ;
228
232
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( ) ) ;
230
236
serial
231
237
}
232
238
}
233
239
234
240
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 ) {
236
242
// NOTE(unsafe) This executes only during initialisation
237
243
let rcc = unsafe { & ( * crate :: stm32:: RCC :: ptr( ) ) } ;
238
244
@@ -246,9 +252,6 @@ macro_rules! usart {
246
252
// Reset other registers to disable advanced USART features
247
253
self . usart. cr2. reset( ) ;
248
254
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( ) ) ;
252
255
}
253
256
254
257
/// Starts listening for an interrupt event
0 commit comments