atsamd51j/pdec/
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 on event"]
12 Retrigger = 1,
13 #[doc = "2: Count on event"]
14 Count = 2,
15}
16impl From<Evactselect> for u8 {
17 #[inline(always)]
18 fn from(variant: Evactselect) -> Self {
19 variant as _
20 }
21}
22impl crate::FieldSpec for Evactselect {
23 type Ux = u8;
24}
25impl crate::IsEnum for Evactselect {}
26#[doc = "Field `EVACT` reader - Event Action"]
27pub type EvactR = crate::FieldReader<Evactselect>;
28impl EvactR {
29 #[doc = "Get enumerated values variant"]
30 #[inline(always)]
31 pub const fn variant(&self) -> Option<Evactselect> {
32 match self.bits {
33 0 => Some(Evactselect::Off),
34 1 => Some(Evactselect::Retrigger),
35 2 => Some(Evactselect::Count),
36 _ => None,
37 }
38 }
39 #[doc = "Event action disabled"]
40 #[inline(always)]
41 pub fn is_off(&self) -> bool {
42 *self == Evactselect::Off
43 }
44 #[doc = "Start, restart or retrigger on event"]
45 #[inline(always)]
46 pub fn is_retrigger(&self) -> bool {
47 *self == Evactselect::Retrigger
48 }
49 #[doc = "Count on event"]
50 #[inline(always)]
51 pub fn is_count(&self) -> bool {
52 *self == Evactselect::Count
53 }
54}
55#[doc = "Field `EVACT` writer - Event Action"]
56pub type EvactW<'a, REG> = crate::FieldWriter<'a, REG, 2, Evactselect>;
57impl<'a, REG> EvactW<'a, REG>
58where
59 REG: crate::Writable + crate::RegisterSpec,
60 REG::Ux: From<u8>,
61{
62 #[doc = "Event action disabled"]
63 #[inline(always)]
64 pub fn off(self) -> &'a mut crate::W<REG> {
65 self.variant(Evactselect::Off)
66 }
67 #[doc = "Start, restart or retrigger on event"]
68 #[inline(always)]
69 pub fn retrigger(self) -> &'a mut crate::W<REG> {
70 self.variant(Evactselect::Retrigger)
71 }
72 #[doc = "Count on event"]
73 #[inline(always)]
74 pub fn count(self) -> &'a mut crate::W<REG> {
75 self.variant(Evactselect::Count)
76 }
77}
78#[doc = "Field `EVINV` reader - Inverted Event Input Enable"]
79pub type EvinvR = crate::FieldReader;
80#[doc = "Field `EVINV` writer - Inverted Event Input Enable"]
81pub type EvinvW<'a, REG> = crate::FieldWriter<'a, REG, 3>;
82#[doc = "Field `EVEI` reader - Event Input Enable"]
83pub type EveiR = crate::FieldReader;
84#[doc = "Field `EVEI` writer - Event Input Enable"]
85pub type EveiW<'a, REG> = crate::FieldWriter<'a, REG, 3>;
86#[doc = "Field `OVFEO` reader - Overflow/Underflow Output Event Enable"]
87pub type OvfeoR = crate::BitReader;
88#[doc = "Field `OVFEO` writer - Overflow/Underflow Output Event Enable"]
89pub type OvfeoW<'a, REG> = crate::BitWriter<'a, REG>;
90#[doc = "Field `ERREO` reader - Error Output Event Enable"]
91pub type ErreoR = crate::BitReader;
92#[doc = "Field `ERREO` writer - Error Output Event Enable"]
93pub type ErreoW<'a, REG> = crate::BitWriter<'a, REG>;
94#[doc = "Field `DIREO` reader - Direction Output Event Enable"]
95pub type DireoR = crate::BitReader;
96#[doc = "Field `DIREO` writer - Direction Output Event Enable"]
97pub type DireoW<'a, REG> = crate::BitWriter<'a, REG>;
98#[doc = "Field `VLCEO` reader - Velocity Output Event Enable"]
99pub type VlceoR = crate::BitReader;
100#[doc = "Field `VLCEO` writer - Velocity Output Event Enable"]
101pub type VlceoW<'a, REG> = crate::BitWriter<'a, REG>;
102#[doc = "Field `MCEO0` reader - Match Channel 0 Event Output Enable"]
103pub type Mceo0R = crate::BitReader;
104#[doc = "Field `MCEO0` writer - Match Channel 0 Event Output Enable"]
105pub type Mceo0W<'a, REG> = crate::BitWriter<'a, REG>;
106#[doc = "Field `MCEO1` reader - Match Channel 1 Event Output Enable"]
107pub type Mceo1R = crate::BitReader;
108#[doc = "Field `MCEO1` writer - Match Channel 1 Event Output Enable"]
109pub type Mceo1W<'a, REG> = crate::BitWriter<'a, REG>;
110impl R {
111 #[doc = "Bits 0:1 - Event Action"]
112 #[inline(always)]
113 pub fn evact(&self) -> EvactR {
114 EvactR::new((self.bits & 3) as u8)
115 }
116 #[doc = "Bits 2:4 - Inverted Event Input Enable"]
117 #[inline(always)]
118 pub fn evinv(&self) -> EvinvR {
119 EvinvR::new(((self.bits >> 2) & 7) as u8)
120 }
121 #[doc = "Bits 5:7 - Event Input Enable"]
122 #[inline(always)]
123 pub fn evei(&self) -> EveiR {
124 EveiR::new(((self.bits >> 5) & 7) as u8)
125 }
126 #[doc = "Bit 8 - Overflow/Underflow Output Event Enable"]
127 #[inline(always)]
128 pub fn ovfeo(&self) -> OvfeoR {
129 OvfeoR::new(((self.bits >> 8) & 1) != 0)
130 }
131 #[doc = "Bit 9 - Error Output Event Enable"]
132 #[inline(always)]
133 pub fn erreo(&self) -> ErreoR {
134 ErreoR::new(((self.bits >> 9) & 1) != 0)
135 }
136 #[doc = "Bit 10 - Direction Output Event Enable"]
137 #[inline(always)]
138 pub fn direo(&self) -> DireoR {
139 DireoR::new(((self.bits >> 10) & 1) != 0)
140 }
141 #[doc = "Bit 11 - Velocity Output Event Enable"]
142 #[inline(always)]
143 pub fn vlceo(&self) -> VlceoR {
144 VlceoR::new(((self.bits >> 11) & 1) != 0)
145 }
146 #[doc = "Bit 12 - Match Channel 0 Event Output Enable"]
147 #[inline(always)]
148 pub fn mceo0(&self) -> Mceo0R {
149 Mceo0R::new(((self.bits >> 12) & 1) != 0)
150 }
151 #[doc = "Bit 13 - Match Channel 1 Event Output Enable"]
152 #[inline(always)]
153 pub fn mceo1(&self) -> Mceo1R {
154 Mceo1R::new(((self.bits >> 13) & 1) != 0)
155 }
156}
157impl W {
158 #[doc = "Bits 0:1 - Event Action"]
159 #[inline(always)]
160 #[must_use]
161 pub fn evact(&mut self) -> EvactW<EvctrlSpec> {
162 EvactW::new(self, 0)
163 }
164 #[doc = "Bits 2:4 - Inverted Event Input Enable"]
165 #[inline(always)]
166 #[must_use]
167 pub fn evinv(&mut self) -> EvinvW<EvctrlSpec> {
168 EvinvW::new(self, 2)
169 }
170 #[doc = "Bits 5:7 - Event Input Enable"]
171 #[inline(always)]
172 #[must_use]
173 pub fn evei(&mut self) -> EveiW<EvctrlSpec> {
174 EveiW::new(self, 5)
175 }
176 #[doc = "Bit 8 - Overflow/Underflow Output Event Enable"]
177 #[inline(always)]
178 #[must_use]
179 pub fn ovfeo(&mut self) -> OvfeoW<EvctrlSpec> {
180 OvfeoW::new(self, 8)
181 }
182 #[doc = "Bit 9 - Error Output Event Enable"]
183 #[inline(always)]
184 #[must_use]
185 pub fn erreo(&mut self) -> ErreoW<EvctrlSpec> {
186 ErreoW::new(self, 9)
187 }
188 #[doc = "Bit 10 - Direction Output Event Enable"]
189 #[inline(always)]
190 #[must_use]
191 pub fn direo(&mut self) -> DireoW<EvctrlSpec> {
192 DireoW::new(self, 10)
193 }
194 #[doc = "Bit 11 - Velocity Output Event Enable"]
195 #[inline(always)]
196 #[must_use]
197 pub fn vlceo(&mut self) -> VlceoW<EvctrlSpec> {
198 VlceoW::new(self, 11)
199 }
200 #[doc = "Bit 12 - Match Channel 0 Event Output Enable"]
201 #[inline(always)]
202 #[must_use]
203 pub fn mceo0(&mut self) -> Mceo0W<EvctrlSpec> {
204 Mceo0W::new(self, 12)
205 }
206 #[doc = "Bit 13 - Match Channel 1 Event Output Enable"]
207 #[inline(always)]
208 #[must_use]
209 pub fn mceo1(&mut self) -> Mceo1W<EvctrlSpec> {
210 Mceo1W::new(self, 13)
211 }
212}
213#[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)."]
214pub struct EvctrlSpec;
215impl crate::RegisterSpec for EvctrlSpec {
216 type Ux = u16;
217}
218#[doc = "`read()` method returns [`evctrl::R`](R) reader structure"]
219impl crate::Readable for EvctrlSpec {}
220#[doc = "`write(|w| ..)` method takes [`evctrl::W`](W) writer structure"]
221impl crate::Writable for EvctrlSpec {
222 type Safety = crate::Unsafe;
223 const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
224 const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
225}
226#[doc = "`reset()` method sets EVCTRL to value 0"]
227impl crate::Resettable for EvctrlSpec {
228 const RESET_VALUE: u16 = 0;
229}