1use crate::pac::{RCC, SYSCFG};
2use crate::rcc::Enable;
3use core::fmt;
4use core::ops::Deref;
5
6pub trait SysCfgExt {
8 fn constrain(self, rcc: &mut RCC) -> SysCfg;
10}
11
12impl SysCfgExt for SYSCFG {
13 fn constrain(self, rcc: &mut RCC) -> SysCfg {
14 SYSCFG::enable(rcc);
16
17 SysCfg(self)
18 }
19}
20
21pub struct SysCfg(SYSCFG);
22
23impl Deref for SysCfg {
24 type Target = SYSCFG;
25
26 #[inline(always)]
27 fn deref(&self) -> &Self::Target {
28 &self.0
29 }
30}
31
32#[cfg(feature = "defmt")]
33impl defmt::Format for SysCfg {
34 fn format(&self, f: defmt::Formatter) {
35 defmt::write!(f, "SysCfg(SYSCFG)");
36 }
37}
38
39impl fmt::Debug for SysCfg {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 f.debug_struct("SysCfg").finish()
42 }
43}