atsamd51g/tc0/count8/
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 = "4: Time stamp capture"]
18 Stamp = 4,
19 #[doc = "5: Period catured in CC0, pulse width in CC1"]
20 Ppw = 5,
21 #[doc = "6: Period catured in CC1, pulse width in CC0"]
22 Pwp = 6,
23 #[doc = "7: Pulse width capture"]
24 Pw = 7,
25}
26impl From<Evactselect> for u8 {
27 #[inline(always)]
28 fn from(variant: Evactselect) -> Self {
29 variant as _
30 }
31}
32impl crate::FieldSpec for Evactselect {
33 type Ux = u8;
34}
35impl crate::IsEnum for Evactselect {}
36#[doc = "Field `EVACT` reader - Event Action"]
37pub type EvactR = crate::FieldReader<Evactselect>;
38impl EvactR {
39 #[doc = "Get enumerated values variant"]
40 #[inline(always)]
41 pub const fn variant(&self) -> Evactselect {
42 match self.bits {
43 0 => Evactselect::Off,
44 1 => Evactselect::Retrigger,
45 2 => Evactselect::Count,
46 3 => Evactselect::Start,
47 4 => Evactselect::Stamp,
48 5 => Evactselect::Ppw,
49 6 => Evactselect::Pwp,
50 7 => Evactselect::Pw,
51 _ => unreachable!(),
52 }
53 }
54 #[doc = "Event action disabled"]
55 #[inline(always)]
56 pub fn is_off(&self) -> bool {
57 *self == Evactselect::Off
58 }
59 #[doc = "Start, restart or retrigger TC on event"]
60 #[inline(always)]
61 pub fn is_retrigger(&self) -> bool {
62 *self == Evactselect::Retrigger
63 }
64 #[doc = "Count on event"]
65 #[inline(always)]
66 pub fn is_count(&self) -> bool {
67 *self == Evactselect::Count
68 }
69 #[doc = "Start TC on event"]
70 #[inline(always)]
71 pub fn is_start(&self) -> bool {
72 *self == Evactselect::Start
73 }
74 #[doc = "Time stamp capture"]
75 #[inline(always)]
76 pub fn is_stamp(&self) -> bool {
77 *self == Evactselect::Stamp
78 }
79 #[doc = "Period catured in CC0, pulse width in CC1"]
80 #[inline(always)]
81 pub fn is_ppw(&self) -> bool {
82 *self == Evactselect::Ppw
83 }
84 #[doc = "Period catured in CC1, pulse width in CC0"]
85 #[inline(always)]
86 pub fn is_pwp(&self) -> bool {
87 *self == Evactselect::Pwp
88 }
89 #[doc = "Pulse width capture"]
90 #[inline(always)]
91 pub fn is_pw(&self) -> bool {
92 *self == Evactselect::Pw
93 }
94}
95#[doc = "Field `EVACT` writer - Event Action"]
96pub type EvactW<'a, REG> = crate::FieldWriter<'a, REG, 3, Evactselect, crate::Safe>;
97impl<'a, REG> EvactW<'a, REG>
98where
99 REG: crate::Writable + crate::RegisterSpec,
100 REG::Ux: From<u8>,
101{
102 #[doc = "Event action disabled"]
103 #[inline(always)]
104 pub fn off(self) -> &'a mut crate::W<REG> {
105 self.variant(Evactselect::Off)
106 }
107 #[doc = "Start, restart or retrigger TC on event"]
108 #[inline(always)]
109 pub fn retrigger(self) -> &'a mut crate::W<REG> {
110 self.variant(Evactselect::Retrigger)
111 }
112 #[doc = "Count on event"]
113 #[inline(always)]
114 pub fn count(self) -> &'a mut crate::W<REG> {
115 self.variant(Evactselect::Count)
116 }
117 #[doc = "Start TC on event"]
118 #[inline(always)]
119 pub fn start(self) -> &'a mut crate::W<REG> {
120 self.variant(Evactselect::Start)
121 }
122 #[doc = "Time stamp capture"]
123 #[inline(always)]
124 pub fn stamp(self) -> &'a mut crate::W<REG> {
125 self.variant(Evactselect::Stamp)
126 }
127 #[doc = "Period catured in CC0, pulse width in CC1"]
128 #[inline(always)]
129 pub fn ppw(self) -> &'a mut crate::W<REG> {
130 self.variant(Evactselect::Ppw)
131 }
132 #[doc = "Period catured in CC1, pulse width in CC0"]
133 #[inline(always)]
134 pub fn pwp(self) -> &'a mut crate::W<REG> {
135 self.variant(Evactselect::Pwp)
136 }
137 #[doc = "Pulse width capture"]
138 #[inline(always)]
139 pub fn pw(self) -> &'a mut crate::W<REG> {
140 self.variant(Evactselect::Pw)
141 }
142}
143#[doc = "Field `TCINV` reader - TC Event Input Polarity"]
144pub type TcinvR = crate::BitReader;
145#[doc = "Field `TCINV` writer - TC Event Input Polarity"]
146pub type TcinvW<'a, REG> = crate::BitWriter<'a, REG>;
147#[doc = "Field `TCEI` reader - TC Event Enable"]
148pub type TceiR = crate::BitReader;
149#[doc = "Field `TCEI` writer - TC Event Enable"]
150pub type TceiW<'a, REG> = crate::BitWriter<'a, REG>;
151#[doc = "Field `OVFEO` reader - Event Output Enable"]
152pub type OvfeoR = crate::BitReader;
153#[doc = "Field `OVFEO` writer - Event Output Enable"]
154pub type OvfeoW<'a, REG> = crate::BitWriter<'a, REG>;
155#[doc = "Field `MCEO0` reader - MC Event Output Enable 0"]
156pub type Mceo0R = crate::BitReader;
157#[doc = "Field `MCEO0` writer - MC Event Output Enable 0"]
158pub type Mceo0W<'a, REG> = crate::BitWriter<'a, REG>;
159#[doc = "Field `MCEO1` reader - MC Event Output Enable 1"]
160pub type Mceo1R = crate::BitReader;
161#[doc = "Field `MCEO1` writer - MC Event Output Enable 1"]
162pub type Mceo1W<'a, REG> = crate::BitWriter<'a, REG>;
163impl R {
164 #[doc = "Bits 0:2 - Event Action"]
165 #[inline(always)]
166 pub fn evact(&self) -> EvactR {
167 EvactR::new((self.bits & 7) as u8)
168 }
169 #[doc = "Bit 4 - TC Event Input Polarity"]
170 #[inline(always)]
171 pub fn tcinv(&self) -> TcinvR {
172 TcinvR::new(((self.bits >> 4) & 1) != 0)
173 }
174 #[doc = "Bit 5 - TC Event Enable"]
175 #[inline(always)]
176 pub fn tcei(&self) -> TceiR {
177 TceiR::new(((self.bits >> 5) & 1) != 0)
178 }
179 #[doc = "Bit 8 - Event Output Enable"]
180 #[inline(always)]
181 pub fn ovfeo(&self) -> OvfeoR {
182 OvfeoR::new(((self.bits >> 8) & 1) != 0)
183 }
184 #[doc = "Bit 12 - MC Event Output Enable 0"]
185 #[inline(always)]
186 pub fn mceo0(&self) -> Mceo0R {
187 Mceo0R::new(((self.bits >> 12) & 1) != 0)
188 }
189 #[doc = "Bit 13 - MC Event Output Enable 1"]
190 #[inline(always)]
191 pub fn mceo1(&self) -> Mceo1R {
192 Mceo1R::new(((self.bits >> 13) & 1) != 0)
193 }
194}
195impl W {
196 #[doc = "Bits 0:2 - Event Action"]
197 #[inline(always)]
198 #[must_use]
199 pub fn evact(&mut self) -> EvactW<EvctrlSpec> {
200 EvactW::new(self, 0)
201 }
202 #[doc = "Bit 4 - TC Event Input Polarity"]
203 #[inline(always)]
204 #[must_use]
205 pub fn tcinv(&mut self) -> TcinvW<EvctrlSpec> {
206 TcinvW::new(self, 4)
207 }
208 #[doc = "Bit 5 - TC Event Enable"]
209 #[inline(always)]
210 #[must_use]
211 pub fn tcei(&mut self) -> TceiW<EvctrlSpec> {
212 TceiW::new(self, 5)
213 }
214 #[doc = "Bit 8 - Event Output Enable"]
215 #[inline(always)]
216 #[must_use]
217 pub fn ovfeo(&mut self) -> OvfeoW<EvctrlSpec> {
218 OvfeoW::new(self, 8)
219 }
220 #[doc = "Bit 12 - MC Event Output Enable 0"]
221 #[inline(always)]
222 #[must_use]
223 pub fn mceo0(&mut self) -> Mceo0W<EvctrlSpec> {
224 Mceo0W::new(self, 12)
225 }
226 #[doc = "Bit 13 - MC Event Output Enable 1"]
227 #[inline(always)]
228 #[must_use]
229 pub fn mceo1(&mut self) -> Mceo1W<EvctrlSpec> {
230 Mceo1W::new(self, 13)
231 }
232}
233#[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)."]
234pub struct EvctrlSpec;
235impl crate::RegisterSpec for EvctrlSpec {
236 type Ux = u16;
237}
238#[doc = "`read()` method returns [`evctrl::R`](R) reader structure"]
239impl crate::Readable for EvctrlSpec {}
240#[doc = "`write(|w| ..)` method takes [`evctrl::W`](W) writer structure"]
241impl crate::Writable for EvctrlSpec {
242 type Safety = crate::Unsafe;
243 const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
244 const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
245}
246#[doc = "`reset()` method sets EVCTRL to value 0"]
247impl crate::Resettable for EvctrlSpec {
248 const RESET_VALUE: u16 = 0;
249}