nrf52840_pac/lpcomp/
refsel.rs
1#[doc = "Register `REFSEL` reader"]
2pub struct R(crate::R<REFSEL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<REFSEL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<REFSEL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<REFSEL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `REFSEL` writer"]
17pub struct W(crate::W<REFSEL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<REFSEL_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<REFSEL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<REFSEL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `REFSEL` reader - Reference select"]
38pub type REFSEL_R = crate::FieldReader<u8, REFSEL_A>;
39#[doc = "Reference select\n\nValue on reset: 4"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum REFSEL_A {
43 #[doc = "0: VDD * 1/8 selected as reference"]
44 REF1_8VDD = 0,
45 #[doc = "1: VDD * 2/8 selected as reference"]
46 REF2_8VDD = 1,
47 #[doc = "2: VDD * 3/8 selected as reference"]
48 REF3_8VDD = 2,
49 #[doc = "3: VDD * 4/8 selected as reference"]
50 REF4_8VDD = 3,
51 #[doc = "4: VDD * 5/8 selected as reference"]
52 REF5_8VDD = 4,
53 #[doc = "5: VDD * 6/8 selected as reference"]
54 REF6_8VDD = 5,
55 #[doc = "6: VDD * 7/8 selected as reference"]
56 REF7_8VDD = 6,
57 #[doc = "7: External analog reference selected"]
58 AREF = 7,
59 #[doc = "8: VDD * 1/16 selected as reference"]
60 REF1_16VDD = 8,
61 #[doc = "9: VDD * 3/16 selected as reference"]
62 REF3_16VDD = 9,
63 #[doc = "10: VDD * 5/16 selected as reference"]
64 REF5_16VDD = 10,
65 #[doc = "11: VDD * 7/16 selected as reference"]
66 REF7_16VDD = 11,
67 #[doc = "12: VDD * 9/16 selected as reference"]
68 REF9_16VDD = 12,
69 #[doc = "13: VDD * 11/16 selected as reference"]
70 REF11_16VDD = 13,
71 #[doc = "14: VDD * 13/16 selected as reference"]
72 REF13_16VDD = 14,
73 #[doc = "15: VDD * 15/16 selected as reference"]
74 REF15_16VDD = 15,
75}
76impl From<REFSEL_A> for u8 {
77 #[inline(always)]
78 fn from(variant: REFSEL_A) -> Self {
79 variant as _
80 }
81}
82impl REFSEL_R {
83 #[doc = "Get enumerated values variant"]
84 #[inline(always)]
85 pub fn variant(&self) -> REFSEL_A {
86 match self.bits {
87 0 => REFSEL_A::REF1_8VDD,
88 1 => REFSEL_A::REF2_8VDD,
89 2 => REFSEL_A::REF3_8VDD,
90 3 => REFSEL_A::REF4_8VDD,
91 4 => REFSEL_A::REF5_8VDD,
92 5 => REFSEL_A::REF6_8VDD,
93 6 => REFSEL_A::REF7_8VDD,
94 7 => REFSEL_A::AREF,
95 8 => REFSEL_A::REF1_16VDD,
96 9 => REFSEL_A::REF3_16VDD,
97 10 => REFSEL_A::REF5_16VDD,
98 11 => REFSEL_A::REF7_16VDD,
99 12 => REFSEL_A::REF9_16VDD,
100 13 => REFSEL_A::REF11_16VDD,
101 14 => REFSEL_A::REF13_16VDD,
102 15 => REFSEL_A::REF15_16VDD,
103 _ => unreachable!(),
104 }
105 }
106 #[doc = "Checks if the value of the field is `REF1_8VDD`"]
107 #[inline(always)]
108 pub fn is_ref1_8vdd(&self) -> bool {
109 *self == REFSEL_A::REF1_8VDD
110 }
111 #[doc = "Checks if the value of the field is `REF2_8VDD`"]
112 #[inline(always)]
113 pub fn is_ref2_8vdd(&self) -> bool {
114 *self == REFSEL_A::REF2_8VDD
115 }
116 #[doc = "Checks if the value of the field is `REF3_8VDD`"]
117 #[inline(always)]
118 pub fn is_ref3_8vdd(&self) -> bool {
119 *self == REFSEL_A::REF3_8VDD
120 }
121 #[doc = "Checks if the value of the field is `REF4_8VDD`"]
122 #[inline(always)]
123 pub fn is_ref4_8vdd(&self) -> bool {
124 *self == REFSEL_A::REF4_8VDD
125 }
126 #[doc = "Checks if the value of the field is `REF5_8VDD`"]
127 #[inline(always)]
128 pub fn is_ref5_8vdd(&self) -> bool {
129 *self == REFSEL_A::REF5_8VDD
130 }
131 #[doc = "Checks if the value of the field is `REF6_8VDD`"]
132 #[inline(always)]
133 pub fn is_ref6_8vdd(&self) -> bool {
134 *self == REFSEL_A::REF6_8VDD
135 }
136 #[doc = "Checks if the value of the field is `REF7_8VDD`"]
137 #[inline(always)]
138 pub fn is_ref7_8vdd(&self) -> bool {
139 *self == REFSEL_A::REF7_8VDD
140 }
141 #[doc = "Checks if the value of the field is `AREF`"]
142 #[inline(always)]
143 pub fn is_aref(&self) -> bool {
144 *self == REFSEL_A::AREF
145 }
146 #[doc = "Checks if the value of the field is `REF1_16VDD`"]
147 #[inline(always)]
148 pub fn is_ref1_16vdd(&self) -> bool {
149 *self == REFSEL_A::REF1_16VDD
150 }
151 #[doc = "Checks if the value of the field is `REF3_16VDD`"]
152 #[inline(always)]
153 pub fn is_ref3_16vdd(&self) -> bool {
154 *self == REFSEL_A::REF3_16VDD
155 }
156 #[doc = "Checks if the value of the field is `REF5_16VDD`"]
157 #[inline(always)]
158 pub fn is_ref5_16vdd(&self) -> bool {
159 *self == REFSEL_A::REF5_16VDD
160 }
161 #[doc = "Checks if the value of the field is `REF7_16VDD`"]
162 #[inline(always)]
163 pub fn is_ref7_16vdd(&self) -> bool {
164 *self == REFSEL_A::REF7_16VDD
165 }
166 #[doc = "Checks if the value of the field is `REF9_16VDD`"]
167 #[inline(always)]
168 pub fn is_ref9_16vdd(&self) -> bool {
169 *self == REFSEL_A::REF9_16VDD
170 }
171 #[doc = "Checks if the value of the field is `REF11_16VDD`"]
172 #[inline(always)]
173 pub fn is_ref11_16vdd(&self) -> bool {
174 *self == REFSEL_A::REF11_16VDD
175 }
176 #[doc = "Checks if the value of the field is `REF13_16VDD`"]
177 #[inline(always)]
178 pub fn is_ref13_16vdd(&self) -> bool {
179 *self == REFSEL_A::REF13_16VDD
180 }
181 #[doc = "Checks if the value of the field is `REF15_16VDD`"]
182 #[inline(always)]
183 pub fn is_ref15_16vdd(&self) -> bool {
184 *self == REFSEL_A::REF15_16VDD
185 }
186}
187#[doc = "Field `REFSEL` writer - Reference select"]
188pub type REFSEL_W<'a, const O: u8> =
189 crate::FieldWriterSafe<'a, u32, REFSEL_SPEC, u8, REFSEL_A, 4, O>;
190impl<'a, const O: u8> REFSEL_W<'a, O> {
191 #[doc = "VDD * 1/8 selected as reference"]
192 #[inline(always)]
193 pub fn ref1_8vdd(self) -> &'a mut W {
194 self.variant(REFSEL_A::REF1_8VDD)
195 }
196 #[doc = "VDD * 2/8 selected as reference"]
197 #[inline(always)]
198 pub fn ref2_8vdd(self) -> &'a mut W {
199 self.variant(REFSEL_A::REF2_8VDD)
200 }
201 #[doc = "VDD * 3/8 selected as reference"]
202 #[inline(always)]
203 pub fn ref3_8vdd(self) -> &'a mut W {
204 self.variant(REFSEL_A::REF3_8VDD)
205 }
206 #[doc = "VDD * 4/8 selected as reference"]
207 #[inline(always)]
208 pub fn ref4_8vdd(self) -> &'a mut W {
209 self.variant(REFSEL_A::REF4_8VDD)
210 }
211 #[doc = "VDD * 5/8 selected as reference"]
212 #[inline(always)]
213 pub fn ref5_8vdd(self) -> &'a mut W {
214 self.variant(REFSEL_A::REF5_8VDD)
215 }
216 #[doc = "VDD * 6/8 selected as reference"]
217 #[inline(always)]
218 pub fn ref6_8vdd(self) -> &'a mut W {
219 self.variant(REFSEL_A::REF6_8VDD)
220 }
221 #[doc = "VDD * 7/8 selected as reference"]
222 #[inline(always)]
223 pub fn ref7_8vdd(self) -> &'a mut W {
224 self.variant(REFSEL_A::REF7_8VDD)
225 }
226 #[doc = "External analog reference selected"]
227 #[inline(always)]
228 pub fn aref(self) -> &'a mut W {
229 self.variant(REFSEL_A::AREF)
230 }
231 #[doc = "VDD * 1/16 selected as reference"]
232 #[inline(always)]
233 pub fn ref1_16vdd(self) -> &'a mut W {
234 self.variant(REFSEL_A::REF1_16VDD)
235 }
236 #[doc = "VDD * 3/16 selected as reference"]
237 #[inline(always)]
238 pub fn ref3_16vdd(self) -> &'a mut W {
239 self.variant(REFSEL_A::REF3_16VDD)
240 }
241 #[doc = "VDD * 5/16 selected as reference"]
242 #[inline(always)]
243 pub fn ref5_16vdd(self) -> &'a mut W {
244 self.variant(REFSEL_A::REF5_16VDD)
245 }
246 #[doc = "VDD * 7/16 selected as reference"]
247 #[inline(always)]
248 pub fn ref7_16vdd(self) -> &'a mut W {
249 self.variant(REFSEL_A::REF7_16VDD)
250 }
251 #[doc = "VDD * 9/16 selected as reference"]
252 #[inline(always)]
253 pub fn ref9_16vdd(self) -> &'a mut W {
254 self.variant(REFSEL_A::REF9_16VDD)
255 }
256 #[doc = "VDD * 11/16 selected as reference"]
257 #[inline(always)]
258 pub fn ref11_16vdd(self) -> &'a mut W {
259 self.variant(REFSEL_A::REF11_16VDD)
260 }
261 #[doc = "VDD * 13/16 selected as reference"]
262 #[inline(always)]
263 pub fn ref13_16vdd(self) -> &'a mut W {
264 self.variant(REFSEL_A::REF13_16VDD)
265 }
266 #[doc = "VDD * 15/16 selected as reference"]
267 #[inline(always)]
268 pub fn ref15_16vdd(self) -> &'a mut W {
269 self.variant(REFSEL_A::REF15_16VDD)
270 }
271}
272impl R {
273 #[doc = "Bits 0:3 - Reference select"]
274 #[inline(always)]
275 pub fn refsel(&self) -> REFSEL_R {
276 REFSEL_R::new((self.bits & 0x0f) as u8)
277 }
278}
279impl W {
280 #[doc = "Bits 0:3 - Reference select"]
281 #[inline(always)]
282 pub fn refsel(&mut self) -> REFSEL_W<0> {
283 REFSEL_W::new(self)
284 }
285 #[doc = "Writes raw bits to the register."]
286 #[inline(always)]
287 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
288 self.0.bits(bits);
289 self
290 }
291}
292#[doc = "Reference select\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 [refsel](index.html) module"]
293pub struct REFSEL_SPEC;
294impl crate::RegisterSpec for REFSEL_SPEC {
295 type Ux = u32;
296}
297#[doc = "`read()` method returns [refsel::R](R) reader structure"]
298impl crate::Readable for REFSEL_SPEC {
299 type Reader = R;
300}
301#[doc = "`write(|w| ..)` method takes [refsel::W](W) writer structure"]
302impl crate::Writable for REFSEL_SPEC {
303 type Writer = W;
304}
305#[doc = "`reset()` method sets REFSEL to value 0x04"]
306impl crate::Resettable for REFSEL_SPEC {
307 #[inline(always)]
308 fn reset_value() -> Self::Ux {
309 0x04
310 }
311}