@@ -13,6 +13,7 @@ impl RccExt for RCC {
1313 fn constrain ( self ) -> Rcc {
1414 Rcc {
1515 apb1 : APB1 { _0 : ( ) } ,
16+ apb2 : APB2 { _0 : ( ) } ,
1617 cfgr : CFGR {
1718 hse : None ,
1819 hclk : None ,
@@ -31,6 +32,9 @@ pub struct Rcc {
3132
3233 /// Advanced Peripheral Bus 1 (APB1) registers
3334 pub apb1 : APB1 ,
35+
36+ /// Advanced Peripheral Bus 2 (APB2) registers
37+ pub apb2 : APB2 ,
3438}
3539
3640/// Advanced Peripheral Bus 1 (APB1) registers
@@ -65,6 +69,31 @@ impl APB1 {
6569 }
6670}
6771
72+ /// Advanced Peripheral Bus 2 (APB2) registers
73+ ///
74+ /// Aquired through the `Rcc` registers:
75+ ///
76+ /// ```rust
77+ /// let dp = pac::Peripherals::take().unwrap();
78+ /// let mut rcc = dp.RCC.constrain();
79+ /// function_that_uses_apb2(&mut rcc.apb2);
80+ /// ```
81+ pub struct APB2 {
82+ _0 : ( ) ,
83+ }
84+
85+ impl APB2 {
86+ pub ( crate ) fn enr ( & mut self ) -> & rcc:: APB2ENR {
87+ // NOTE(unsafe) this proxy grants exclusive access to this register
88+ unsafe { & ( * RCC :: ptr ( ) ) . apb2enr }
89+ }
90+
91+ pub ( crate ) fn rstr ( & mut self ) -> & rcc:: APB2RSTR {
92+ // NOTE(unsafe) this proxy grants exclusive access to this register
93+ unsafe { & ( * RCC :: ptr ( ) ) . apb2rstr }
94+ }
95+ }
96+
6897/// Built-in high speed clock frequency
6998pub const HSI : u32 = 16_000_000 ; // Hz
7099
@@ -547,6 +576,15 @@ impl GetBusFreq for APB1 {
547576 }
548577}
549578
579+ impl GetBusFreq for APB2 {
580+ fn get_frequency ( clocks : & Clocks ) -> Hertz {
581+ clocks. pclk2
582+ }
583+ fn get_timer_frequency ( clocks : & Clocks ) -> Hertz {
584+ clocks. pclk2 ( )
585+ }
586+ }
587+
550588pub ( crate ) mod sealed {
551589 /// Bus associated to peripheral
552590 pub trait RccBus {
0 commit comments