lpc82x_pac/syscon/
bodctrl.rs1#[doc = "Register `BODCTRL` reader"]
2pub struct R(crate::R<BODCTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<BODCTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<BODCTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<BODCTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `BODCTRL` writer"]
17pub struct W(crate::W<BODCTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<BODCTRL_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<BODCTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<BODCTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "BOD reset level\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum BODRSTLEV_A {
41 #[doc = "1: Level 1"]
42 LEVEL_1 = 1,
43 #[doc = "2: Level 2"]
44 LEVEL_2 = 2,
45 #[doc = "3: Level 3"]
46 LEVEL_3 = 3,
47}
48impl From<BODRSTLEV_A> for u8 {
49 #[inline(always)]
50 fn from(variant: BODRSTLEV_A) -> Self {
51 variant as _
52 }
53}
54#[doc = "Field `BODRSTLEV` reader - BOD reset level"]
55pub struct BODRSTLEV_R(crate::FieldReader<u8, BODRSTLEV_A>);
56impl BODRSTLEV_R {
57 pub(crate) fn new(bits: u8) -> Self {
58 BODRSTLEV_R(crate::FieldReader::new(bits))
59 }
60 #[doc = r"Get enumerated values variant"]
61 #[inline(always)]
62 pub fn variant(&self) -> Option<BODRSTLEV_A> {
63 match self.bits {
64 1 => Some(BODRSTLEV_A::LEVEL_1),
65 2 => Some(BODRSTLEV_A::LEVEL_2),
66 3 => Some(BODRSTLEV_A::LEVEL_3),
67 _ => None,
68 }
69 }
70 #[doc = "Checks if the value of the field is `LEVEL_1`"]
71 #[inline(always)]
72 pub fn is_level_1(&self) -> bool {
73 **self == BODRSTLEV_A::LEVEL_1
74 }
75 #[doc = "Checks if the value of the field is `LEVEL_2`"]
76 #[inline(always)]
77 pub fn is_level_2(&self) -> bool {
78 **self == BODRSTLEV_A::LEVEL_2
79 }
80 #[doc = "Checks if the value of the field is `LEVEL_3`"]
81 #[inline(always)]
82 pub fn is_level_3(&self) -> bool {
83 **self == BODRSTLEV_A::LEVEL_3
84 }
85}
86impl core::ops::Deref for BODRSTLEV_R {
87 type Target = crate::FieldReader<u8, BODRSTLEV_A>;
88 #[inline(always)]
89 fn deref(&self) -> &Self::Target {
90 &self.0
91 }
92}
93#[doc = "Field `BODRSTLEV` writer - BOD reset level"]
94pub struct BODRSTLEV_W<'a> {
95 w: &'a mut W,
96}
97impl<'a> BODRSTLEV_W<'a> {
98 #[doc = r"Writes `variant` to the field"]
99 #[inline(always)]
100 pub fn variant(self, variant: BODRSTLEV_A) -> &'a mut W {
101 unsafe { self.bits(variant.into()) }
102 }
103 #[doc = "Level 1"]
104 #[inline(always)]
105 pub fn level_1(self) -> &'a mut W {
106 self.variant(BODRSTLEV_A::LEVEL_1)
107 }
108 #[doc = "Level 2"]
109 #[inline(always)]
110 pub fn level_2(self) -> &'a mut W {
111 self.variant(BODRSTLEV_A::LEVEL_2)
112 }
113 #[doc = "Level 3"]
114 #[inline(always)]
115 pub fn level_3(self) -> &'a mut W {
116 self.variant(BODRSTLEV_A::LEVEL_3)
117 }
118 #[doc = r"Writes raw bits to the field"]
119 #[inline(always)]
120 pub unsafe fn bits(self, value: u8) -> &'a mut W {
121 self.w.bits = (self.w.bits & !0x03) | (value as u32 & 0x03);
122 self.w
123 }
124}
125#[doc = "BOD interrupt level\n\nValue on reset: 0"]
126#[derive(Clone, Copy, Debug, PartialEq)]
127#[repr(u8)]
128pub enum BODINTVAL_A {
129 #[doc = "1: Level 1"]
130 LEVEL_1 = 1,
131 #[doc = "2: Level 2"]
132 LEVEL_2 = 2,
133 #[doc = "3: Level 3"]
134 LEVEL_3 = 3,
135}
136impl From<BODINTVAL_A> for u8 {
137 #[inline(always)]
138 fn from(variant: BODINTVAL_A) -> Self {
139 variant as _
140 }
141}
142#[doc = "Field `BODINTVAL` reader - BOD interrupt level"]
143pub struct BODINTVAL_R(crate::FieldReader<u8, BODINTVAL_A>);
144impl BODINTVAL_R {
145 pub(crate) fn new(bits: u8) -> Self {
146 BODINTVAL_R(crate::FieldReader::new(bits))
147 }
148 #[doc = r"Get enumerated values variant"]
149 #[inline(always)]
150 pub fn variant(&self) -> Option<BODINTVAL_A> {
151 match self.bits {
152 1 => Some(BODINTVAL_A::LEVEL_1),
153 2 => Some(BODINTVAL_A::LEVEL_2),
154 3 => Some(BODINTVAL_A::LEVEL_3),
155 _ => None,
156 }
157 }
158 #[doc = "Checks if the value of the field is `LEVEL_1`"]
159 #[inline(always)]
160 pub fn is_level_1(&self) -> bool {
161 **self == BODINTVAL_A::LEVEL_1
162 }
163 #[doc = "Checks if the value of the field is `LEVEL_2`"]
164 #[inline(always)]
165 pub fn is_level_2(&self) -> bool {
166 **self == BODINTVAL_A::LEVEL_2
167 }
168 #[doc = "Checks if the value of the field is `LEVEL_3`"]
169 #[inline(always)]
170 pub fn is_level_3(&self) -> bool {
171 **self == BODINTVAL_A::LEVEL_3
172 }
173}
174impl core::ops::Deref for BODINTVAL_R {
175 type Target = crate::FieldReader<u8, BODINTVAL_A>;
176 #[inline(always)]
177 fn deref(&self) -> &Self::Target {
178 &self.0
179 }
180}
181#[doc = "Field `BODINTVAL` writer - BOD interrupt level"]
182pub struct BODINTVAL_W<'a> {
183 w: &'a mut W,
184}
185impl<'a> BODINTVAL_W<'a> {
186 #[doc = r"Writes `variant` to the field"]
187 #[inline(always)]
188 pub fn variant(self, variant: BODINTVAL_A) -> &'a mut W {
189 unsafe { self.bits(variant.into()) }
190 }
191 #[doc = "Level 1"]
192 #[inline(always)]
193 pub fn level_1(self) -> &'a mut W {
194 self.variant(BODINTVAL_A::LEVEL_1)
195 }
196 #[doc = "Level 2"]
197 #[inline(always)]
198 pub fn level_2(self) -> &'a mut W {
199 self.variant(BODINTVAL_A::LEVEL_2)
200 }
201 #[doc = "Level 3"]
202 #[inline(always)]
203 pub fn level_3(self) -> &'a mut W {
204 self.variant(BODINTVAL_A::LEVEL_3)
205 }
206 #[doc = r"Writes raw bits to the field"]
207 #[inline(always)]
208 pub unsafe fn bits(self, value: u8) -> &'a mut W {
209 self.w.bits = (self.w.bits & !(0x03 << 2)) | ((value as u32 & 0x03) << 2);
210 self.w
211 }
212}
213#[doc = "BOD reset enable\n\nValue on reset: 0"]
214#[derive(Clone, Copy, Debug, PartialEq)]
215pub enum BODRSTENA_A {
216 #[doc = "0: Disable reset function."]
217 DISABLE = 0,
218 #[doc = "1: Enable reset function."]
219 ENABLE = 1,
220}
221impl From<BODRSTENA_A> for bool {
222 #[inline(always)]
223 fn from(variant: BODRSTENA_A) -> Self {
224 variant as u8 != 0
225 }
226}
227#[doc = "Field `BODRSTENA` reader - BOD reset enable"]
228pub struct BODRSTENA_R(crate::FieldReader<bool, BODRSTENA_A>);
229impl BODRSTENA_R {
230 pub(crate) fn new(bits: bool) -> Self {
231 BODRSTENA_R(crate::FieldReader::new(bits))
232 }
233 #[doc = r"Get enumerated values variant"]
234 #[inline(always)]
235 pub fn variant(&self) -> BODRSTENA_A {
236 match self.bits {
237 false => BODRSTENA_A::DISABLE,
238 true => BODRSTENA_A::ENABLE,
239 }
240 }
241 #[doc = "Checks if the value of the field is `DISABLE`"]
242 #[inline(always)]
243 pub fn is_disable(&self) -> bool {
244 **self == BODRSTENA_A::DISABLE
245 }
246 #[doc = "Checks if the value of the field is `ENABLE`"]
247 #[inline(always)]
248 pub fn is_enable(&self) -> bool {
249 **self == BODRSTENA_A::ENABLE
250 }
251}
252impl core::ops::Deref for BODRSTENA_R {
253 type Target = crate::FieldReader<bool, BODRSTENA_A>;
254 #[inline(always)]
255 fn deref(&self) -> &Self::Target {
256 &self.0
257 }
258}
259#[doc = "Field `BODRSTENA` writer - BOD reset enable"]
260pub struct BODRSTENA_W<'a> {
261 w: &'a mut W,
262}
263impl<'a> BODRSTENA_W<'a> {
264 #[doc = r"Writes `variant` to the field"]
265 #[inline(always)]
266 pub fn variant(self, variant: BODRSTENA_A) -> &'a mut W {
267 self.bit(variant.into())
268 }
269 #[doc = "Disable reset function."]
270 #[inline(always)]
271 pub fn disable(self) -> &'a mut W {
272 self.variant(BODRSTENA_A::DISABLE)
273 }
274 #[doc = "Enable reset function."]
275 #[inline(always)]
276 pub fn enable(self) -> &'a mut W {
277 self.variant(BODRSTENA_A::ENABLE)
278 }
279 #[doc = r"Sets the field bit"]
280 #[inline(always)]
281 pub fn set_bit(self) -> &'a mut W {
282 self.bit(true)
283 }
284 #[doc = r"Clears the field bit"]
285 #[inline(always)]
286 pub fn clear_bit(self) -> &'a mut W {
287 self.bit(false)
288 }
289 #[doc = r"Writes raw bits to the field"]
290 #[inline(always)]
291 pub fn bit(self, value: bool) -> &'a mut W {
292 self.w.bits = (self.w.bits & !(0x01 << 4)) | ((value as u32 & 0x01) << 4);
293 self.w
294 }
295}
296impl R {
297 #[doc = "Bits 0:1 - BOD reset level"]
298 #[inline(always)]
299 pub fn bodrstlev(&self) -> BODRSTLEV_R {
300 BODRSTLEV_R::new((self.bits & 0x03) as u8)
301 }
302 #[doc = "Bits 2:3 - BOD interrupt level"]
303 #[inline(always)]
304 pub fn bodintval(&self) -> BODINTVAL_R {
305 BODINTVAL_R::new(((self.bits >> 2) & 0x03) as u8)
306 }
307 #[doc = "Bit 4 - BOD reset enable"]
308 #[inline(always)]
309 pub fn bodrstena(&self) -> BODRSTENA_R {
310 BODRSTENA_R::new(((self.bits >> 4) & 0x01) != 0)
311 }
312}
313impl W {
314 #[doc = "Bits 0:1 - BOD reset level"]
315 #[inline(always)]
316 pub fn bodrstlev(&mut self) -> BODRSTLEV_W {
317 BODRSTLEV_W { w: self }
318 }
319 #[doc = "Bits 2:3 - BOD interrupt level"]
320 #[inline(always)]
321 pub fn bodintval(&mut self) -> BODINTVAL_W {
322 BODINTVAL_W { w: self }
323 }
324 #[doc = "Bit 4 - BOD reset enable"]
325 #[inline(always)]
326 pub fn bodrstena(&mut self) -> BODRSTENA_W {
327 BODRSTENA_W { w: self }
328 }
329 #[doc = "Writes raw bits to the register."]
330 #[inline(always)]
331 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
332 self.0.bits(bits);
333 self
334 }
335}
336#[doc = "BOD control 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 [bodctrl](index.html) module"]
337pub struct BODCTRL_SPEC;
338impl crate::RegisterSpec for BODCTRL_SPEC {
339 type Ux = u32;
340}
341#[doc = "`read()` method returns [bodctrl::R](R) reader structure"]
342impl crate::Readable for BODCTRL_SPEC {
343 type Reader = R;
344}
345#[doc = "`write(|w| ..)` method takes [bodctrl::W](W) writer structure"]
346impl crate::Writable for BODCTRL_SPEC {
347 type Writer = W;
348}
349#[doc = "`reset()` method sets BODCTRL to value 0"]
350impl crate::Resettable for BODCTRL_SPEC {
351 #[inline(always)]
352 fn reset_value() -> Self::Ux {
353 0
354 }
355}