efm32gg_pac/efm32gg230/emu/
buctrl.rs

1#[doc = "Register `BUCTRL` reader"]
2pub struct R(crate::R<BUCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<BUCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<BUCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<BUCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `BUCTRL` writer"]
17pub struct W(crate::W<BUCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<BUCTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<BUCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<BUCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `EN` reader - Enable backup mode"]
38pub type EN_R = crate::BitReader<bool>;
39#[doc = "Field `EN` writer - Enable backup mode"]
40pub type EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, O>;
41#[doc = "Field `STATEN` reader - Enable backup mode status export"]
42pub type STATEN_R = crate::BitReader<bool>;
43#[doc = "Field `STATEN` writer - Enable backup mode status export"]
44pub type STATEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, O>;
45#[doc = "Field `BODCAL` reader - Enable BOD calibration mode"]
46pub type BODCAL_R = crate::BitReader<bool>;
47#[doc = "Field `BODCAL` writer - Enable BOD calibration mode"]
48pub type BODCAL_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, O>;
49#[doc = "Field `BUMODEBODEN` reader - Enable brown out detection on BU_VIN when in backup mode"]
50pub type BUMODEBODEN_R = crate::BitReader<bool>;
51#[doc = "Field `BUMODEBODEN` writer - Enable brown out detection on BU_VIN when in backup mode"]
52pub type BUMODEBODEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, O>;
53#[doc = "Field `PROBE` reader - Voltage probe select"]
54pub type PROBE_R = crate::FieldReader<u8, PROBE_A>;
55#[doc = "Voltage probe select\n\nValue on reset: 0"]
56#[derive(Clone, Copy, Debug, PartialEq, Eq)]
57#[repr(u8)]
58pub enum PROBE_A {
59    #[doc = "0: Disable voltage probe."]
60    DISABLE = 0,
61    #[doc = "1: Connect probe to VDD_DREG."]
62    VDDDREG = 1,
63    #[doc = "2: Connect probe to BU_IN."]
64    BUIN = 2,
65    #[doc = "3: Connect probe to BU_OUT."]
66    BUOUT = 3,
67}
68impl From<PROBE_A> for u8 {
69    #[inline(always)]
70    fn from(variant: PROBE_A) -> Self {
71        variant as _
72    }
73}
74impl PROBE_R {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub fn variant(&self) -> PROBE_A {
78        match self.bits {
79            0 => PROBE_A::DISABLE,
80            1 => PROBE_A::VDDDREG,
81            2 => PROBE_A::BUIN,
82            3 => PROBE_A::BUOUT,
83            _ => unreachable!(),
84        }
85    }
86    #[doc = "Checks if the value of the field is `DISABLE`"]
87    #[inline(always)]
88    pub fn is_disable(&self) -> bool {
89        *self == PROBE_A::DISABLE
90    }
91    #[doc = "Checks if the value of the field is `VDDDREG`"]
92    #[inline(always)]
93    pub fn is_vdddreg(&self) -> bool {
94        *self == PROBE_A::VDDDREG
95    }
96    #[doc = "Checks if the value of the field is `BUIN`"]
97    #[inline(always)]
98    pub fn is_buin(&self) -> bool {
99        *self == PROBE_A::BUIN
100    }
101    #[doc = "Checks if the value of the field is `BUOUT`"]
102    #[inline(always)]
103    pub fn is_buout(&self) -> bool {
104        *self == PROBE_A::BUOUT
105    }
106}
107#[doc = "Field `PROBE` writer - Voltage probe select"]
108pub type PROBE_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, PROBE_A, 2, O>;
109impl<'a, const O: u8> PROBE_W<'a, O> {
110    #[doc = "Disable voltage probe."]
111    #[inline(always)]
112    pub fn disable(self) -> &'a mut W {
113        self.variant(PROBE_A::DISABLE)
114    }
115    #[doc = "Connect probe to VDD_DREG."]
116    #[inline(always)]
117    pub fn vdddreg(self) -> &'a mut W {
118        self.variant(PROBE_A::VDDDREG)
119    }
120    #[doc = "Connect probe to BU_IN."]
121    #[inline(always)]
122    pub fn buin(self) -> &'a mut W {
123        self.variant(PROBE_A::BUIN)
124    }
125    #[doc = "Connect probe to BU_OUT."]
126    #[inline(always)]
127    pub fn buout(self) -> &'a mut W {
128        self.variant(PROBE_A::BUOUT)
129    }
130}
131impl R {
132    #[doc = "Bit 0 - Enable backup mode"]
133    #[inline(always)]
134    pub fn en(&self) -> EN_R {
135        EN_R::new((self.bits & 1) != 0)
136    }
137    #[doc = "Bit 1 - Enable backup mode status export"]
138    #[inline(always)]
139    pub fn staten(&self) -> STATEN_R {
140        STATEN_R::new(((self.bits >> 1) & 1) != 0)
141    }
142    #[doc = "Bit 2 - Enable BOD calibration mode"]
143    #[inline(always)]
144    pub fn bodcal(&self) -> BODCAL_R {
145        BODCAL_R::new(((self.bits >> 2) & 1) != 0)
146    }
147    #[doc = "Bit 3 - Enable brown out detection on BU_VIN when in backup mode"]
148    #[inline(always)]
149    pub fn bumodeboden(&self) -> BUMODEBODEN_R {
150        BUMODEBODEN_R::new(((self.bits >> 3) & 1) != 0)
151    }
152    #[doc = "Bits 5:6 - Voltage probe select"]
153    #[inline(always)]
154    pub fn probe(&self) -> PROBE_R {
155        PROBE_R::new(((self.bits >> 5) & 3) as u8)
156    }
157}
158impl W {
159    #[doc = "Bit 0 - Enable backup mode"]
160    #[inline(always)]
161    #[must_use]
162    pub fn en(&mut self) -> EN_W<0> {
163        EN_W::new(self)
164    }
165    #[doc = "Bit 1 - Enable backup mode status export"]
166    #[inline(always)]
167    #[must_use]
168    pub fn staten(&mut self) -> STATEN_W<1> {
169        STATEN_W::new(self)
170    }
171    #[doc = "Bit 2 - Enable BOD calibration mode"]
172    #[inline(always)]
173    #[must_use]
174    pub fn bodcal(&mut self) -> BODCAL_W<2> {
175        BODCAL_W::new(self)
176    }
177    #[doc = "Bit 3 - Enable brown out detection on BU_VIN when in backup mode"]
178    #[inline(always)]
179    #[must_use]
180    pub fn bumodeboden(&mut self) -> BUMODEBODEN_W<3> {
181        BUMODEBODEN_W::new(self)
182    }
183    #[doc = "Bits 5:6 - Voltage probe select"]
184    #[inline(always)]
185    #[must_use]
186    pub fn probe(&mut self) -> PROBE_W<5> {
187        PROBE_W::new(self)
188    }
189    #[doc = "Writes raw bits to the register."]
190    #[inline(always)]
191    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
192        self.0.bits(bits);
193        self
194    }
195}
196#[doc = "Backup Power configuration register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [buctrl](index.html) module"]
197pub struct BUCTRL_SPEC;
198impl crate::RegisterSpec for BUCTRL_SPEC {
199    type Ux = u32;
200}
201#[doc = "`read()` method returns [buctrl::R](R) reader structure"]
202impl crate::Readable for BUCTRL_SPEC {
203    type Reader = R;
204}
205#[doc = "`write(|w| ..)` method takes [buctrl::W](W) writer structure"]
206impl crate::Writable for BUCTRL_SPEC {
207    type Writer = W;
208    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
209    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
210}
211#[doc = "`reset()` method sets BUCTRL to value 0"]
212impl crate::Resettable for BUCTRL_SPEC {
213    const RESET_VALUE: Self::Ux = 0;
214}