avr_device/devices/atmega4809/bod/
intctrl.rs

1#[doc = "Register `INTCTRL` reader"]
2pub struct R(crate::R<INTCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<INTCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<INTCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<INTCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `INTCTRL` writer"]
17pub struct W(crate::W<INTCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<INTCTRL_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<INTCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<INTCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `VLMIE` reader - voltage level monitor interrrupt enable"]
38pub type VLMIE_R = crate::BitReader<bool>;
39#[doc = "Field `VLMIE` writer - voltage level monitor interrrupt enable"]
40pub type VLMIE_W<'a, const O: u8> = crate::BitWriter<'a, u8, INTCTRL_SPEC, bool, O>;
41#[doc = "Field `VLMCFG` reader - Configuration"]
42pub type VLMCFG_R = crate::FieldReader<u8, VLMCFG_A>;
43#[doc = "Configuration\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum VLMCFG_A {
47    #[doc = "0: Interrupt when supply goes below VLM level"]
48    BELOW = 0,
49    #[doc = "1: Interrupt when supply goes above VLM level"]
50    ABOVE = 1,
51    #[doc = "2: Interrupt when supply crosses VLM level"]
52    CROSS = 2,
53}
54impl From<VLMCFG_A> for u8 {
55    #[inline(always)]
56    fn from(variant: VLMCFG_A) -> Self {
57        variant as _
58    }
59}
60impl VLMCFG_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<VLMCFG_A> {
64        match self.bits {
65            0 => Some(VLMCFG_A::BELOW),
66            1 => Some(VLMCFG_A::ABOVE),
67            2 => Some(VLMCFG_A::CROSS),
68            _ => None,
69        }
70    }
71    #[doc = "Checks if the value of the field is `BELOW`"]
72    #[inline(always)]
73    pub fn is_below(&self) -> bool {
74        *self == VLMCFG_A::BELOW
75    }
76    #[doc = "Checks if the value of the field is `ABOVE`"]
77    #[inline(always)]
78    pub fn is_above(&self) -> bool {
79        *self == VLMCFG_A::ABOVE
80    }
81    #[doc = "Checks if the value of the field is `CROSS`"]
82    #[inline(always)]
83    pub fn is_cross(&self) -> bool {
84        *self == VLMCFG_A::CROSS
85    }
86}
87#[doc = "Field `VLMCFG` writer - Configuration"]
88pub type VLMCFG_W<'a, const O: u8> = crate::FieldWriter<'a, u8, INTCTRL_SPEC, u8, VLMCFG_A, 2, O>;
89impl<'a, const O: u8> VLMCFG_W<'a, O> {
90    #[doc = "Interrupt when supply goes below VLM level"]
91    #[inline(always)]
92    pub fn below(self) -> &'a mut W {
93        self.variant(VLMCFG_A::BELOW)
94    }
95    #[doc = "Interrupt when supply goes above VLM level"]
96    #[inline(always)]
97    pub fn above(self) -> &'a mut W {
98        self.variant(VLMCFG_A::ABOVE)
99    }
100    #[doc = "Interrupt when supply crosses VLM level"]
101    #[inline(always)]
102    pub fn cross(self) -> &'a mut W {
103        self.variant(VLMCFG_A::CROSS)
104    }
105}
106impl R {
107    #[doc = "Bit 0 - voltage level monitor interrrupt enable"]
108    #[inline(always)]
109    pub fn vlmie(&self) -> VLMIE_R {
110        VLMIE_R::new((self.bits & 1) != 0)
111    }
112    #[doc = "Bits 1:2 - Configuration"]
113    #[inline(always)]
114    pub fn vlmcfg(&self) -> VLMCFG_R {
115        VLMCFG_R::new((self.bits >> 1) & 3)
116    }
117}
118impl W {
119    #[doc = "Bit 0 - voltage level monitor interrrupt enable"]
120    #[inline(always)]
121    #[must_use]
122    pub fn vlmie(&mut self) -> VLMIE_W<0> {
123        VLMIE_W::new(self)
124    }
125    #[doc = "Bits 1:2 - Configuration"]
126    #[inline(always)]
127    #[must_use]
128    pub fn vlmcfg(&mut self) -> VLMCFG_W<1> {
129        VLMCFG_W::new(self)
130    }
131    #[doc = "Writes raw bits to the register."]
132    #[inline(always)]
133    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
134        self.0.bits(bits);
135        self
136    }
137}
138#[doc = "Voltage level monitor interrupt Control\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 [intctrl](index.html) module"]
139pub struct INTCTRL_SPEC;
140impl crate::RegisterSpec for INTCTRL_SPEC {
141    type Ux = u8;
142}
143#[doc = "`read()` method returns [intctrl::R](R) reader structure"]
144impl crate::Readable for INTCTRL_SPEC {
145    type Reader = R;
146}
147#[doc = "`write(|w| ..)` method takes [intctrl::W](W) writer structure"]
148impl crate::Writable for INTCTRL_SPEC {
149    type Writer = W;
150    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
151    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
152}
153#[doc = "`reset()` method sets INTCTRL to value 0"]
154impl crate::Resettable for INTCTRL_SPEC {
155    const RESET_VALUE: Self::Ux = 0;
156}