atsaml21e17b/tc0/count16/
evctrl.rs1#[doc = "Register `EVCTRL` reader"]
2pub struct R(crate::R<EVCTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<EVCTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<EVCTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<EVCTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `EVCTRL` writer"]
17pub struct W(crate::W<EVCTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<EVCTRL_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<EVCTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<EVCTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `EVACT` reader - Event Action"]
38pub type EVACT_R = crate::FieldReader<u8, EVACTSELECT_A>;
39#[doc = "Event Action\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum EVACTSELECT_A {
43 #[doc = "0: Event action disabled"]
44 OFF = 0,
45 #[doc = "1: Start, restart or retrigger TC on event"]
46 RETRIGGER = 1,
47 #[doc = "2: Count on event"]
48 COUNT = 2,
49 #[doc = "3: Start TC on event"]
50 START = 3,
51 #[doc = "4: Time stamp capture"]
52 STAMP = 4,
53 #[doc = "5: Period captured in CC0, pulse width in CC1"]
54 PPW = 5,
55 #[doc = "6: Period captured in CC1, pulse width in CC0"]
56 PWP = 6,
57 #[doc = "7: Pulse width capture"]
58 PW = 7,
59}
60impl From<EVACTSELECT_A> for u8 {
61 #[inline(always)]
62 fn from(variant: EVACTSELECT_A) -> Self {
63 variant as _
64 }
65}
66impl EVACT_R {
67 #[doc = "Get enumerated values variant"]
68 #[inline(always)]
69 pub fn variant(&self) -> EVACTSELECT_A {
70 match self.bits {
71 0 => EVACTSELECT_A::OFF,
72 1 => EVACTSELECT_A::RETRIGGER,
73 2 => EVACTSELECT_A::COUNT,
74 3 => EVACTSELECT_A::START,
75 4 => EVACTSELECT_A::STAMP,
76 5 => EVACTSELECT_A::PPW,
77 6 => EVACTSELECT_A::PWP,
78 7 => EVACTSELECT_A::PW,
79 _ => unreachable!(),
80 }
81 }
82 #[doc = "Checks if the value of the field is `OFF`"]
83 #[inline(always)]
84 pub fn is_off(&self) -> bool {
85 *self == EVACTSELECT_A::OFF
86 }
87 #[doc = "Checks if the value of the field is `RETRIGGER`"]
88 #[inline(always)]
89 pub fn is_retrigger(&self) -> bool {
90 *self == EVACTSELECT_A::RETRIGGER
91 }
92 #[doc = "Checks if the value of the field is `COUNT`"]
93 #[inline(always)]
94 pub fn is_count(&self) -> bool {
95 *self == EVACTSELECT_A::COUNT
96 }
97 #[doc = "Checks if the value of the field is `START`"]
98 #[inline(always)]
99 pub fn is_start(&self) -> bool {
100 *self == EVACTSELECT_A::START
101 }
102 #[doc = "Checks if the value of the field is `STAMP`"]
103 #[inline(always)]
104 pub fn is_stamp(&self) -> bool {
105 *self == EVACTSELECT_A::STAMP
106 }
107 #[doc = "Checks if the value of the field is `PPW`"]
108 #[inline(always)]
109 pub fn is_ppw(&self) -> bool {
110 *self == EVACTSELECT_A::PPW
111 }
112 #[doc = "Checks if the value of the field is `PWP`"]
113 #[inline(always)]
114 pub fn is_pwp(&self) -> bool {
115 *self == EVACTSELECT_A::PWP
116 }
117 #[doc = "Checks if the value of the field is `PW`"]
118 #[inline(always)]
119 pub fn is_pw(&self) -> bool {
120 *self == EVACTSELECT_A::PW
121 }
122}
123#[doc = "Field `EVACT` writer - Event Action"]
124pub type EVACT_W<'a, const O: u8> =
125 crate::FieldWriterSafe<'a, u16, EVCTRL_SPEC, u8, EVACTSELECT_A, 3, O>;
126impl<'a, const O: u8> EVACT_W<'a, O> {
127 #[doc = "Event action disabled"]
128 #[inline(always)]
129 pub fn off(self) -> &'a mut W {
130 self.variant(EVACTSELECT_A::OFF)
131 }
132 #[doc = "Start, restart or retrigger TC on event"]
133 #[inline(always)]
134 pub fn retrigger(self) -> &'a mut W {
135 self.variant(EVACTSELECT_A::RETRIGGER)
136 }
137 #[doc = "Count on event"]
138 #[inline(always)]
139 pub fn count(self) -> &'a mut W {
140 self.variant(EVACTSELECT_A::COUNT)
141 }
142 #[doc = "Start TC on event"]
143 #[inline(always)]
144 pub fn start(self) -> &'a mut W {
145 self.variant(EVACTSELECT_A::START)
146 }
147 #[doc = "Time stamp capture"]
148 #[inline(always)]
149 pub fn stamp(self) -> &'a mut W {
150 self.variant(EVACTSELECT_A::STAMP)
151 }
152 #[doc = "Period captured in CC0, pulse width in CC1"]
153 #[inline(always)]
154 pub fn ppw(self) -> &'a mut W {
155 self.variant(EVACTSELECT_A::PPW)
156 }
157 #[doc = "Period captured in CC1, pulse width in CC0"]
158 #[inline(always)]
159 pub fn pwp(self) -> &'a mut W {
160 self.variant(EVACTSELECT_A::PWP)
161 }
162 #[doc = "Pulse width capture"]
163 #[inline(always)]
164 pub fn pw(self) -> &'a mut W {
165 self.variant(EVACTSELECT_A::PW)
166 }
167}
168#[doc = "Field `TCINV` reader - TC Event Input Polarity"]
169pub type TCINV_R = crate::BitReader<bool>;
170#[doc = "Field `TCINV` writer - TC Event Input Polarity"]
171pub type TCINV_W<'a, const O: u8> = crate::BitWriter<'a, u16, EVCTRL_SPEC, bool, O>;
172#[doc = "Field `TCEI` reader - TC Event Enable"]
173pub type TCEI_R = crate::BitReader<bool>;
174#[doc = "Field `TCEI` writer - TC Event Enable"]
175pub type TCEI_W<'a, const O: u8> = crate::BitWriter<'a, u16, EVCTRL_SPEC, bool, O>;
176#[doc = "Field `OVFEO` reader - Event Output Enable"]
177pub type OVFEO_R = crate::BitReader<bool>;
178#[doc = "Field `OVFEO` writer - Event Output Enable"]
179pub type OVFEO_W<'a, const O: u8> = crate::BitWriter<'a, u16, EVCTRL_SPEC, bool, O>;
180#[doc = "Field `MCEO0` reader - MC Event Output Enable 0"]
181pub type MCEO0_R = crate::BitReader<bool>;
182#[doc = "Field `MCEO0` writer - MC Event Output Enable 0"]
183pub type MCEO0_W<'a, const O: u8> = crate::BitWriter<'a, u16, EVCTRL_SPEC, bool, O>;
184#[doc = "Field `MCEO1` reader - MC Event Output Enable 1"]
185pub type MCEO1_R = crate::BitReader<bool>;
186#[doc = "Field `MCEO1` writer - MC Event Output Enable 1"]
187pub type MCEO1_W<'a, const O: u8> = crate::BitWriter<'a, u16, EVCTRL_SPEC, bool, O>;
188impl R {
189 #[doc = "Bits 0:2 - Event Action"]
190 #[inline(always)]
191 pub fn evact(&self) -> EVACT_R {
192 EVACT_R::new((self.bits & 7) as u8)
193 }
194 #[doc = "Bit 4 - TC Event Input Polarity"]
195 #[inline(always)]
196 pub fn tcinv(&self) -> TCINV_R {
197 TCINV_R::new(((self.bits >> 4) & 1) != 0)
198 }
199 #[doc = "Bit 5 - TC Event Enable"]
200 #[inline(always)]
201 pub fn tcei(&self) -> TCEI_R {
202 TCEI_R::new(((self.bits >> 5) & 1) != 0)
203 }
204 #[doc = "Bit 8 - Event Output Enable"]
205 #[inline(always)]
206 pub fn ovfeo(&self) -> OVFEO_R {
207 OVFEO_R::new(((self.bits >> 8) & 1) != 0)
208 }
209 #[doc = "Bit 12 - MC Event Output Enable 0"]
210 #[inline(always)]
211 pub fn mceo0(&self) -> MCEO0_R {
212 MCEO0_R::new(((self.bits >> 12) & 1) != 0)
213 }
214 #[doc = "Bit 13 - MC Event Output Enable 1"]
215 #[inline(always)]
216 pub fn mceo1(&self) -> MCEO1_R {
217 MCEO1_R::new(((self.bits >> 13) & 1) != 0)
218 }
219}
220impl W {
221 #[doc = "Bits 0:2 - Event Action"]
222 #[inline(always)]
223 #[must_use]
224 pub fn evact(&mut self) -> EVACT_W<0> {
225 EVACT_W::new(self)
226 }
227 #[doc = "Bit 4 - TC Event Input Polarity"]
228 #[inline(always)]
229 #[must_use]
230 pub fn tcinv(&mut self) -> TCINV_W<4> {
231 TCINV_W::new(self)
232 }
233 #[doc = "Bit 5 - TC Event Enable"]
234 #[inline(always)]
235 #[must_use]
236 pub fn tcei(&mut self) -> TCEI_W<5> {
237 TCEI_W::new(self)
238 }
239 #[doc = "Bit 8 - Event Output Enable"]
240 #[inline(always)]
241 #[must_use]
242 pub fn ovfeo(&mut self) -> OVFEO_W<8> {
243 OVFEO_W::new(self)
244 }
245 #[doc = "Bit 12 - MC Event Output Enable 0"]
246 #[inline(always)]
247 #[must_use]
248 pub fn mceo0(&mut self) -> MCEO0_W<12> {
249 MCEO0_W::new(self)
250 }
251 #[doc = "Bit 13 - MC Event Output Enable 1"]
252 #[inline(always)]
253 #[must_use]
254 pub fn mceo1(&mut self) -> MCEO1_W<13> {
255 MCEO1_W::new(self)
256 }
257 #[doc = "Writes raw bits to the register."]
258 #[inline(always)]
259 pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
260 self.0.bits(bits);
261 self
262 }
263}
264#[doc = "Event 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 [evctrl](index.html) module"]
265pub struct EVCTRL_SPEC;
266impl crate::RegisterSpec for EVCTRL_SPEC {
267 type Ux = u16;
268}
269#[doc = "`read()` method returns [evctrl::R](R) reader structure"]
270impl crate::Readable for EVCTRL_SPEC {
271 type Reader = R;
272}
273#[doc = "`write(|w| ..)` method takes [evctrl::W](W) writer structure"]
274impl crate::Writable for EVCTRL_SPEC {
275 type Writer = W;
276 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
277 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
278}
279#[doc = "`reset()` method sets EVCTRL to value 0"]
280impl crate::Resettable for EVCTRL_SPEC {
281 const RESET_VALUE: Self::Ux = 0;
282}