avr_device/devices/atmega328p/ac/
acsr.rs1#[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 `ACIC` reader - Analog Comparator Input Capture Enable"]
103pub type ACIC_R = crate::BitReader<bool>;
104#[doc = "Field `ACIC` writer - Analog Comparator Input Capture Enable"]
105pub type ACIC_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
106#[doc = "Field `ACIE` reader - Analog Comparator Interrupt Enable"]
107pub type ACIE_R = crate::BitReader<bool>;
108#[doc = "Field `ACIE` writer - Analog Comparator Interrupt Enable"]
109pub type ACIE_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
110#[doc = "Field `ACI` reader - Analog Comparator Interrupt Flag"]
111pub type ACI_R = crate::BitReader<bool>;
112#[doc = "Field `ACI` writer - Analog Comparator Interrupt Flag"]
113pub type ACI_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
114#[doc = "Field `ACO` reader - Analog Compare Output"]
115pub type ACO_R = crate::BitReader<bool>;
116#[doc = "Field `ACBG` reader - Analog Comparator Bandgap Select"]
117pub type ACBG_R = crate::BitReader<bool>;
118#[doc = "Field `ACBG` writer - Analog Comparator Bandgap Select"]
119pub type ACBG_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
120#[doc = "Field `ACD` reader - Analog Comparator Disable"]
121pub type ACD_R = crate::BitReader<bool>;
122#[doc = "Field `ACD` writer - Analog Comparator Disable"]
123pub type ACD_W<'a, const O: u8> = crate::BitWriter<'a, u8, ACSR_SPEC, bool, O>;
124impl R {
125 #[doc = "Bits 0:1 - Analog Comparator Interrupt Mode Select"]
126 #[inline(always)]
127 pub fn acis(&self) -> ACIS_R {
128 ACIS_R::new(self.bits & 3)
129 }
130 #[doc = "Bit 2 - Analog Comparator Input Capture Enable"]
131 #[inline(always)]
132 pub fn acic(&self) -> ACIC_R {
133 ACIC_R::new(((self.bits >> 2) & 1) != 0)
134 }
135 #[doc = "Bit 3 - Analog Comparator Interrupt Enable"]
136 #[inline(always)]
137 pub fn acie(&self) -> ACIE_R {
138 ACIE_R::new(((self.bits >> 3) & 1) != 0)
139 }
140 #[doc = "Bit 4 - Analog Comparator Interrupt Flag"]
141 #[inline(always)]
142 pub fn aci(&self) -> ACI_R {
143 ACI_R::new(((self.bits >> 4) & 1) != 0)
144 }
145 #[doc = "Bit 5 - Analog Compare Output"]
146 #[inline(always)]
147 pub fn aco(&self) -> ACO_R {
148 ACO_R::new(((self.bits >> 5) & 1) != 0)
149 }
150 #[doc = "Bit 6 - Analog Comparator Bandgap Select"]
151 #[inline(always)]
152 pub fn acbg(&self) -> ACBG_R {
153 ACBG_R::new(((self.bits >> 6) & 1) != 0)
154 }
155 #[doc = "Bit 7 - Analog Comparator Disable"]
156 #[inline(always)]
157 pub fn acd(&self) -> ACD_R {
158 ACD_R::new(((self.bits >> 7) & 1) != 0)
159 }
160}
161impl W {
162 #[doc = "Bits 0:1 - Analog Comparator Interrupt Mode Select"]
163 #[inline(always)]
164 #[must_use]
165 pub fn acis(&mut self) -> ACIS_W<0> {
166 ACIS_W::new(self)
167 }
168 #[doc = "Bit 2 - Analog Comparator Input Capture Enable"]
169 #[inline(always)]
170 #[must_use]
171 pub fn acic(&mut self) -> ACIC_W<2> {
172 ACIC_W::new(self)
173 }
174 #[doc = "Bit 3 - Analog Comparator Interrupt Enable"]
175 #[inline(always)]
176 #[must_use]
177 pub fn acie(&mut self) -> ACIE_W<3> {
178 ACIE_W::new(self)
179 }
180 #[doc = "Bit 4 - Analog Comparator Interrupt Flag"]
181 #[inline(always)]
182 #[must_use]
183 pub fn aci(&mut self) -> ACI_W<4> {
184 ACI_W::new(self)
185 }
186 #[doc = "Bit 6 - Analog Comparator Bandgap Select"]
187 #[inline(always)]
188 #[must_use]
189 pub fn acbg(&mut self) -> ACBG_W<6> {
190 ACBG_W::new(self)
191 }
192 #[doc = "Bit 7 - Analog Comparator Disable"]
193 #[inline(always)]
194 #[must_use]
195 pub fn acd(&mut self) -> ACD_W<7> {
196 ACD_W::new(self)
197 }
198 #[doc = "Writes raw bits to the register."]
199 #[inline(always)]
200 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
201 self.0.bits(bits);
202 self
203 }
204}
205#[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"]
206pub struct ACSR_SPEC;
207impl crate::RegisterSpec for ACSR_SPEC {
208 type Ux = u8;
209}
210#[doc = "`read()` method returns [acsr::R](R) reader structure"]
211impl crate::Readable for ACSR_SPEC {
212 type Reader = R;
213}
214#[doc = "`write(|w| ..)` method takes [acsr::W](W) writer structure"]
215impl crate::Writable for ACSR_SPEC {
216 type Writer = W;
217 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
218 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
219}
220#[doc = "`reset()` method sets ACSR to value 0"]
221impl crate::Resettable for ACSR_SPEC {
222 const RESET_VALUE: Self::Ux = 0;
223}