File tree Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,11 @@ pub enum PLLSrc {
53
53
/// RTC clock input source
54
54
#[ derive( Clone , Copy ) ]
55
55
pub enum RTCSrc {
56
- LSE = 0b01 ,
57
- LSI = 0b10 ,
58
- HSE = 0b11 ,
56
+ LSE ,
57
+ LSE_BYPASS ,
58
+ LSI ,
59
+ HSE ,
60
+ HSE_BYPASS ,
59
61
}
60
62
61
63
/// PLL divider
Original file line number Diff line number Diff line change @@ -301,19 +301,37 @@ impl Rcc {
301
301
}
302
302
303
303
pub ( crate ) fn enable_rtc ( & self , src : RTCSrc ) {
304
- match src {
305
- RTCSrc :: LSI => self . enable_lsi ( ) ,
306
- RTCSrc :: HSE => self . enable_hse ( false ) ,
307
- RTCSrc :: LSE => self . enable_lse ( false ) ,
308
- }
304
+ let rtc_sel = match src {
305
+ RTCSrc :: LSE => {
306
+ self . enable_lse ( false ) ;
307
+ 0b01
308
+ }
309
+ RTCSrc :: LSE_BYPASS => {
310
+ self . enable_lse ( true ) ;
311
+ 0b01
312
+ }
313
+ RTCSrc :: LSI => {
314
+ self . enable_lsi ( ) ;
315
+ 0b10
316
+ }
317
+ RTCSrc :: HSE => {
318
+ self . enable_hse ( false ) ;
319
+ 0b11
320
+ }
321
+ RTCSrc :: HSE_BYPASS => {
322
+ self . enable_hse ( true ) ;
323
+ 0b11
324
+ }
325
+ } ;
326
+
309
327
self . apbenr1
310
328
. modify ( |_, w| w. rtcapben ( ) . set_bit ( ) . pwren ( ) . set_bit ( ) ) ;
311
329
self . apbsmenr1 . modify ( |_, w| w. rtcapbsmen ( ) . set_bit ( ) ) ;
312
330
self . unlock_rtc ( ) ;
313
331
self . bdcr . modify ( |_, w| w. bdrst ( ) . set_bit ( ) ) ;
314
332
self . bdcr . modify ( |_, w| unsafe {
315
333
w. rtcsel ( )
316
- . bits ( src as u8 )
334
+ . bits ( rtc_sel )
317
335
. rtcen ( )
318
336
. set_bit ( )
319
337
. bdrst ( )
You can’t perform that action at this time.
0 commit comments