avr_device/devices/attiny85/ac/
acsr.rs

1#[doc = "Register `ACSR` reader"]
2pub struct R(crate::R<ACSR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ACSR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ACSR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ACSR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ACSR` writer"]
17pub struct W(crate::W<ACSR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ACSR_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<ACSR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ACSR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ACIS` reader - Analog Comparator Interrupt Mode Select"]
38pub type ACIS_R = crate::FieldReader<u8, ACIS_A>;
39#[doc = "Analog Comparator Interrupt Mode Select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum ACIS_A {
43    #[doc = "0: Interrupt on Toggle"]
44    ON_TOGGLE = 0,
45    #[doc = "2: Interrupt on Falling Edge"]
46    ON_FALLING_EDGE = 2,
47    #[doc = "3: Interrupt on Rising Edge"]
48    ON_RISING_EDGE = 3,
49}
50impl From<ACIS_A> for u8 {
51    #[inline(always)]
52    fn from(variant: ACIS_A) -> Self {
53        variant as _
54    }
55}
56impl ACIS_R {
57    #[doc = "Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> Option<ACIS_A> {
60        match self.bits {
61            0 => Some(ACIS_A::ON_TOGGLE),
62            2 => Some(ACIS_A::ON_FALLING_EDGE),
63            3 => Some(ACIS_A::ON_RISING_EDGE),
64            _ => None,
65        }
66    }
67    #[doc = "Checks if the value of the field is `ON_TOGGLE`"]
68    #[inline(always)]
69    pub fn is_on_toggle(&self) -> bool {
70        *self == ACIS_A::ON_TOGGLE
71    }
72    #[doc = "Checks if the value of the field is `ON_FALLING_EDGE`"]
73    #[inline(always)]
74    pub fn is_on_falling_edge(&self) -> bool {
75        *self == ACIS_A::ON_FALLING_EDGE
76    }
77    #[doc = "Checks if the value of the field is `ON_RISING_EDGE`"]
78    #[inline(always)]
79    pub fn is_on_rising_edge(&self) -> bool {
80        *self == ACIS_A::ON_RISING_EDGE
81    }
82}
83#[doc = "Field `ACIS` writer - Analog Comparator Interrupt Mode Select"]
84pub type ACIS_W<'a, const O: u8> = crate::FieldWriter<'a, u8, ACSR_SPEC, u8, ACIS_A, 2, O>;
85impl<'a, const O: u8> ACIS_W<'a, O> {
86    #[doc = "Interrupt on Toggle"]
87    #[inline(always)]
88    pub fn on_toggle(self) -> &'a mut W {
89        self.variant(ACIS_A::ON_TOGGLE)
90    }
91    #[doc = "Interrupt on Falling Edge"]
92    #[inline(always)]
93    pub fn on_falling_edge(self) -> &'a mut W {
94        self.variant(ACIS_A::ON_FALLING_EDGE)
95    }
96    #[doc = "Interrupt on Rising Edge"]
97    #[inline(always)]
98    pub fn on_rising_edge(self) -> &'a mut W {
99        self.variant(ACIS_A::ON_RISING_EDGE)
100    }
101}
102#[doc = "Field `ACIE` reader - Analog Comparator Interrupt Enable"]
103pub type ACIE_R = crate::BitReader<bool>;
104#[doc = "Field `ACIE` writer - Analog Comparator Interrupt Enable"]
105pub type ACIE_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
106#[doc = "Field `ACI` reader - Analog Comparator Interrupt Flag"]
107pub type ACI_R = crate::BitReader<bool>;
108#[doc = "Field `ACI` writer - Analog Comparator Interrupt Flag"]
109pub type ACI_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
110#[doc = "Field `ACO` reader - Analog Compare Output"]
111pub type ACO_R = crate::BitReader<bool>;
112#[doc = "Field `ACBG` reader - Analog Comparator Bandgap Select"]
113pub type ACBG_R = crate::BitReader<bool>;
114#[doc = "Field `ACBG` writer - Analog Comparator Bandgap Select"]
115pub type ACBG_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
116#[doc = "Field `ACD` reader - Analog Comparator Disable"]
117pub type ACD_R = crate::BitReader<bool>;
118#[doc = "Field `ACD` writer - Analog Comparator Disable"]
119pub type ACD_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
120impl R {
121    #[doc = "Bits 0:1 - Analog Comparator Interrupt Mode Select"]
122    #[inline(always)]
123    pub fn acis(&self) -> ACIS_R {
124        ACIS_R::new(self.bits & 3)
125    }
126    #[doc = "Bit 3 - Analog Comparator Interrupt Enable"]
127    #[inline(always)]
128    pub fn acie(&self) -> ACIE_R {
129        ACIE_R::new(((self.bits >> 3) & 1) != 0)
130    }
131    #[doc = "Bit 4 - Analog Comparator Interrupt Flag"]
132    #[inline(always)]
133    pub fn aci(&self) -> ACI_R {
134        ACI_R::new(((self.bits >> 4) & 1) != 0)
135    }
136    #[doc = "Bit 5 - Analog Compare Output"]
137    #[inline(always)]
138    pub fn aco(&self) -> ACO_R {
139        ACO_R::new(((self.bits >> 5) & 1) != 0)
140    }
141    #[doc = "Bit 6 - Analog Comparator Bandgap Select"]
142    #[inline(always)]
143    pub fn acbg(&self) -> ACBG_R {
144        ACBG_R::new(((self.bits >> 6) & 1) != 0)
145    }
146    #[doc = "Bit 7 - Analog Comparator Disable"]
147    #[inline(always)]
148    pub fn acd(&self) -> ACD_R {
149        ACD_R::new(((self.bits >> 7) & 1) != 0)
150    }
151}
152impl W {
153    #[doc = "Bits 0:1 - Analog Comparator Interrupt Mode Select"]
154    #[inline(always)]
155    #[must_use]
156    pub fn acis(&mut self) -> ACIS_W<0> {
157        ACIS_W::new(self)
158    }
159    #[doc = "Bit 3 - Analog Comparator Interrupt Enable"]
160    #[inline(always)]
161    #[must_use]
162    pub fn acie(&mut self) -> ACIE_W<3> {
163        ACIE_W::new(self)
164    }
165    #[doc = "Bit 4 - Analog Comparator Interrupt Flag"]
166    #[inline(always)]
167    #[must_use]
168    pub fn aci(&mut self) -> ACI_W<4> {
169        ACI_W::new(self)
170    }
171    #[doc = "Bit 6 - Analog Comparator Bandgap Select"]
172    #[inline(always)]
173    #[must_use]
174    pub fn acbg(&mut self) -> ACBG_W<6> {
175        ACBG_W::new(self)
176    }
177    #[doc = "Bit 7 - Analog Comparator Disable"]
178    #[inline(always)]
179    #[must_use]
180    pub fn acd(&mut self) -> ACD_W<7> {
181        ACD_W::new(self)
182    }
183    #[doc = "Writes raw bits to the register."]
184    #[inline(always)]
185    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
186        self.0.bits(bits);
187        self
188    }
189}
190#[doc = "Analog Comparator Control And Status 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 [acsr](index.html) module"]
191pub struct ACSR_SPEC;
192impl crate::RegisterSpec for ACSR_SPEC {
193    type Ux = u8;
194}
195#[doc = "`read()` method returns [acsr::R](R) reader structure"]
196impl crate::Readable for ACSR_SPEC {
197    type Reader = R;
198}
199#[doc = "`write(|w| ..)` method takes [acsr::W](W) writer structure"]
200impl crate::Writable for ACSR_SPEC {
201    type Writer = W;
202    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
203    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
204}
205#[doc = "`reset()` method sets ACSR to value 0"]
206impl crate::Resettable for ACSR_SPEC {
207    const RESET_VALUE: Self::Ux = 0;
208}