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 {
5353/// RTC clock input source
5454#[ derive( Clone , Copy ) ]
5555pub enum RTCSrc {
56- LSE = 0b01 ,
57- LSI = 0b10 ,
58- HSE = 0b11 ,
56+ LSE ,
57+ LSE_BYPASS ,
58+ LSI ,
59+ HSE ,
60+ HSE_BYPASS ,
5961}
6062
6163/// PLL divider
Original file line number Diff line number Diff line change @@ -301,19 +301,37 @@ impl Rcc {
301301 }
302302
303303 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+
309327 self . apbenr1
310328 . modify ( |_, w| w. rtcapben ( ) . set_bit ( ) . pwren ( ) . set_bit ( ) ) ;
311329 self . apbsmenr1 . modify ( |_, w| w. rtcapbsmen ( ) . set_bit ( ) ) ;
312330 self . unlock_rtc ( ) ;
313331 self . bdcr . modify ( |_, w| w. bdrst ( ) . set_bit ( ) ) ;
314332 self . bdcr . modify ( |_, w| unsafe {
315333 w. rtcsel ( )
316- . bits ( src as u8 )
334+ . bits ( rtc_sel )
317335 . rtcen ( )
318336 . set_bit ( )
319337 . bdrst ( )
You can’t perform that action at this time.
0 commit comments