d1_pac/rtc/
rtc_vio.rs

1#[doc = "Register `rtc_vio` reader"]
2pub type R = crate::R<RTC_VIO_SPEC>;
3#[doc = "Register `rtc_vio` writer"]
4pub type W = crate::W<RTC_VIO_SPEC>;
5#[doc = "Field `rtc_viou` reader - RTC_VIO Voltage Select\n\nThe RTC-VIO is provided power for RTC digital part.\n\nThese bits are useful for regulating the RTC_VIO from 0.65 V to 1.3 V."]
6pub type RTC_VIOU_R = crate::FieldReader<RTC_VIOU_A>;
7#[doc = "RTC_VIO Voltage Select\n\nThe RTC-VIO is provided power for RTC digital part.\n\nThese bits are useful for regulating the RTC_VIO from 0.65 V to 1.3 V.\n\nValue on reset: 4"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9#[repr(u8)]
10pub enum RTC_VIOU_A {
11    #[doc = "0: 1.0 V"]
12    V_1_0 = 0,
13    #[doc = "1: 0.65 V (the configuration can cause RTC reset)"]
14    V_0_65 = 1,
15    #[doc = "2: 0.7 V"]
16    V_0_7 = 2,
17    #[doc = "3: 0.8 V"]
18    V_0_8 = 3,
19    #[doc = "4: 0.9 V"]
20    V_0_9 = 4,
21    #[doc = "5: 1.1 V"]
22    V_1_1 = 5,
23    #[doc = "6: 1.2 V"]
24    V_1_2 = 6,
25    #[doc = "7: 1.3 V"]
26    V_1_3 = 7,
27}
28impl From<RTC_VIOU_A> for u8 {
29    #[inline(always)]
30    fn from(variant: RTC_VIOU_A) -> Self {
31        variant as _
32    }
33}
34impl crate::FieldSpec for RTC_VIOU_A {
35    type Ux = u8;
36}
37impl RTC_VIOU_R {
38    #[doc = "Get enumerated values variant"]
39    #[inline(always)]
40    pub const fn variant(&self) -> RTC_VIOU_A {
41        match self.bits {
42            0 => RTC_VIOU_A::V_1_0,
43            1 => RTC_VIOU_A::V_0_65,
44            2 => RTC_VIOU_A::V_0_7,
45            3 => RTC_VIOU_A::V_0_8,
46            4 => RTC_VIOU_A::V_0_9,
47            5 => RTC_VIOU_A::V_1_1,
48            6 => RTC_VIOU_A::V_1_2,
49            7 => RTC_VIOU_A::V_1_3,
50            _ => unreachable!(),
51        }
52    }
53    #[doc = "1.0 V"]
54    #[inline(always)]
55    pub fn is_v_1_0(&self) -> bool {
56        *self == RTC_VIOU_A::V_1_0
57    }
58    #[doc = "0.65 V (the configuration can cause RTC reset)"]
59    #[inline(always)]
60    pub fn is_v_0_65(&self) -> bool {
61        *self == RTC_VIOU_A::V_0_65
62    }
63    #[doc = "0.7 V"]
64    #[inline(always)]
65    pub fn is_v_0_7(&self) -> bool {
66        *self == RTC_VIOU_A::V_0_7
67    }
68    #[doc = "0.8 V"]
69    #[inline(always)]
70    pub fn is_v_0_8(&self) -> bool {
71        *self == RTC_VIOU_A::V_0_8
72    }
73    #[doc = "0.9 V"]
74    #[inline(always)]
75    pub fn is_v_0_9(&self) -> bool {
76        *self == RTC_VIOU_A::V_0_9
77    }
78    #[doc = "1.1 V"]
79    #[inline(always)]
80    pub fn is_v_1_1(&self) -> bool {
81        *self == RTC_VIOU_A::V_1_1
82    }
83    #[doc = "1.2 V"]
84    #[inline(always)]
85    pub fn is_v_1_2(&self) -> bool {
86        *self == RTC_VIOU_A::V_1_2
87    }
88    #[doc = "1.3 V"]
89    #[inline(always)]
90    pub fn is_v_1_3(&self) -> bool {
91        *self == RTC_VIOU_A::V_1_3
92    }
93}
94#[doc = "Field `rtc_viou` writer - RTC_VIO Voltage Select\n\nThe RTC-VIO is provided power for RTC digital part.\n\nThese bits are useful for regulating the RTC_VIO from 0.65 V to 1.3 V."]
95pub type RTC_VIOU_W<'a, REG> = crate::FieldWriterSafe<'a, REG, 3, RTC_VIOU_A>;
96impl<'a, REG> RTC_VIOU_W<'a, REG>
97where
98    REG: crate::Writable + crate::RegisterSpec,
99    REG::Ux: From<u8>,
100{
101    #[doc = "1.0 V"]
102    #[inline(always)]
103    pub fn v_1_0(self) -> &'a mut crate::W<REG> {
104        self.variant(RTC_VIOU_A::V_1_0)
105    }
106    #[doc = "0.65 V (the configuration can cause RTC reset)"]
107    #[inline(always)]
108    pub fn v_0_65(self) -> &'a mut crate::W<REG> {
109        self.variant(RTC_VIOU_A::V_0_65)
110    }
111    #[doc = "0.7 V"]
112    #[inline(always)]
113    pub fn v_0_7(self) -> &'a mut crate::W<REG> {
114        self.variant(RTC_VIOU_A::V_0_7)
115    }
116    #[doc = "0.8 V"]
117    #[inline(always)]
118    pub fn v_0_8(self) -> &'a mut crate::W<REG> {
119        self.variant(RTC_VIOU_A::V_0_8)
120    }
121    #[doc = "0.9 V"]
122    #[inline(always)]
123    pub fn v_0_9(self) -> &'a mut crate::W<REG> {
124        self.variant(RTC_VIOU_A::V_0_9)
125    }
126    #[doc = "1.1 V"]
127    #[inline(always)]
128    pub fn v_1_1(self) -> &'a mut crate::W<REG> {
129        self.variant(RTC_VIOU_A::V_1_1)
130    }
131    #[doc = "1.2 V"]
132    #[inline(always)]
133    pub fn v_1_2(self) -> &'a mut crate::W<REG> {
134        self.variant(RTC_VIOU_A::V_1_2)
135    }
136    #[doc = "1.3 V"]
137    #[inline(always)]
138    pub fn v_1_3(self) -> &'a mut crate::W<REG> {
139        self.variant(RTC_VIOU_A::V_1_3)
140    }
141}
142#[doc = "Field `v_sel` reader - VDD Select"]
143pub type V_SEL_R = crate::BitReader<V_SEL_A>;
144#[doc = "VDD Select\n\nValue on reset: 0"]
145#[derive(Clone, Copy, Debug, PartialEq, Eq)]
146pub enum V_SEL_A {
147    #[doc = "0: Resistance divider"]
148    RESISTANCE = 0,
149    #[doc = "1: Band gap"]
150    BAND = 1,
151}
152impl From<V_SEL_A> for bool {
153    #[inline(always)]
154    fn from(variant: V_SEL_A) -> Self {
155        variant as u8 != 0
156    }
157}
158impl V_SEL_R {
159    #[doc = "Get enumerated values variant"]
160    #[inline(always)]
161    pub const fn variant(&self) -> V_SEL_A {
162        match self.bits {
163            false => V_SEL_A::RESISTANCE,
164            true => V_SEL_A::BAND,
165        }
166    }
167    #[doc = "Resistance divider"]
168    #[inline(always)]
169    pub fn is_resistance(&self) -> bool {
170        *self == V_SEL_A::RESISTANCE
171    }
172    #[doc = "Band gap"]
173    #[inline(always)]
174    pub fn is_band(&self) -> bool {
175        *self == V_SEL_A::BAND
176    }
177}
178#[doc = "Field `v_sel` writer - VDD Select"]
179pub type V_SEL_W<'a, REG> = crate::BitWriter<'a, REG, V_SEL_A>;
180impl<'a, REG> V_SEL_W<'a, REG>
181where
182    REG: crate::Writable + crate::RegisterSpec,
183{
184    #[doc = "Resistance divider"]
185    #[inline(always)]
186    pub fn resistance(self) -> &'a mut crate::W<REG> {
187        self.variant(V_SEL_A::RESISTANCE)
188    }
189    #[doc = "Band gap"]
190    #[inline(always)]
191    pub fn band(self) -> &'a mut crate::W<REG> {
192        self.variant(V_SEL_A::BAND)
193    }
194}
195impl R {
196    #[doc = "Bits 0:2 - RTC_VIO Voltage Select\n\nThe RTC-VIO is provided power for RTC digital part.\n\nThese bits are useful for regulating the RTC_VIO from 0.65 V to 1.3 V."]
197    #[inline(always)]
198    pub fn rtc_viou(&self) -> RTC_VIOU_R {
199        RTC_VIOU_R::new((self.bits & 7) as u8)
200    }
201    #[doc = "Bit 4 - VDD Select"]
202    #[inline(always)]
203    pub fn v_sel(&self) -> V_SEL_R {
204        V_SEL_R::new(((self.bits >> 4) & 1) != 0)
205    }
206}
207impl W {
208    #[doc = "Bits 0:2 - RTC_VIO Voltage Select\n\nThe RTC-VIO is provided power for RTC digital part.\n\nThese bits are useful for regulating the RTC_VIO from 0.65 V to 1.3 V."]
209    #[inline(always)]
210    #[must_use]
211    pub fn rtc_viou(&mut self) -> RTC_VIOU_W<RTC_VIO_SPEC> {
212        RTC_VIOU_W::new(self, 0)
213    }
214    #[doc = "Bit 4 - VDD Select"]
215    #[inline(always)]
216    #[must_use]
217    pub fn v_sel(&mut self) -> V_SEL_W<RTC_VIO_SPEC> {
218        V_SEL_W::new(self, 4)
219    }
220    #[doc = r" Writes raw bits to the register."]
221    #[doc = r""]
222    #[doc = r" # Safety"]
223    #[doc = r""]
224    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
225    #[inline(always)]
226    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
227        self.bits = bits;
228        self
229    }
230}
231#[doc = "RTC_VIO Regulation Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`rtc_vio::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`rtc_vio::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
232pub struct RTC_VIO_SPEC;
233impl crate::RegisterSpec for RTC_VIO_SPEC {
234    type Ux = u32;
235}
236#[doc = "`read()` method returns [`rtc_vio::R`](R) reader structure"]
237impl crate::Readable for RTC_VIO_SPEC {}
238#[doc = "`write(|w| ..)` method takes [`rtc_vio::W`](W) writer structure"]
239impl crate::Writable for RTC_VIO_SPEC {
240    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
241    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
242}
243#[doc = "`reset()` method sets rtc_vio to value 0x04"]
244impl crate::Resettable for RTC_VIO_SPEC {
245    const RESET_VALUE: Self::Ux = 0x04;
246}