efm32wg332_pac/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> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, 0>;
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> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, 1>;
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> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, 2>;
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> = crate::BitWriter<'a, u32, BUCTRL_SPEC, bool, 3>;
53#[doc = "Voltage probe select\n\nValue on reset: 0"]
54#[derive(Clone, Copy, Debug, PartialEq)]
55#[repr(u8)]
56pub enum PROBE_A {
57    #[doc = "0: Disable voltage probe."]
58    DISABLE = 0,
59    #[doc = "1: Connect probe to VDD_DREG."]
60    VDDDREG = 1,
61    #[doc = "2: Connect probe to BU_IN."]
62    BUIN = 2,
63    #[doc = "3: Connect probe to BU_OUT."]
64    BUOUT = 3,
65}
66impl From<PROBE_A> for u8 {
67    #[inline(always)]
68    fn from(variant: PROBE_A) -> Self {
69        variant as _
70    }
71}
72#[doc = "Field `PROBE` reader - Voltage probe select"]
73pub type PROBE_R = crate::FieldReader<u8, PROBE_A>;
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> = crate::FieldWriterSafe<'a, u32, BUCTRL_SPEC, u8, PROBE_A, 2, 5>;
109impl<'a> PROBE_W<'a> {
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    pub fn en(&mut self) -> EN_W {
162        EN_W::new(self)
163    }
164    #[doc = "Bit 1 - Enable backup mode status export"]
165    #[inline(always)]
166    pub fn staten(&mut self) -> STATEN_W {
167        STATEN_W::new(self)
168    }
169    #[doc = "Bit 2 - Enable BOD calibration mode"]
170    #[inline(always)]
171    pub fn bodcal(&mut self) -> BODCAL_W {
172        BODCAL_W::new(self)
173    }
174    #[doc = "Bit 3 - Enable brown out detection on BU_VIN when in backup mode"]
175    #[inline(always)]
176    pub fn bumodeboden(&mut self) -> BUMODEBODEN_W {
177        BUMODEBODEN_W::new(self)
178    }
179    #[doc = "Bits 5:6 - Voltage probe select"]
180    #[inline(always)]
181    pub fn probe(&mut self) -> PROBE_W {
182        PROBE_W::new(self)
183    }
184    #[doc = "Writes raw bits to the register."]
185    #[inline(always)]
186    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
187        self.0.bits(bits);
188        self
189    }
190}
191#[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"]
192pub struct BUCTRL_SPEC;
193impl crate::RegisterSpec for BUCTRL_SPEC {
194    type Ux = u32;
195}
196#[doc = "`read()` method returns [buctrl::R](R) reader structure"]
197impl crate::Readable for BUCTRL_SPEC {
198    type Reader = R;
199}
200#[doc = "`write(|w| ..)` method takes [buctrl::W](W) writer structure"]
201impl crate::Writable for BUCTRL_SPEC {
202    type Writer = W;
203}
204#[doc = "`reset()` method sets BUCTRL to value 0"]
205impl crate::Resettable for BUCTRL_SPEC {
206    #[inline(always)]
207    fn reset_value() -> Self::Ux {
208        0
209    }
210}