avr_device/devices/atmega4809/adc0/
ctrle.rs

1#[doc = "Register `CTRLE` reader"]
2pub struct R(crate::R<CTRLE_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRLE_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRLE_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRLE_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRLE` writer"]
17pub struct W(crate::W<CTRLE_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRLE_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<CTRLE_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRLE_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `WINCM` reader - Window Comparator Mode"]
38pub type WINCM_R = crate::FieldReader<u8, WINCM_A>;
39#[doc = "Window Comparator Mode\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum WINCM_A {
43    #[doc = "0: No Window Comparison"]
44    NONE = 0,
45    #[doc = "1: Below Window"]
46    BELOW = 1,
47    #[doc = "2: Above Window"]
48    ABOVE = 2,
49    #[doc = "3: Inside Window"]
50    INSIDE = 3,
51    #[doc = "4: Outside Window"]
52    OUTSIDE = 4,
53}
54impl From<WINCM_A> for u8 {
55    #[inline(always)]
56    fn from(variant: WINCM_A) -> Self {
57        variant as _
58    }
59}
60impl WINCM_R {
61    #[doc = "Get enumerated values variant"]
62    #[inline(always)]
63    pub fn variant(&self) -> Option<WINCM_A> {
64        match self.bits {
65            0 => Some(WINCM_A::NONE),
66            1 => Some(WINCM_A::BELOW),
67            2 => Some(WINCM_A::ABOVE),
68            3 => Some(WINCM_A::INSIDE),
69            4 => Some(WINCM_A::OUTSIDE),
70            _ => None,
71        }
72    }
73    #[doc = "Checks if the value of the field is `NONE`"]
74    #[inline(always)]
75    pub fn is_none(&self) -> bool {
76        *self == WINCM_A::NONE
77    }
78    #[doc = "Checks if the value of the field is `BELOW`"]
79    #[inline(always)]
80    pub fn is_below(&self) -> bool {
81        *self == WINCM_A::BELOW
82    }
83    #[doc = "Checks if the value of the field is `ABOVE`"]
84    #[inline(always)]
85    pub fn is_above(&self) -> bool {
86        *self == WINCM_A::ABOVE
87    }
88    #[doc = "Checks if the value of the field is `INSIDE`"]
89    #[inline(always)]
90    pub fn is_inside(&self) -> bool {
91        *self == WINCM_A::INSIDE
92    }
93    #[doc = "Checks if the value of the field is `OUTSIDE`"]
94    #[inline(always)]
95    pub fn is_outside(&self) -> bool {
96        *self == WINCM_A::OUTSIDE
97    }
98}
99#[doc = "Field `WINCM` writer - Window Comparator Mode"]
100pub type WINCM_W<'a, const O: u8> = crate::FieldWriter<'a, u8, CTRLE_SPEC, u8, WINCM_A, 3, O>;
101impl<'a, const O: u8> WINCM_W<'a, O> {
102    #[doc = "No Window Comparison"]
103    #[inline(always)]
104    pub fn none(self) -> &'a mut W {
105        self.variant(WINCM_A::NONE)
106    }
107    #[doc = "Below Window"]
108    #[inline(always)]
109    pub fn below(self) -> &'a mut W {
110        self.variant(WINCM_A::BELOW)
111    }
112    #[doc = "Above Window"]
113    #[inline(always)]
114    pub fn above(self) -> &'a mut W {
115        self.variant(WINCM_A::ABOVE)
116    }
117    #[doc = "Inside Window"]
118    #[inline(always)]
119    pub fn inside(self) -> &'a mut W {
120        self.variant(WINCM_A::INSIDE)
121    }
122    #[doc = "Outside Window"]
123    #[inline(always)]
124    pub fn outside(self) -> &'a mut W {
125        self.variant(WINCM_A::OUTSIDE)
126    }
127}
128impl R {
129    #[doc = "Bits 0:2 - Window Comparator Mode"]
130    #[inline(always)]
131    pub fn wincm(&self) -> WINCM_R {
132        WINCM_R::new(self.bits & 7)
133    }
134}
135impl W {
136    #[doc = "Bits 0:2 - Window Comparator Mode"]
137    #[inline(always)]
138    #[must_use]
139    pub fn wincm(&mut self) -> WINCM_W<0> {
140        WINCM_W::new(self)
141    }
142    #[doc = "Writes raw bits to the register."]
143    #[inline(always)]
144    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
145        self.0.bits(bits);
146        self
147    }
148}
149#[doc = "Control E\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 [ctrle](index.html) module"]
150pub struct CTRLE_SPEC;
151impl crate::RegisterSpec for CTRLE_SPEC {
152    type Ux = u8;
153}
154#[doc = "`read()` method returns [ctrle::R](R) reader structure"]
155impl crate::Readable for CTRLE_SPEC {
156    type Reader = R;
157}
158#[doc = "`write(|w| ..)` method takes [ctrle::W](W) writer structure"]
159impl crate::Writable for CTRLE_SPEC {
160    type Writer = W;
161    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
162    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
163}
164#[doc = "`reset()` method sets CTRLE to value 0"]
165impl crate::Resettable for CTRLE_SPEC {
166    const RESET_VALUE: Self::Ux = 0;
167}