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