atsaml21g16b/supc/
vref.rs

1#[doc = "Register `VREF` reader"]
2pub struct R(crate::R<VREF_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<VREF_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<VREF_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<VREF_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `VREF` writer"]
17pub struct W(crate::W<VREF_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<VREF_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<VREF_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<VREF_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TSEN` reader - Temperature Sensor Output Enable"]
38pub type TSEN_R = crate::BitReader<bool>;
39#[doc = "Field `TSEN` writer - Temperature Sensor Output Enable"]
40pub type TSEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, VREF_SPEC, bool, O>;
41#[doc = "Field `VREFOE` reader - Voltage Reference Output Enable"]
42pub type VREFOE_R = crate::BitReader<bool>;
43#[doc = "Field `VREFOE` writer - Voltage Reference Output Enable"]
44pub type VREFOE_W<'a, const O: u8> = crate::BitWriter<'a, u32, VREF_SPEC, bool, O>;
45#[doc = "Field `RUNSTDBY` reader - Run during Standby"]
46pub type RUNSTDBY_R = crate::BitReader<bool>;
47#[doc = "Field `RUNSTDBY` writer - Run during Standby"]
48pub type RUNSTDBY_W<'a, const O: u8> = crate::BitWriter<'a, u32, VREF_SPEC, bool, O>;
49#[doc = "Field `ONDEMAND` reader - On Demand Contrl"]
50pub type ONDEMAND_R = crate::BitReader<bool>;
51#[doc = "Field `ONDEMAND` writer - On Demand Contrl"]
52pub type ONDEMAND_W<'a, const O: u8> = crate::BitWriter<'a, u32, VREF_SPEC, bool, O>;
53#[doc = "Field `SEL` reader - Voltage Reference Selection"]
54pub type SEL_R = crate::FieldReader<u8, SELSELECT_A>;
55#[doc = "Voltage Reference Selection\n\nValue on reset: 0"]
56#[derive(Clone, Copy, Debug, PartialEq, Eq)]
57#[repr(u8)]
58pub enum SELSELECT_A {
59    #[doc = "0: 1.0V voltage reference typical value"]
60    _1V0 = 0,
61    #[doc = "1: 1.1V voltage reference typical value"]
62    _1V1 = 1,
63    #[doc = "2: 1.2V voltage reference typical value"]
64    _1V2 = 2,
65    #[doc = "3: 1.25V voltage reference typical value"]
66    _1V25 = 3,
67    #[doc = "4: 2.0V voltage reference typical value"]
68    _2V0 = 4,
69    #[doc = "5: 2.2V voltage reference typical value"]
70    _2V2 = 5,
71    #[doc = "6: 2.4V voltage reference typical value"]
72    _2V4 = 6,
73    #[doc = "7: 2.5V voltage reference typical value"]
74    _2V5 = 7,
75}
76impl From<SELSELECT_A> for u8 {
77    #[inline(always)]
78    fn from(variant: SELSELECT_A) -> Self {
79        variant as _
80    }
81}
82impl SEL_R {
83    #[doc = "Get enumerated values variant"]
84    #[inline(always)]
85    pub fn variant(&self) -> Option<SELSELECT_A> {
86        match self.bits {
87            0 => Some(SELSELECT_A::_1V0),
88            1 => Some(SELSELECT_A::_1V1),
89            2 => Some(SELSELECT_A::_1V2),
90            3 => Some(SELSELECT_A::_1V25),
91            4 => Some(SELSELECT_A::_2V0),
92            5 => Some(SELSELECT_A::_2V2),
93            6 => Some(SELSELECT_A::_2V4),
94            7 => Some(SELSELECT_A::_2V5),
95            _ => None,
96        }
97    }
98    #[doc = "Checks if the value of the field is `_1V0`"]
99    #[inline(always)]
100    pub fn is_1v0(&self) -> bool {
101        *self == SELSELECT_A::_1V0
102    }
103    #[doc = "Checks if the value of the field is `_1V1`"]
104    #[inline(always)]
105    pub fn is_1v1(&self) -> bool {
106        *self == SELSELECT_A::_1V1
107    }
108    #[doc = "Checks if the value of the field is `_1V2`"]
109    #[inline(always)]
110    pub fn is_1v2(&self) -> bool {
111        *self == SELSELECT_A::_1V2
112    }
113    #[doc = "Checks if the value of the field is `_1V25`"]
114    #[inline(always)]
115    pub fn is_1v25(&self) -> bool {
116        *self == SELSELECT_A::_1V25
117    }
118    #[doc = "Checks if the value of the field is `_2V0`"]
119    #[inline(always)]
120    pub fn is_2v0(&self) -> bool {
121        *self == SELSELECT_A::_2V0
122    }
123    #[doc = "Checks if the value of the field is `_2V2`"]
124    #[inline(always)]
125    pub fn is_2v2(&self) -> bool {
126        *self == SELSELECT_A::_2V2
127    }
128    #[doc = "Checks if the value of the field is `_2V4`"]
129    #[inline(always)]
130    pub fn is_2v4(&self) -> bool {
131        *self == SELSELECT_A::_2V4
132    }
133    #[doc = "Checks if the value of the field is `_2V5`"]
134    #[inline(always)]
135    pub fn is_2v5(&self) -> bool {
136        *self == SELSELECT_A::_2V5
137    }
138}
139#[doc = "Field `SEL` writer - Voltage Reference Selection"]
140pub type SEL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, VREF_SPEC, u8, SELSELECT_A, 4, O>;
141impl<'a, const O: u8> SEL_W<'a, O> {
142    #[doc = "1.0V voltage reference typical value"]
143    #[inline(always)]
144    pub fn _1v0(self) -> &'a mut W {
145        self.variant(SELSELECT_A::_1V0)
146    }
147    #[doc = "1.1V voltage reference typical value"]
148    #[inline(always)]
149    pub fn _1v1(self) -> &'a mut W {
150        self.variant(SELSELECT_A::_1V1)
151    }
152    #[doc = "1.2V voltage reference typical value"]
153    #[inline(always)]
154    pub fn _1v2(self) -> &'a mut W {
155        self.variant(SELSELECT_A::_1V2)
156    }
157    #[doc = "1.25V voltage reference typical value"]
158    #[inline(always)]
159    pub fn _1v25(self) -> &'a mut W {
160        self.variant(SELSELECT_A::_1V25)
161    }
162    #[doc = "2.0V voltage reference typical value"]
163    #[inline(always)]
164    pub fn _2v0(self) -> &'a mut W {
165        self.variant(SELSELECT_A::_2V0)
166    }
167    #[doc = "2.2V voltage reference typical value"]
168    #[inline(always)]
169    pub fn _2v2(self) -> &'a mut W {
170        self.variant(SELSELECT_A::_2V2)
171    }
172    #[doc = "2.4V voltage reference typical value"]
173    #[inline(always)]
174    pub fn _2v4(self) -> &'a mut W {
175        self.variant(SELSELECT_A::_2V4)
176    }
177    #[doc = "2.5V voltage reference typical value"]
178    #[inline(always)]
179    pub fn _2v5(self) -> &'a mut W {
180        self.variant(SELSELECT_A::_2V5)
181    }
182}
183impl R {
184    #[doc = "Bit 1 - Temperature Sensor Output Enable"]
185    #[inline(always)]
186    pub fn tsen(&self) -> TSEN_R {
187        TSEN_R::new(((self.bits >> 1) & 1) != 0)
188    }
189    #[doc = "Bit 2 - Voltage Reference Output Enable"]
190    #[inline(always)]
191    pub fn vrefoe(&self) -> VREFOE_R {
192        VREFOE_R::new(((self.bits >> 2) & 1) != 0)
193    }
194    #[doc = "Bit 6 - Run during Standby"]
195    #[inline(always)]
196    pub fn runstdby(&self) -> RUNSTDBY_R {
197        RUNSTDBY_R::new(((self.bits >> 6) & 1) != 0)
198    }
199    #[doc = "Bit 7 - On Demand Contrl"]
200    #[inline(always)]
201    pub fn ondemand(&self) -> ONDEMAND_R {
202        ONDEMAND_R::new(((self.bits >> 7) & 1) != 0)
203    }
204    #[doc = "Bits 16:19 - Voltage Reference Selection"]
205    #[inline(always)]
206    pub fn sel(&self) -> SEL_R {
207        SEL_R::new(((self.bits >> 16) & 0x0f) as u8)
208    }
209}
210impl W {
211    #[doc = "Bit 1 - Temperature Sensor Output Enable"]
212    #[inline(always)]
213    #[must_use]
214    pub fn tsen(&mut self) -> TSEN_W<1> {
215        TSEN_W::new(self)
216    }
217    #[doc = "Bit 2 - Voltage Reference Output Enable"]
218    #[inline(always)]
219    #[must_use]
220    pub fn vrefoe(&mut self) -> VREFOE_W<2> {
221        VREFOE_W::new(self)
222    }
223    #[doc = "Bit 6 - Run during Standby"]
224    #[inline(always)]
225    #[must_use]
226    pub fn runstdby(&mut self) -> RUNSTDBY_W<6> {
227        RUNSTDBY_W::new(self)
228    }
229    #[doc = "Bit 7 - On Demand Contrl"]
230    #[inline(always)]
231    #[must_use]
232    pub fn ondemand(&mut self) -> ONDEMAND_W<7> {
233        ONDEMAND_W::new(self)
234    }
235    #[doc = "Bits 16:19 - Voltage Reference Selection"]
236    #[inline(always)]
237    #[must_use]
238    pub fn sel(&mut self) -> SEL_W<16> {
239        SEL_W::new(self)
240    }
241    #[doc = "Writes raw bits to the register."]
242    #[inline(always)]
243    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
244        self.0.bits(bits);
245        self
246    }
247}
248#[doc = "VREF Control\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 [vref](index.html) module"]
249pub struct VREF_SPEC;
250impl crate::RegisterSpec for VREF_SPEC {
251    type Ux = u32;
252}
253#[doc = "`read()` method returns [vref::R](R) reader structure"]
254impl crate::Readable for VREF_SPEC {
255    type Reader = R;
256}
257#[doc = "`write(|w| ..)` method takes [vref::W](W) writer structure"]
258impl crate::Writable for VREF_SPEC {
259    type Writer = W;
260    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
261    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
262}
263#[doc = "`reset()` method sets VREF to value 0"]
264impl crate::Resettable for VREF_SPEC {
265    const RESET_VALUE: Self::Ux = 0;
266}