@@ -89,6 +89,8 @@ pub struct Config {
89
89
oversampling : Oversampling ,
90
90
character_match : Option < u8 > ,
91
91
receiver_timeout : Option < u32 > ,
92
+ disable_overrun : bool ,
93
+ onebit_sampling : bool ,
92
94
}
93
95
94
96
impl Config {
@@ -142,6 +144,18 @@ impl Config {
142
144
self . receiver_timeout = Some ( receiver_timeout) ;
143
145
self
144
146
}
147
+
148
+ /// Disable overrun detection
149
+ pub fn with_overrun_disabled ( mut self ) -> Self {
150
+ self . disable_overrun = true ;
151
+ self
152
+ }
153
+
154
+ /// Change to onebit sampling
155
+ pub fn with_onebit_sampling ( mut self ) -> Self {
156
+ self . onebit_sampling = true ;
157
+ self
158
+ }
145
159
}
146
160
147
161
impl Default for Config {
@@ -154,6 +168,8 @@ impl Default for Config {
154
168
oversampling : Oversampling :: Over16 ,
155
169
character_match : None ,
156
170
receiver_timeout : None ,
171
+ disable_overrun : false ,
172
+ onebit_sampling : false ,
157
173
}
158
174
}
159
175
}
@@ -264,7 +280,17 @@ macro_rules! hal {
264
280
}
265
281
266
282
// Enable One bit sampling method
267
- usart. cr3. modify( |_, w| w. onebit( ) . set_bit( ) ) ;
283
+ usart. cr3. modify( |_, w| {
284
+ if config. onebit_sampling {
285
+ w. onebit( ) . set_bit( ) ;
286
+ }
287
+
288
+ if config. disable_overrun {
289
+ w. ovrdis( ) . set_bit( ) ;
290
+ }
291
+
292
+ w
293
+ } ) ;
268
294
269
295
// Configure parity and word length
270
296
// Unlike most uart devices, the "word length" of this usart device refers to
0 commit comments