1#[doc = "Reader of register LVDSC1"]
2pub type R = crate::R<u8, super::LVDSC1>;
3#[doc = "Writer for register LVDSC1"]
4pub type W = crate::W<u8, super::LVDSC1>;
5#[doc = "Register LVDSC1 `reset()`'s with value 0x10"]
6impl crate::ResetValue for super::LVDSC1 {
7 type Type = u8;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0x10
11 }
12}
13#[doc = "Low-Voltage Detect Voltage Select\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15#[repr(u8)]
16pub enum LVDV_A {
17 #[doc = "0: Low trip point selected (V LVD = V LVDL )"]
18 _00 = 0,
19 #[doc = "1: High trip point selected (V LVD = V LVDH )"]
20 _01 = 1,
21}
22impl From<LVDV_A> for u8 {
23 #[inline(always)]
24 fn from(variant: LVDV_A) -> Self {
25 variant as _
26 }
27}
28#[doc = "Reader of field `LVDV`"]
29pub type LVDV_R = crate::R<u8, LVDV_A>;
30impl LVDV_R {
31 #[doc = r"Get enumerated values variant"]
32 #[inline(always)]
33 pub fn variant(&self) -> crate::Variant<u8, LVDV_A> {
34 use crate::Variant::*;
35 match self.bits {
36 0 => Val(LVDV_A::_00),
37 1 => Val(LVDV_A::_01),
38 i => Res(i),
39 }
40 }
41 #[doc = "Checks if the value of the field is `_00`"]
42 #[inline(always)]
43 pub fn is_00(&self) -> bool {
44 *self == LVDV_A::_00
45 }
46 #[doc = "Checks if the value of the field is `_01`"]
47 #[inline(always)]
48 pub fn is_01(&self) -> bool {
49 *self == LVDV_A::_01
50 }
51}
52#[doc = "Write proxy for field `LVDV`"]
53pub struct LVDV_W<'a> {
54 w: &'a mut W,
55}
56impl<'a> LVDV_W<'a> {
57 #[doc = r"Writes `variant` to the field"]
58 #[inline(always)]
59 pub fn variant(self, variant: LVDV_A) -> &'a mut W {
60 unsafe { self.bits(variant.into()) }
61 }
62 #[doc = "Low trip point selected (V LVD = V LVDL )"]
63 #[inline(always)]
64 pub fn _00(self) -> &'a mut W {
65 self.variant(LVDV_A::_00)
66 }
67 #[doc = "High trip point selected (V LVD = V LVDH )"]
68 #[inline(always)]
69 pub fn _01(self) -> &'a mut W {
70 self.variant(LVDV_A::_01)
71 }
72 #[doc = r"Writes raw bits to the field"]
73 #[inline(always)]
74 pub unsafe fn bits(self, value: u8) -> &'a mut W {
75 self.w.bits = (self.w.bits & !0x03) | ((value as u8) & 0x03);
76 self.w
77 }
78}
79#[doc = "Low-Voltage Detect Reset Enable\n\nValue on reset: 1"]
80#[derive(Clone, Copy, Debug, PartialEq)]
81pub enum LVDRE_A {
82 #[doc = "0: LVDF does not generate hardware resets"]
83 _0 = 0,
84 #[doc = "1: Force an MCU reset when LVDF = 1"]
85 _1 = 1,
86}
87impl From<LVDRE_A> for bool {
88 #[inline(always)]
89 fn from(variant: LVDRE_A) -> Self {
90 variant as u8 != 0
91 }
92}
93#[doc = "Reader of field `LVDRE`"]
94pub type LVDRE_R = crate::R<bool, LVDRE_A>;
95impl LVDRE_R {
96 #[doc = r"Get enumerated values variant"]
97 #[inline(always)]
98 pub fn variant(&self) -> LVDRE_A {
99 match self.bits {
100 false => LVDRE_A::_0,
101 true => LVDRE_A::_1,
102 }
103 }
104 #[doc = "Checks if the value of the field is `_0`"]
105 #[inline(always)]
106 pub fn is_0(&self) -> bool {
107 *self == LVDRE_A::_0
108 }
109 #[doc = "Checks if the value of the field is `_1`"]
110 #[inline(always)]
111 pub fn is_1(&self) -> bool {
112 *self == LVDRE_A::_1
113 }
114}
115#[doc = "Write proxy for field `LVDRE`"]
116pub struct LVDRE_W<'a> {
117 w: &'a mut W,
118}
119impl<'a> LVDRE_W<'a> {
120 #[doc = r"Writes `variant` to the field"]
121 #[inline(always)]
122 pub fn variant(self, variant: LVDRE_A) -> &'a mut W {
123 {
124 self.bit(variant.into())
125 }
126 }
127 #[doc = "LVDF does not generate hardware resets"]
128 #[inline(always)]
129 pub fn _0(self) -> &'a mut W {
130 self.variant(LVDRE_A::_0)
131 }
132 #[doc = "Force an MCU reset when LVDF = 1"]
133 #[inline(always)]
134 pub fn _1(self) -> &'a mut W {
135 self.variant(LVDRE_A::_1)
136 }
137 #[doc = r"Sets the field bit"]
138 #[inline(always)]
139 pub fn set_bit(self) -> &'a mut W {
140 self.bit(true)
141 }
142 #[doc = r"Clears the field bit"]
143 #[inline(always)]
144 pub fn clear_bit(self) -> &'a mut W {
145 self.bit(false)
146 }
147 #[doc = r"Writes raw bits to the field"]
148 #[inline(always)]
149 pub fn bit(self, value: bool) -> &'a mut W {
150 self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u8) & 0x01) << 4);
151 self.w
152 }
153}
154#[doc = "Low-Voltage Detect Interrupt Enable\n\nValue on reset: 0"]
155#[derive(Clone, Copy, Debug, PartialEq)]
156pub enum LVDIE_A {
157 #[doc = "0: Hardware interrupt disabled (use polling)"]
158 _0 = 0,
159 #[doc = "1: Request a hardware interrupt when LVDF = 1"]
160 _1 = 1,
161}
162impl From<LVDIE_A> for bool {
163 #[inline(always)]
164 fn from(variant: LVDIE_A) -> Self {
165 variant as u8 != 0
166 }
167}
168#[doc = "Reader of field `LVDIE`"]
169pub type LVDIE_R = crate::R<bool, LVDIE_A>;
170impl LVDIE_R {
171 #[doc = r"Get enumerated values variant"]
172 #[inline(always)]
173 pub fn variant(&self) -> LVDIE_A {
174 match self.bits {
175 false => LVDIE_A::_0,
176 true => LVDIE_A::_1,
177 }
178 }
179 #[doc = "Checks if the value of the field is `_0`"]
180 #[inline(always)]
181 pub fn is_0(&self) -> bool {
182 *self == LVDIE_A::_0
183 }
184 #[doc = "Checks if the value of the field is `_1`"]
185 #[inline(always)]
186 pub fn is_1(&self) -> bool {
187 *self == LVDIE_A::_1
188 }
189}
190#[doc = "Write proxy for field `LVDIE`"]
191pub struct LVDIE_W<'a> {
192 w: &'a mut W,
193}
194impl<'a> LVDIE_W<'a> {
195 #[doc = r"Writes `variant` to the field"]
196 #[inline(always)]
197 pub fn variant(self, variant: LVDIE_A) -> &'a mut W {
198 {
199 self.bit(variant.into())
200 }
201 }
202 #[doc = "Hardware interrupt disabled (use polling)"]
203 #[inline(always)]
204 pub fn _0(self) -> &'a mut W {
205 self.variant(LVDIE_A::_0)
206 }
207 #[doc = "Request a hardware interrupt when LVDF = 1"]
208 #[inline(always)]
209 pub fn _1(self) -> &'a mut W {
210 self.variant(LVDIE_A::_1)
211 }
212 #[doc = r"Sets the field bit"]
213 #[inline(always)]
214 pub fn set_bit(self) -> &'a mut W {
215 self.bit(true)
216 }
217 #[doc = r"Clears the field bit"]
218 #[inline(always)]
219 pub fn clear_bit(self) -> &'a mut W {
220 self.bit(false)
221 }
222 #[doc = r"Writes raw bits to the field"]
223 #[inline(always)]
224 pub fn bit(self, value: bool) -> &'a mut W {
225 self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u8) & 0x01) << 5);
226 self.w
227 }
228}
229#[doc = "Write proxy for field `LVDACK`"]
230pub struct LVDACK_W<'a> {
231 w: &'a mut W,
232}
233impl<'a> LVDACK_W<'a> {
234 #[doc = r"Sets the field bit"]
235 #[inline(always)]
236 pub fn set_bit(self) -> &'a mut W {
237 self.bit(true)
238 }
239 #[doc = r"Clears the field bit"]
240 #[inline(always)]
241 pub fn clear_bit(self) -> &'a mut W {
242 self.bit(false)
243 }
244 #[doc = r"Writes raw bits to the field"]
245 #[inline(always)]
246 pub fn bit(self, value: bool) -> &'a mut W {
247 self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u8) & 0x01) << 6);
248 self.w
249 }
250}
251#[doc = "Low-Voltage Detect Flag\n\nValue on reset: 0"]
252#[derive(Clone, Copy, Debug, PartialEq)]
253pub enum LVDF_A {
254 #[doc = "0: Low-voltage event not detected"]
255 _0 = 0,
256 #[doc = "1: Low-voltage event detected"]
257 _1 = 1,
258}
259impl From<LVDF_A> for bool {
260 #[inline(always)]
261 fn from(variant: LVDF_A) -> Self {
262 variant as u8 != 0
263 }
264}
265#[doc = "Reader of field `LVDF`"]
266pub type LVDF_R = crate::R<bool, LVDF_A>;
267impl LVDF_R {
268 #[doc = r"Get enumerated values variant"]
269 #[inline(always)]
270 pub fn variant(&self) -> LVDF_A {
271 match self.bits {
272 false => LVDF_A::_0,
273 true => LVDF_A::_1,
274 }
275 }
276 #[doc = "Checks if the value of the field is `_0`"]
277 #[inline(always)]
278 pub fn is_0(&self) -> bool {
279 *self == LVDF_A::_0
280 }
281 #[doc = "Checks if the value of the field is `_1`"]
282 #[inline(always)]
283 pub fn is_1(&self) -> bool {
284 *self == LVDF_A::_1
285 }
286}
287impl R {
288 #[doc = "Bits 0:1 - Low-Voltage Detect Voltage Select"]
289 #[inline(always)]
290 pub fn lvdv(&self) -> LVDV_R {
291 LVDV_R::new((self.bits & 0x03) as u8)
292 }
293 #[doc = "Bit 4 - Low-Voltage Detect Reset Enable"]
294 #[inline(always)]
295 pub fn lvdre(&self) -> LVDRE_R {
296 LVDRE_R::new(((self.bits >> 4) & 0x01) != 0)
297 }
298 #[doc = "Bit 5 - Low-Voltage Detect Interrupt Enable"]
299 #[inline(always)]
300 pub fn lvdie(&self) -> LVDIE_R {
301 LVDIE_R::new(((self.bits >> 5) & 0x01) != 0)
302 }
303 #[doc = "Bit 7 - Low-Voltage Detect Flag"]
304 #[inline(always)]
305 pub fn lvdf(&self) -> LVDF_R {
306 LVDF_R::new(((self.bits >> 7) & 0x01) != 0)
307 }
308}
309impl W {
310 #[doc = "Bits 0:1 - Low-Voltage Detect Voltage Select"]
311 #[inline(always)]
312 pub fn lvdv(&mut self) -> LVDV_W {
313 LVDV_W { w: self }
314 }
315 #[doc = "Bit 4 - Low-Voltage Detect Reset Enable"]
316 #[inline(always)]
317 pub fn lvdre(&mut self) -> LVDRE_W {
318 LVDRE_W { w: self }
319 }
320 #[doc = "Bit 5 - Low-Voltage Detect Interrupt Enable"]
321 #[inline(always)]
322 pub fn lvdie(&mut self) -> LVDIE_W {
323 LVDIE_W { w: self }
324 }
325 #[doc = "Bit 6 - Low-Voltage Detect Acknowledge"]
326 #[inline(always)]
327 pub fn lvdack(&mut self) -> LVDACK_W {
328 LVDACK_W { w: self }
329 }
330}