1#[doc = "Register `QDC` reader"]
2pub type R = crate::R<QDC_SPEC>;
3#[doc = "Register `QDC` writer"]
4pub type W = crate::W<QDC_SPEC>;
5#[doc = "Phase A Level selector\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum PALS_A {
8 #[doc = "0: Phase A is active HIGH"]
9 VALUE1 = 0,
10 #[doc = "1: Phase A is active LOW"]
11 VALUE2 = 1,
12}
13impl From<PALS_A> for bool {
14 #[inline(always)]
15 fn from(variant: PALS_A) -> Self {
16 variant as u8 != 0
17 }
18}
19#[doc = "Field `PALS` reader - Phase A Level selector"]
20pub type PALS_R = crate::BitReader<PALS_A>;
21impl PALS_R {
22 #[doc = "Get enumerated values variant"]
23 #[inline(always)]
24 pub const fn variant(&self) -> PALS_A {
25 match self.bits {
26 false => PALS_A::VALUE1,
27 true => PALS_A::VALUE2,
28 }
29 }
30 #[doc = "Phase A is active HIGH"]
31 #[inline(always)]
32 pub fn is_value1(&self) -> bool {
33 *self == PALS_A::VALUE1
34 }
35 #[doc = "Phase A is active LOW"]
36 #[inline(always)]
37 pub fn is_value2(&self) -> bool {
38 *self == PALS_A::VALUE2
39 }
40}
41#[doc = "Field `PALS` writer - Phase A Level selector"]
42pub type PALS_W<'a, REG> = crate::BitWriter<'a, REG, PALS_A>;
43impl<'a, REG> PALS_W<'a, REG>
44where
45 REG: crate::Writable + crate::RegisterSpec,
46{
47 #[doc = "Phase A is active HIGH"]
48 #[inline(always)]
49 pub fn value1(self) -> &'a mut crate::W<REG> {
50 self.variant(PALS_A::VALUE1)
51 }
52 #[doc = "Phase A is active LOW"]
53 #[inline(always)]
54 pub fn value2(self) -> &'a mut crate::W<REG> {
55 self.variant(PALS_A::VALUE2)
56 }
57}
58#[doc = "Phase B Level selector\n\nValue on reset: 0"]
59#[derive(Clone, Copy, Debug, PartialEq, Eq)]
60pub enum PBLS_A {
61 #[doc = "0: Phase B is active HIGH"]
62 VALUE1 = 0,
63 #[doc = "1: Phase B is active LOW"]
64 VALUE2 = 1,
65}
66impl From<PBLS_A> for bool {
67 #[inline(always)]
68 fn from(variant: PBLS_A) -> Self {
69 variant as u8 != 0
70 }
71}
72#[doc = "Field `PBLS` reader - Phase B Level selector"]
73pub type PBLS_R = crate::BitReader<PBLS_A>;
74impl PBLS_R {
75 #[doc = "Get enumerated values variant"]
76 #[inline(always)]
77 pub const fn variant(&self) -> PBLS_A {
78 match self.bits {
79 false => PBLS_A::VALUE1,
80 true => PBLS_A::VALUE2,
81 }
82 }
83 #[doc = "Phase B is active HIGH"]
84 #[inline(always)]
85 pub fn is_value1(&self) -> bool {
86 *self == PBLS_A::VALUE1
87 }
88 #[doc = "Phase B is active LOW"]
89 #[inline(always)]
90 pub fn is_value2(&self) -> bool {
91 *self == PBLS_A::VALUE2
92 }
93}
94#[doc = "Field `PBLS` writer - Phase B Level selector"]
95pub type PBLS_W<'a, REG> = crate::BitWriter<'a, REG, PBLS_A>;
96impl<'a, REG> PBLS_W<'a, REG>
97where
98 REG: crate::Writable + crate::RegisterSpec,
99{
100 #[doc = "Phase B is active HIGH"]
101 #[inline(always)]
102 pub fn value1(self) -> &'a mut crate::W<REG> {
103 self.variant(PBLS_A::VALUE1)
104 }
105 #[doc = "Phase B is active LOW"]
106 #[inline(always)]
107 pub fn value2(self) -> &'a mut crate::W<REG> {
108 self.variant(PBLS_A::VALUE2)
109 }
110}
111#[doc = "Phase signals swap\n\nValue on reset: 0"]
112#[derive(Clone, Copy, Debug, PartialEq, Eq)]
113pub enum PHS_A {
114 #[doc = "0: Phase A is the leading signal for clockwise rotation"]
115 VALUE1 = 0,
116 #[doc = "1: Phase B is the leading signal for clockwise rotation"]
117 VALUE2 = 1,
118}
119impl From<PHS_A> for bool {
120 #[inline(always)]
121 fn from(variant: PHS_A) -> Self {
122 variant as u8 != 0
123 }
124}
125#[doc = "Field `PHS` reader - Phase signals swap"]
126pub type PHS_R = crate::BitReader<PHS_A>;
127impl PHS_R {
128 #[doc = "Get enumerated values variant"]
129 #[inline(always)]
130 pub const fn variant(&self) -> PHS_A {
131 match self.bits {
132 false => PHS_A::VALUE1,
133 true => PHS_A::VALUE2,
134 }
135 }
136 #[doc = "Phase A is the leading signal for clockwise rotation"]
137 #[inline(always)]
138 pub fn is_value1(&self) -> bool {
139 *self == PHS_A::VALUE1
140 }
141 #[doc = "Phase B is the leading signal for clockwise rotation"]
142 #[inline(always)]
143 pub fn is_value2(&self) -> bool {
144 *self == PHS_A::VALUE2
145 }
146}
147#[doc = "Field `PHS` writer - Phase signals swap"]
148pub type PHS_W<'a, REG> = crate::BitWriter<'a, REG, PHS_A>;
149impl<'a, REG> PHS_W<'a, REG>
150where
151 REG: crate::Writable + crate::RegisterSpec,
152{
153 #[doc = "Phase A is the leading signal for clockwise rotation"]
154 #[inline(always)]
155 pub fn value1(self) -> &'a mut crate::W<REG> {
156 self.variant(PHS_A::VALUE1)
157 }
158 #[doc = "Phase B is the leading signal for clockwise rotation"]
159 #[inline(always)]
160 pub fn value2(self) -> &'a mut crate::W<REG> {
161 self.variant(PHS_A::VALUE2)
162 }
163}
164#[doc = "Index Marker generations control\n\nValue on reset: 0"]
165#[derive(Clone, Copy, Debug, PartialEq, Eq)]
166#[repr(u8)]
167pub enum ICM_A {
168 #[doc = "0: No index marker generation on POSIFx.OUT3"]
169 VALUE1 = 0,
170 #[doc = "1: Only first index occurrence generated on POSIFx.OUT3"]
171 VALUE2 = 1,
172 #[doc = "2: All index occurrences generated on POSIFx.OUT3"]
173 VALUE3 = 2,
174}
175impl From<ICM_A> for u8 {
176 #[inline(always)]
177 fn from(variant: ICM_A) -> Self {
178 variant as _
179 }
180}
181impl crate::FieldSpec for ICM_A {
182 type Ux = u8;
183}
184impl crate::IsEnum for ICM_A {}
185#[doc = "Field `ICM` reader - Index Marker generations control"]
186pub type ICM_R = crate::FieldReader<ICM_A>;
187impl ICM_R {
188 #[doc = "Get enumerated values variant"]
189 #[inline(always)]
190 pub const fn variant(&self) -> Option<ICM_A> {
191 match self.bits {
192 0 => Some(ICM_A::VALUE1),
193 1 => Some(ICM_A::VALUE2),
194 2 => Some(ICM_A::VALUE3),
195 _ => None,
196 }
197 }
198 #[doc = "No index marker generation on POSIFx.OUT3"]
199 #[inline(always)]
200 pub fn is_value1(&self) -> bool {
201 *self == ICM_A::VALUE1
202 }
203 #[doc = "Only first index occurrence generated on POSIFx.OUT3"]
204 #[inline(always)]
205 pub fn is_value2(&self) -> bool {
206 *self == ICM_A::VALUE2
207 }
208 #[doc = "All index occurrences generated on POSIFx.OUT3"]
209 #[inline(always)]
210 pub fn is_value3(&self) -> bool {
211 *self == ICM_A::VALUE3
212 }
213}
214#[doc = "Field `ICM` writer - Index Marker generations control"]
215pub type ICM_W<'a, REG> = crate::FieldWriter<'a, REG, 2, ICM_A>;
216impl<'a, REG> ICM_W<'a, REG>
217where
218 REG: crate::Writable + crate::RegisterSpec,
219 REG::Ux: From<u8>,
220{
221 #[doc = "No index marker generation on POSIFx.OUT3"]
222 #[inline(always)]
223 pub fn value1(self) -> &'a mut crate::W<REG> {
224 self.variant(ICM_A::VALUE1)
225 }
226 #[doc = "Only first index occurrence generated on POSIFx.OUT3"]
227 #[inline(always)]
228 pub fn value2(self) -> &'a mut crate::W<REG> {
229 self.variant(ICM_A::VALUE2)
230 }
231 #[doc = "All index occurrences generated on POSIFx.OUT3"]
232 #[inline(always)]
233 pub fn value3(self) -> &'a mut crate::W<REG> {
234 self.variant(ICM_A::VALUE3)
235 }
236}
237#[doc = "Current rotation direction\n\nValue on reset: 0"]
238#[derive(Clone, Copy, Debug, PartialEq, Eq)]
239pub enum DVAL_A {
240 #[doc = "0: Counterclockwise rotation"]
241 VALUE1 = 0,
242 #[doc = "1: Clockwise rotation"]
243 VALUE2 = 1,
244}
245impl From<DVAL_A> for bool {
246 #[inline(always)]
247 fn from(variant: DVAL_A) -> Self {
248 variant as u8 != 0
249 }
250}
251#[doc = "Field `DVAL` reader - Current rotation direction"]
252pub type DVAL_R = crate::BitReader<DVAL_A>;
253impl DVAL_R {
254 #[doc = "Get enumerated values variant"]
255 #[inline(always)]
256 pub const fn variant(&self) -> DVAL_A {
257 match self.bits {
258 false => DVAL_A::VALUE1,
259 true => DVAL_A::VALUE2,
260 }
261 }
262 #[doc = "Counterclockwise rotation"]
263 #[inline(always)]
264 pub fn is_value1(&self) -> bool {
265 *self == DVAL_A::VALUE1
266 }
267 #[doc = "Clockwise rotation"]
268 #[inline(always)]
269 pub fn is_value2(&self) -> bool {
270 *self == DVAL_A::VALUE2
271 }
272}
273impl R {
274 #[doc = "Bit 0 - Phase A Level selector"]
275 #[inline(always)]
276 pub fn pals(&self) -> PALS_R {
277 PALS_R::new((self.bits & 1) != 0)
278 }
279 #[doc = "Bit 1 - Phase B Level selector"]
280 #[inline(always)]
281 pub fn pbls(&self) -> PBLS_R {
282 PBLS_R::new(((self.bits >> 1) & 1) != 0)
283 }
284 #[doc = "Bit 2 - Phase signals swap"]
285 #[inline(always)]
286 pub fn phs(&self) -> PHS_R {
287 PHS_R::new(((self.bits >> 2) & 1) != 0)
288 }
289 #[doc = "Bits 4:5 - Index Marker generations control"]
290 #[inline(always)]
291 pub fn icm(&self) -> ICM_R {
292 ICM_R::new(((self.bits >> 4) & 3) as u8)
293 }
294 #[doc = "Bit 8 - Current rotation direction"]
295 #[inline(always)]
296 pub fn dval(&self) -> DVAL_R {
297 DVAL_R::new(((self.bits >> 8) & 1) != 0)
298 }
299}
300impl W {
301 #[doc = "Bit 0 - Phase A Level selector"]
302 #[inline(always)]
303 pub fn pals(&mut self) -> PALS_W<QDC_SPEC> {
304 PALS_W::new(self, 0)
305 }
306 #[doc = "Bit 1 - Phase B Level selector"]
307 #[inline(always)]
308 pub fn pbls(&mut self) -> PBLS_W<QDC_SPEC> {
309 PBLS_W::new(self, 1)
310 }
311 #[doc = "Bit 2 - Phase signals swap"]
312 #[inline(always)]
313 pub fn phs(&mut self) -> PHS_W<QDC_SPEC> {
314 PHS_W::new(self, 2)
315 }
316 #[doc = "Bits 4:5 - Index Marker generations control"]
317 #[inline(always)]
318 pub fn icm(&mut self) -> ICM_W<QDC_SPEC> {
319 ICM_W::new(self, 4)
320 }
321}
322#[doc = "Quadrature Decoder Control\n\nYou can [`read`](crate::Reg::read) this register and get [`qdc::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`qdc::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
323pub struct QDC_SPEC;
324impl crate::RegisterSpec for QDC_SPEC {
325 type Ux = u32;
326}
327#[doc = "`read()` method returns [`qdc::R`](R) reader structure"]
328impl crate::Readable for QDC_SPEC {}
329#[doc = "`write(|w| ..)` method takes [`qdc::W`](W) writer structure"]
330impl crate::Writable for QDC_SPEC {
331 type Safety = crate::Unsafe;
332 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
333 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
334}
335#[doc = "`reset()` method sets QDC to value 0"]
336impl crate::Resettable for QDC_SPEC {
337 const RESET_VALUE: u32 = 0;
338}