File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ cfg_if::cfg_if! {
191
191
pub mod rtc;
192
192
pub mod serial;
193
193
pub mod spi;
194
+ pub mod syscfg;
194
195
pub mod timer;
195
196
}
196
197
}
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ pub use crate::flash::FlashExt as _stm32f3xx_hal_flash_FlashExt;
6
6
pub use crate :: gpio:: GpioExt as _stm32f3xx_hal_gpio_GpioExt;
7
7
pub use crate :: hal:: prelude:: * ;
8
8
pub use crate :: rcc:: RccExt as _stm32f3xx_hal_rcc_RccExt;
9
+ pub use crate :: syscfg:: SysCfgExt as _stm32f3xx_hal_syscfg_SysCfgExt;
9
10
pub use crate :: time:: duration:: Extensions as _stm32f3xx_hal_time_time_Extensions;
10
11
pub use crate :: time:: rate:: Extensions as _stm32f3xx_hal_time_rate_Extensions;
11
12
#[ cfg( feature = "unproven" ) ]
Original file line number Diff line number Diff line change
1
+ //! System configuration controller
2
+
3
+ use core:: ops:: Deref ;
4
+
5
+ use crate :: { pac:: SYSCFG , rcc:: APB2 } ;
6
+
7
+ /// Extension trait that constrains the `SYSCFG` peripheral
8
+ pub trait SysCfgExt {
9
+ /// Constrains the `SYSCFG` peripheral so it plays nicely with the other abstractions
10
+ fn constrain ( self , apb2 : & mut APB2 ) -> SysCfg ;
11
+ }
12
+
13
+ impl SysCfgExt for SYSCFG {
14
+ fn constrain ( self , apb2 : & mut APB2 ) -> SysCfg {
15
+ apb2. enr ( ) . modify ( |_, w| w. syscfgen ( ) . enabled ( ) ) ;
16
+
17
+ SysCfg ( self )
18
+ }
19
+ }
20
+
21
+ /// Constrained SYSCFG peripheral
22
+ ///
23
+ /// An instance of this struct is acquired by calling the
24
+ /// [`constrain`](SysCfgExt::constrain) function on the
25
+ /// [`SYSCFG`](crate::pac::SYSCFG) struct.
26
+ ///
27
+ /// ```
28
+ /// let dp = pac::Peripherals::take().unwrap();
29
+ /// let syscfg = dp.SYSCFG.constrain();
30
+ /// ```
31
+ pub struct SysCfg ( SYSCFG ) ;
32
+
33
+ impl Deref for SysCfg {
34
+ type Target = SYSCFG ;
35
+
36
+ #[ inline( always) ]
37
+ fn deref ( & self ) -> & Self :: Target {
38
+ & self . 0
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments