atsamd21g/tc3/count32/
evctrl.rs
1#[doc = "Register `EVCTRL` reader"]
2pub type R = crate::R<EvctrlSpec>;
3#[doc = "Register `EVCTRL` writer"]
4pub type W = crate::W<EvctrlSpec>;
5#[doc = "Event Action\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Evactselect {
9 #[doc = "0: Event action disabled"]
10 Off = 0,
11 #[doc = "1: Start, restart or retrigger TC on event"]
12 Retrigger = 1,
13 #[doc = "2: Count on event"]
14 Count = 2,
15 #[doc = "3: Start TC on event"]
16 Start = 3,
17 #[doc = "5: Period captured in CC0, pulse width in CC1"]
18 Ppw = 5,
19 #[doc = "6: Period captured in CC1, pulse width in CC0"]
20 Pwp = 6,
21}
22impl From<Evactselect> for u8 {
23 #[inline(always)]
24 fn from(variant: Evactselect) -> Self {
25 variant as _
26 }
27}
28impl crate::FieldSpec for Evactselect {
29 type Ux = u8;
30}
31impl crate::IsEnum for Evactselect {}
32#[doc = "Field `EVACT` reader - Event Action"]
33pub type EvactR = crate::FieldReader<Evactselect>;
34impl EvactR {
35 #[doc = "Get enumerated values variant"]
36 #[inline(always)]
37 pub const fn variant(&self) -> Option<Evactselect> {
38 match self.bits {
39 0 => Some(Evactselect::Off),
40 1 => Some(Evactselect::Retrigger),
41 2 => Some(Evactselect::Count),
42 3 => Some(Evactselect::Start),
43 5 => Some(Evactselect::Ppw),
44 6 => Some(Evactselect::Pwp),
45 _ => None,
46 }
47 }
48 #[doc = "Event action disabled"]
49 #[inline(always)]
50 pub fn is_off(&self) -> bool {
51 *self == Evactselect::Off
52 }
53 #[doc = "Start, restart or retrigger TC on event"]
54 #[inline(always)]
55 pub fn is_retrigger(&self) -> bool {
56 *self == Evactselect::Retrigger
57 }
58 #[doc = "Count on event"]
59 #[inline(always)]
60 pub fn is_count(&self) -> bool {
61 *self == Evactselect::Count
62 }
63 #[doc = "Start TC on event"]
64 #[inline(always)]
65 pub fn is_start(&self) -> bool {
66 *self == Evactselect::Start
67 }
68 #[doc = "Period captured in CC0, pulse width in CC1"]
69 #[inline(always)]
70 pub fn is_ppw(&self) -> bool {
71 *self == Evactselect::Ppw
72 }
73 #[doc = "Period captured in CC1, pulse width in CC0"]
74 #[inline(always)]
75 pub fn is_pwp(&self) -> bool {
76 *self == Evactselect::Pwp
77 }
78}
79#[doc = "Field `EVACT` writer - Event Action"]
80pub type EvactW<'a, REG> = crate::FieldWriter<'a, REG, 3, Evactselect>;
81impl<'a, REG> EvactW<'a, REG>
82where
83 REG: crate::Writable + crate::RegisterSpec,
84 REG::Ux: From<u8>,
85{
86 #[doc = "Event action disabled"]
87 #[inline(always)]
88 pub fn off(self) -> &'a mut crate::W<REG> {
89 self.variant(Evactselect::Off)
90 }
91 #[doc = "Start, restart or retrigger TC on event"]
92 #[inline(always)]
93 pub fn retrigger(self) -> &'a mut crate::W<REG> {
94 self.variant(Evactselect::Retrigger)
95 }
96 #[doc = "Count on event"]
97 #[inline(always)]
98 pub fn count(self) -> &'a mut crate::W<REG> {
99 self.variant(Evactselect::Count)
100 }
101 #[doc = "Start TC on event"]
102 #[inline(always)]
103 pub fn start(self) -> &'a mut crate::W<REG> {
104 self.variant(Evactselect::Start)
105 }
106 #[doc = "Period captured in CC0, pulse width in CC1"]
107 #[inline(always)]
108 pub fn ppw(self) -> &'a mut crate::W<REG> {
109 self.variant(Evactselect::Ppw)
110 }
111 #[doc = "Period captured in CC1, pulse width in CC0"]
112 #[inline(always)]
113 pub fn pwp(self) -> &'a mut crate::W<REG> {
114 self.variant(Evactselect::Pwp)
115 }
116}
117#[doc = "Field `TCINV` reader - TC Inverted Event Input"]
118pub type TcinvR = crate::BitReader;
119#[doc = "Field `TCINV` writer - TC Inverted Event Input"]
120pub type TcinvW<'a, REG> = crate::BitWriter<'a, REG>;
121#[doc = "Field `TCEI` reader - TC Event Input"]
122pub type TceiR = crate::BitReader;
123#[doc = "Field `TCEI` writer - TC Event Input"]
124pub type TceiW<'a, REG> = crate::BitWriter<'a, REG>;
125#[doc = "Field `OVFEO` reader - Overflow/Underflow Event Output Enable"]
126pub type OvfeoR = crate::BitReader;
127#[doc = "Field `OVFEO` writer - Overflow/Underflow Event Output Enable"]
128pub type OvfeoW<'a, REG> = crate::BitWriter<'a, REG>;
129#[doc = "Field `MCEO0` reader - Match or Capture Channel 0 Event Output Enable"]
130pub type Mceo0R = crate::BitReader;
131#[doc = "Field `MCEO0` writer - Match or Capture Channel 0 Event Output Enable"]
132pub type Mceo0W<'a, REG> = crate::BitWriter<'a, REG>;
133#[doc = "Field `MCEO1` reader - Match or Capture Channel 1 Event Output Enable"]
134pub type Mceo1R = crate::BitReader;
135#[doc = "Field `MCEO1` writer - Match or Capture Channel 1 Event Output Enable"]
136pub type Mceo1W<'a, REG> = crate::BitWriter<'a, REG>;
137impl R {
138 #[doc = "Bits 0:2 - Event Action"]
139 #[inline(always)]
140 pub fn evact(&self) -> EvactR {
141 EvactR::new((self.bits & 7) as u8)
142 }
143 #[doc = "Bit 4 - TC Inverted Event Input"]
144 #[inline(always)]
145 pub fn tcinv(&self) -> TcinvR {
146 TcinvR::new(((self.bits >> 4) & 1) != 0)
147 }
148 #[doc = "Bit 5 - TC Event Input"]
149 #[inline(always)]
150 pub fn tcei(&self) -> TceiR {
151 TceiR::new(((self.bits >> 5) & 1) != 0)
152 }
153 #[doc = "Bit 8 - Overflow/Underflow Event Output Enable"]
154 #[inline(always)]
155 pub fn ovfeo(&self) -> OvfeoR {
156 OvfeoR::new(((self.bits >> 8) & 1) != 0)
157 }
158 #[doc = "Bit 12 - Match or Capture Channel 0 Event Output Enable"]
159 #[inline(always)]
160 pub fn mceo0(&self) -> Mceo0R {
161 Mceo0R::new(((self.bits >> 12) & 1) != 0)
162 }
163 #[doc = "Bit 13 - Match or Capture Channel 1 Event Output Enable"]
164 #[inline(always)]
165 pub fn mceo1(&self) -> Mceo1R {
166 Mceo1R::new(((self.bits >> 13) & 1) != 0)
167 }
168}
169impl W {
170 #[doc = "Bits 0:2 - Event Action"]
171 #[inline(always)]
172 #[must_use]
173 pub fn evact(&mut self) -> EvactW<EvctrlSpec> {
174 EvactW::new(self, 0)
175 }
176 #[doc = "Bit 4 - TC Inverted Event Input"]
177 #[inline(always)]
178 #[must_use]
179 pub fn tcinv(&mut self) -> TcinvW<EvctrlSpec> {
180 TcinvW::new(self, 4)
181 }
182 #[doc = "Bit 5 - TC Event Input"]
183 #[inline(always)]
184 #[must_use]
185 pub fn tcei(&mut self) -> TceiW<EvctrlSpec> {
186 TceiW::new(self, 5)
187 }
188 #[doc = "Bit 8 - Overflow/Underflow Event Output Enable"]
189 #[inline(always)]
190 #[must_use]
191 pub fn ovfeo(&mut self) -> OvfeoW<EvctrlSpec> {
192 OvfeoW::new(self, 8)
193 }
194 #[doc = "Bit 12 - Match or Capture Channel 0 Event Output Enable"]
195 #[inline(always)]
196 #[must_use]
197 pub fn mceo0(&mut self) -> Mceo0W<EvctrlSpec> {
198 Mceo0W::new(self, 12)
199 }
200 #[doc = "Bit 13 - Match or Capture Channel 1 Event Output Enable"]
201 #[inline(always)]
202 #[must_use]
203 pub fn mceo1(&mut self) -> Mceo1W<EvctrlSpec> {
204 Mceo1W::new(self, 13)
205 }
206}
207#[doc = "Event Control\n\nYou can [`read`](crate::Reg::read) this register and get [`evctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`evctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
208pub struct EvctrlSpec;
209impl crate::RegisterSpec for EvctrlSpec {
210 type Ux = u16;
211}
212#[doc = "`read()` method returns [`evctrl::R`](R) reader structure"]
213impl crate::Readable for EvctrlSpec {}
214#[doc = "`write(|w| ..)` method takes [`evctrl::W`](W) writer structure"]
215impl crate::Writable for EvctrlSpec {
216 type Safety = crate::Unsafe;
217 const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
218 const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
219}
220#[doc = "`reset()` method sets EVCTRL to value 0"]
221impl crate::Resettable for EvctrlSpec {
222 const RESET_VALUE: u16 = 0;
223}