saml10d16a/tc0/count32/
evctrl.rs1#[doc = "Reader of register EVCTRL"]
2pub type R = crate::R<u16, super::EVCTRL>;
3#[doc = "Writer for register EVCTRL"]
4pub type W = crate::W<u16, super::EVCTRL>;
5#[doc = "Register EVCTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::EVCTRL {
7 type Type = u16;
8 #[inline(always)]
9 fn reset_value() -> Self::Type {
10 0
11 }
12}
13#[doc = "Possible values of the field `EVACT`"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum EVACT_A {
16 #[doc = "Event action disabled"]
17 OFF,
18 #[doc = "Start, restart or retrigger TC on event"]
19 RETRIGGER,
20 #[doc = "Count on event"]
21 COUNT,
22 #[doc = "Start TC on event"]
23 START,
24 #[doc = "Time stamp capture"]
25 STAMP,
26 #[doc = "Period catured in CC0, pulse width in CC1"]
27 PPW,
28 #[doc = "Period catured in CC1, pulse width in CC0"]
29 PWP,
30 #[doc = "Pulse width capture"]
31 PW,
32}
33impl crate::ToBits<u8> for EVACT_A {
34 #[inline(always)]
35 fn _bits(&self) -> u8 {
36 match *self {
37 EVACT_A::OFF => 0,
38 EVACT_A::RETRIGGER => 1,
39 EVACT_A::COUNT => 2,
40 EVACT_A::START => 3,
41 EVACT_A::STAMP => 4,
42 EVACT_A::PPW => 5,
43 EVACT_A::PWP => 6,
44 EVACT_A::PW => 7,
45 }
46 }
47}
48#[doc = "Reader of field `EVACT`"]
49pub type EVACT_R = crate::R<u8, EVACT_A>;
50impl EVACT_R {
51 #[doc = r"Get enumerated values variant"]
52 #[inline(always)]
53 pub fn variant(&self) -> EVACT_A {
54 match self.bits {
55 0 => EVACT_A::OFF,
56 1 => EVACT_A::RETRIGGER,
57 2 => EVACT_A::COUNT,
58 3 => EVACT_A::START,
59 4 => EVACT_A::STAMP,
60 5 => EVACT_A::PPW,
61 6 => EVACT_A::PWP,
62 7 => EVACT_A::PW,
63 _ => unreachable!(),
64 }
65 }
66 #[doc = "Checks if the value of the field is `OFF`"]
67 #[inline(always)]
68 pub fn is_off(&self) -> bool {
69 *self == EVACT_A::OFF
70 }
71 #[doc = "Checks if the value of the field is `RETRIGGER`"]
72 #[inline(always)]
73 pub fn is_retrigger(&self) -> bool {
74 *self == EVACT_A::RETRIGGER
75 }
76 #[doc = "Checks if the value of the field is `COUNT`"]
77 #[inline(always)]
78 pub fn is_count(&self) -> bool {
79 *self == EVACT_A::COUNT
80 }
81 #[doc = "Checks if the value of the field is `START`"]
82 #[inline(always)]
83 pub fn is_start(&self) -> bool {
84 *self == EVACT_A::START
85 }
86 #[doc = "Checks if the value of the field is `STAMP`"]
87 #[inline(always)]
88 pub fn is_stamp(&self) -> bool {
89 *self == EVACT_A::STAMP
90 }
91 #[doc = "Checks if the value of the field is `PPW`"]
92 #[inline(always)]
93 pub fn is_ppw(&self) -> bool {
94 *self == EVACT_A::PPW
95 }
96 #[doc = "Checks if the value of the field is `PWP`"]
97 #[inline(always)]
98 pub fn is_pwp(&self) -> bool {
99 *self == EVACT_A::PWP
100 }
101 #[doc = "Checks if the value of the field is `PW`"]
102 #[inline(always)]
103 pub fn is_pw(&self) -> bool {
104 *self == EVACT_A::PW
105 }
106}
107#[doc = "Write proxy for field `EVACT`"]
108pub struct EVACT_W<'a> {
109 w: &'a mut W,
110}
111impl<'a> EVACT_W<'a> {
112 #[doc = r"Writes `variant` to the field"]
113 #[inline(always)]
114 pub fn variant(self, variant: EVACT_A) -> &'a mut W {
115 use crate::ToBits;
116 {
117 self.bits(variant._bits())
118 }
119 }
120 #[doc = "Event action disabled"]
121 #[inline(always)]
122 pub fn off(self) -> &'a mut W {
123 self.variant(EVACT_A::OFF)
124 }
125 #[doc = "Start, restart or retrigger TC on event"]
126 #[inline(always)]
127 pub fn retrigger(self) -> &'a mut W {
128 self.variant(EVACT_A::RETRIGGER)
129 }
130 #[doc = "Count on event"]
131 #[inline(always)]
132 pub fn count(self) -> &'a mut W {
133 self.variant(EVACT_A::COUNT)
134 }
135 #[doc = "Start TC on event"]
136 #[inline(always)]
137 pub fn start(self) -> &'a mut W {
138 self.variant(EVACT_A::START)
139 }
140 #[doc = "Time stamp capture"]
141 #[inline(always)]
142 pub fn stamp(self) -> &'a mut W {
143 self.variant(EVACT_A::STAMP)
144 }
145 #[doc = "Period catured in CC0, pulse width in CC1"]
146 #[inline(always)]
147 pub fn ppw(self) -> &'a mut W {
148 self.variant(EVACT_A::PPW)
149 }
150 #[doc = "Period catured in CC1, pulse width in CC0"]
151 #[inline(always)]
152 pub fn pwp(self) -> &'a mut W {
153 self.variant(EVACT_A::PWP)
154 }
155 #[doc = "Pulse width capture"]
156 #[inline(always)]
157 pub fn pw(self) -> &'a mut W {
158 self.variant(EVACT_A::PW)
159 }
160 #[doc = r"Writes raw bits to the field"]
161 #[inline(always)]
162 pub fn bits(self, value: u8) -> &'a mut W {
163 self.w.bits = (self.w.bits & !0x07) | ((value as u16) & 0x07);
164 self.w
165 }
166}
167#[doc = "Reader of field `TCINV`"]
168pub type TCINV_R = crate::R<bool, bool>;
169#[doc = "Write proxy for field `TCINV`"]
170pub struct TCINV_W<'a> {
171 w: &'a mut W,
172}
173impl<'a> TCINV_W<'a> {
174 #[doc = r"Sets the field bit"]
175 #[inline(always)]
176 pub fn set_bit(self) -> &'a mut W {
177 self.bit(true)
178 }
179 #[doc = r"Clears the field bit"]
180 #[inline(always)]
181 pub fn clear_bit(self) -> &'a mut W {
182 self.bit(false)
183 }
184 #[doc = r"Writes raw bits to the field"]
185 #[inline(always)]
186 pub fn bit(self, value: bool) -> &'a mut W {
187 self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u16) & 0x01) << 4);
188 self.w
189 }
190}
191#[doc = "Reader of field `TCEI`"]
192pub type TCEI_R = crate::R<bool, bool>;
193#[doc = "Write proxy for field `TCEI`"]
194pub struct TCEI_W<'a> {
195 w: &'a mut W,
196}
197impl<'a> TCEI_W<'a> {
198 #[doc = r"Sets the field bit"]
199 #[inline(always)]
200 pub fn set_bit(self) -> &'a mut W {
201 self.bit(true)
202 }
203 #[doc = r"Clears the field bit"]
204 #[inline(always)]
205 pub fn clear_bit(self) -> &'a mut W {
206 self.bit(false)
207 }
208 #[doc = r"Writes raw bits to the field"]
209 #[inline(always)]
210 pub fn bit(self, value: bool) -> &'a mut W {
211 self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u16) & 0x01) << 5);
212 self.w
213 }
214}
215#[doc = "Reader of field `OVFEO`"]
216pub type OVFEO_R = crate::R<bool, bool>;
217#[doc = "Write proxy for field `OVFEO`"]
218pub struct OVFEO_W<'a> {
219 w: &'a mut W,
220}
221impl<'a> OVFEO_W<'a> {
222 #[doc = r"Sets the field bit"]
223 #[inline(always)]
224 pub fn set_bit(self) -> &'a mut W {
225 self.bit(true)
226 }
227 #[doc = r"Clears the field bit"]
228 #[inline(always)]
229 pub fn clear_bit(self) -> &'a mut W {
230 self.bit(false)
231 }
232 #[doc = r"Writes raw bits to the field"]
233 #[inline(always)]
234 pub fn bit(self, value: bool) -> &'a mut W {
235 self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u16) & 0x01) << 8);
236 self.w
237 }
238}
239#[doc = "Reader of field `MCEO0`"]
240pub type MCEO0_R = crate::R<bool, bool>;
241#[doc = "Write proxy for field `MCEO0`"]
242pub struct MCEO0_W<'a> {
243 w: &'a mut W,
244}
245impl<'a> MCEO0_W<'a> {
246 #[doc = r"Sets the field bit"]
247 #[inline(always)]
248 pub fn set_bit(self) -> &'a mut W {
249 self.bit(true)
250 }
251 #[doc = r"Clears the field bit"]
252 #[inline(always)]
253 pub fn clear_bit(self) -> &'a mut W {
254 self.bit(false)
255 }
256 #[doc = r"Writes raw bits to the field"]
257 #[inline(always)]
258 pub fn bit(self, value: bool) -> &'a mut W {
259 self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u16) & 0x01) << 12);
260 self.w
261 }
262}
263#[doc = "Reader of field `MCEO1`"]
264pub type MCEO1_R = crate::R<bool, bool>;
265#[doc = "Write proxy for field `MCEO1`"]
266pub struct MCEO1_W<'a> {
267 w: &'a mut W,
268}
269impl<'a> MCEO1_W<'a> {
270 #[doc = r"Sets the field bit"]
271 #[inline(always)]
272 pub fn set_bit(self) -> &'a mut W {
273 self.bit(true)
274 }
275 #[doc = r"Clears the field bit"]
276 #[inline(always)]
277 pub fn clear_bit(self) -> &'a mut W {
278 self.bit(false)
279 }
280 #[doc = r"Writes raw bits to the field"]
281 #[inline(always)]
282 pub fn bit(self, value: bool) -> &'a mut W {
283 self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u16) & 0x01) << 13);
284 self.w
285 }
286}
287impl R {
288 #[doc = "Bits 0:2 - Event Action"]
289 #[inline(always)]
290 pub fn evact(&self) -> EVACT_R {
291 EVACT_R::new((self.bits & 0x07) as u8)
292 }
293 #[doc = "Bit 4 - TC Event Input Polarity"]
294 #[inline(always)]
295 pub fn tcinv(&self) -> TCINV_R {
296 TCINV_R::new(((self.bits >> 4) & 0x01) != 0)
297 }
298 #[doc = "Bit 5 - TC Event Enable"]
299 #[inline(always)]
300 pub fn tcei(&self) -> TCEI_R {
301 TCEI_R::new(((self.bits >> 5) & 0x01) != 0)
302 }
303 #[doc = "Bit 8 - Event Output Enable"]
304 #[inline(always)]
305 pub fn ovfeo(&self) -> OVFEO_R {
306 OVFEO_R::new(((self.bits >> 8) & 0x01) != 0)
307 }
308 #[doc = "Bit 12 - MC Event Output Enable 0"]
309 #[inline(always)]
310 pub fn mceo0(&self) -> MCEO0_R {
311 MCEO0_R::new(((self.bits >> 12) & 0x01) != 0)
312 }
313 #[doc = "Bit 13 - MC Event Output Enable 1"]
314 #[inline(always)]
315 pub fn mceo1(&self) -> MCEO1_R {
316 MCEO1_R::new(((self.bits >> 13) & 0x01) != 0)
317 }
318}
319impl W {
320 #[doc = "Bits 0:2 - Event Action"]
321 #[inline(always)]
322 pub fn evact(&mut self) -> EVACT_W {
323 EVACT_W { w: self }
324 }
325 #[doc = "Bit 4 - TC Event Input Polarity"]
326 #[inline(always)]
327 pub fn tcinv(&mut self) -> TCINV_W {
328 TCINV_W { w: self }
329 }
330 #[doc = "Bit 5 - TC Event Enable"]
331 #[inline(always)]
332 pub fn tcei(&mut self) -> TCEI_W {
333 TCEI_W { w: self }
334 }
335 #[doc = "Bit 8 - Event Output Enable"]
336 #[inline(always)]
337 pub fn ovfeo(&mut self) -> OVFEO_W {
338 OVFEO_W { w: self }
339 }
340 #[doc = "Bit 12 - MC Event Output Enable 0"]
341 #[inline(always)]
342 pub fn mceo0(&mut self) -> MCEO0_W {
343 MCEO0_W { w: self }
344 }
345 #[doc = "Bit 13 - MC Event Output Enable 1"]
346 #[inline(always)]
347 pub fn mceo1(&mut self) -> MCEO1_W {
348 MCEO1_W { w: self }
349 }
350}