1#[doc = "Register `LVD2CMPCR` reader"]
2pub struct R(crate::R<LVD2CMPCR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<LVD2CMPCR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<LVD2CMPCR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<LVD2CMPCR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `LVD2CMPCR` writer"]
17pub struct W(crate::W<LVD2CMPCR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<LVD2CMPCR_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<LVD2CMPCR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<LVD2CMPCR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `LVD2LVL` reader - Voltage Detection 2 Level Select (Standard voltage during drop in voltage)"]
38pub type LVD2LVL_R = crate::FieldReader<u8, LVD2LVL_A>;
39#[doc = "Voltage Detection 2 Level Select (Standard voltage during drop in voltage)\n\nValue on reset: 7"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum LVD2LVL_A {
43 #[doc = "5: 2.99 V (Vdet2_5)"]
44 _101 = 5,
45 #[doc = "6: 2.92 V (Vdet2_6)"]
46 _110 = 6,
47 #[doc = "7: 2.85 V (Vdet2_7)"]
48 _111 = 7,
49}
50impl From<LVD2LVL_A> for u8 {
51 #[inline(always)]
52 fn from(variant: LVD2LVL_A) -> Self {
53 variant as _
54 }
55}
56impl LVD2LVL_R {
57 #[doc = "Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> Option<LVD2LVL_A> {
60 match self.bits {
61 5 => Some(LVD2LVL_A::_101),
62 6 => Some(LVD2LVL_A::_110),
63 7 => Some(LVD2LVL_A::_111),
64 _ => None,
65 }
66 }
67 #[doc = "Checks if the value of the field is `_101`"]
68 #[inline(always)]
69 pub fn is_101(&self) -> bool {
70 *self == LVD2LVL_A::_101
71 }
72 #[doc = "Checks if the value of the field is `_110`"]
73 #[inline(always)]
74 pub fn is_110(&self) -> bool {
75 *self == LVD2LVL_A::_110
76 }
77 #[doc = "Checks if the value of the field is `_111`"]
78 #[inline(always)]
79 pub fn is_111(&self) -> bool {
80 *self == LVD2LVL_A::_111
81 }
82}
83#[doc = "Field `LVD2LVL` writer - Voltage Detection 2 Level Select (Standard voltage during drop in voltage)"]
84pub type LVD2LVL_W<'a, const O: u8> =
85 crate::FieldWriter<'a, u8, LVD2CMPCR_SPEC, u8, LVD2LVL_A, 3, O>;
86impl<'a, const O: u8> LVD2LVL_W<'a, O> {
87 #[doc = "2.99 V (Vdet2_5)"]
88 #[inline(always)]
89 pub fn _101(self) -> &'a mut W {
90 self.variant(LVD2LVL_A::_101)
91 }
92 #[doc = "2.92 V (Vdet2_6)"]
93 #[inline(always)]
94 pub fn _110(self) -> &'a mut W {
95 self.variant(LVD2LVL_A::_110)
96 }
97 #[doc = "2.85 V (Vdet2_7)"]
98 #[inline(always)]
99 pub fn _111(self) -> &'a mut W {
100 self.variant(LVD2LVL_A::_111)
101 }
102}
103#[doc = "Field `LVD2E` reader - Voltage Detection 2 Enable"]
104pub type LVD2E_R = crate::BitReader<LVD2E_A>;
105#[doc = "Voltage Detection 2 Enable\n\nValue on reset: 0"]
106#[derive(Clone, Copy, Debug, PartialEq, Eq)]
107pub enum LVD2E_A {
108 #[doc = "0: Voltage detection 2 circuit disabled"]
109 _0 = 0,
110 #[doc = "1: Voltage detection 2 circuit enabled"]
111 _1 = 1,
112}
113impl From<LVD2E_A> for bool {
114 #[inline(always)]
115 fn from(variant: LVD2E_A) -> Self {
116 variant as u8 != 0
117 }
118}
119impl LVD2E_R {
120 #[doc = "Get enumerated values variant"]
121 #[inline(always)]
122 pub fn variant(&self) -> LVD2E_A {
123 match self.bits {
124 false => LVD2E_A::_0,
125 true => LVD2E_A::_1,
126 }
127 }
128 #[doc = "Checks if the value of the field is `_0`"]
129 #[inline(always)]
130 pub fn is_0(&self) -> bool {
131 *self == LVD2E_A::_0
132 }
133 #[doc = "Checks if the value of the field is `_1`"]
134 #[inline(always)]
135 pub fn is_1(&self) -> bool {
136 *self == LVD2E_A::_1
137 }
138}
139#[doc = "Field `LVD2E` writer - Voltage Detection 2 Enable"]
140pub type LVD2E_W<'a, const O: u8> = crate::BitWriter<'a, u8, LVD2CMPCR_SPEC, LVD2E_A, O>;
141impl<'a, const O: u8> LVD2E_W<'a, O> {
142 #[doc = "Voltage detection 2 circuit disabled"]
143 #[inline(always)]
144 pub fn _0(self) -> &'a mut W {
145 self.variant(LVD2E_A::_0)
146 }
147 #[doc = "Voltage detection 2 circuit enabled"]
148 #[inline(always)]
149 pub fn _1(self) -> &'a mut W {
150 self.variant(LVD2E_A::_1)
151 }
152}
153impl R {
154 #[doc = "Bits 0:2 - Voltage Detection 2 Level Select (Standard voltage during drop in voltage)"]
155 #[inline(always)]
156 pub fn lvd2lvl(&self) -> LVD2LVL_R {
157 LVD2LVL_R::new(self.bits & 7)
158 }
159 #[doc = "Bit 7 - Voltage Detection 2 Enable"]
160 #[inline(always)]
161 pub fn lvd2e(&self) -> LVD2E_R {
162 LVD2E_R::new(((self.bits >> 7) & 1) != 0)
163 }
164}
165impl W {
166 #[doc = "Bits 0:2 - Voltage Detection 2 Level Select (Standard voltage during drop in voltage)"]
167 #[inline(always)]
168 #[must_use]
169 pub fn lvd2lvl(&mut self) -> LVD2LVL_W<0> {
170 LVD2LVL_W::new(self)
171 }
172 #[doc = "Bit 7 - Voltage Detection 2 Enable"]
173 #[inline(always)]
174 #[must_use]
175 pub fn lvd2e(&mut self) -> LVD2E_W<7> {
176 LVD2E_W::new(self)
177 }
178 #[doc = "Writes raw bits to the register."]
179 #[inline(always)]
180 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
181 self.0.bits(bits);
182 self
183 }
184}
185#[doc = "Voltage Monitoring 2 Comparator 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 [lvd2cmpcr](index.html) module"]
186pub struct LVD2CMPCR_SPEC;
187impl crate::RegisterSpec for LVD2CMPCR_SPEC {
188 type Ux = u8;
189}
190#[doc = "`read()` method returns [lvd2cmpcr::R](R) reader structure"]
191impl crate::Readable for LVD2CMPCR_SPEC {
192 type Reader = R;
193}
194#[doc = "`write(|w| ..)` method takes [lvd2cmpcr::W](W) writer structure"]
195impl crate::Writable for LVD2CMPCR_SPEC {
196 type Writer = W;
197 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
198 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
199}
200#[doc = "`reset()` method sets LVD2CMPCR to value 0x07"]
201impl crate::Resettable for LVD2CMPCR_SPEC {
202 const RESET_VALUE: Self::Ux = 0x07;
203}