py32f0/py32f003/tim3/
ccmr1_input.rs

1///Register `CCMR1_Input` reader
2pub struct R(crate::R<CCMR1_INPUT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CCMR1_INPUT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CCMR1_INPUT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CCMR1_INPUT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16///Register `CCMR1_Input` writer
17pub struct W(crate::W<CCMR1_INPUT_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CCMR1_INPUT_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<CCMR1_INPUT_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CCMR1_INPUT_SPEC>) -> Self {
34        W(writer)
35    }
36}
37///Field `CC1S` reader - Capture/Compare 1 selection
38pub type CC1S_R = crate::FieldReader<u8, CC1S_A>;
39/**Capture/Compare 1 selection
40
41Value on reset: 0*/
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43#[repr(u8)]
44pub enum CC1S_A {
45    ///1: CC1 channel is configured as input, IC1 is mapped on TI1
46    Ti1 = 1,
47    ///2: CC1 channel is configured as input, IC1 is mapped on TI2
48    Ti2 = 2,
49    ///3: CC1 channel is configured as input, IC1 is mapped on TRC
50    Trc = 3,
51}
52impl From<CC1S_A> for u8 {
53    #[inline(always)]
54    fn from(variant: CC1S_A) -> Self {
55        variant as _
56    }
57}
58impl CC1S_R {
59    ///Get enumerated values variant
60    #[inline(always)]
61    pub fn variant(&self) -> Option<CC1S_A> {
62        match self.bits {
63            1 => Some(CC1S_A::Ti1),
64            2 => Some(CC1S_A::Ti2),
65            3 => Some(CC1S_A::Trc),
66            _ => None,
67        }
68    }
69    ///Checks if the value of the field is `Ti1`
70    #[inline(always)]
71    pub fn is_ti1(&self) -> bool {
72        *self == CC1S_A::Ti1
73    }
74    ///Checks if the value of the field is `Ti2`
75    #[inline(always)]
76    pub fn is_ti2(&self) -> bool {
77        *self == CC1S_A::Ti2
78    }
79    ///Checks if the value of the field is `Trc`
80    #[inline(always)]
81    pub fn is_trc(&self) -> bool {
82        *self == CC1S_A::Trc
83    }
84}
85///Field `CC1S` writer - Capture/Compare 1 selection
86pub type CC1S_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCMR1_INPUT_SPEC, u8, CC1S_A, 2, O>;
87impl<'a, const O: u8> CC1S_W<'a, O> {
88    ///CC1 channel is configured as input, IC1 is mapped on TI1
89    #[inline(always)]
90    pub fn ti1(self) -> &'a mut W {
91        self.variant(CC1S_A::Ti1)
92    }
93    ///CC1 channel is configured as input, IC1 is mapped on TI2
94    #[inline(always)]
95    pub fn ti2(self) -> &'a mut W {
96        self.variant(CC1S_A::Ti2)
97    }
98    ///CC1 channel is configured as input, IC1 is mapped on TRC
99    #[inline(always)]
100    pub fn trc(self) -> &'a mut W {
101        self.variant(CC1S_A::Trc)
102    }
103}
104///Field `IC1PSC` reader - Input capture 1 prescaler
105pub type IC1PSC_R = crate::FieldReader<u8, u8>;
106///Field `IC1PSC` writer - Input capture 1 prescaler
107pub type IC1PSC_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCMR1_INPUT_SPEC, u8, u8, 2, O>;
108///Field `IC1F` reader - Input capture 1 filter
109pub type IC1F_R = crate::FieldReader<u8, IC1F_A>;
110/**Input capture 1 filter
111
112Value on reset: 0*/
113#[derive(Clone, Copy, Debug, PartialEq, Eq)]
114#[repr(u8)]
115pub enum IC1F_A {
116    ///0: No filter, sampling is done at fDTS
117    NoFilter = 0,
118    ///1: fSAMPLING=fCK_INT, N=2
119    FckIntN2 = 1,
120    ///2: fSAMPLING=fCK_INT, N=4
121    FckIntN4 = 2,
122    ///3: fSAMPLING=fCK_INT, N=8
123    FckIntN8 = 3,
124    ///4: fSAMPLING=fDTS/2, N=6
125    FdtsDiv2N6 = 4,
126    ///5: fSAMPLING=fDTS/2, N=8
127    FdtsDiv2N8 = 5,
128    ///6: fSAMPLING=fDTS/4, N=6
129    FdtsDiv4N6 = 6,
130    ///7: fSAMPLING=fDTS/4, N=8
131    FdtsDiv4N8 = 7,
132    ///8: fSAMPLING=fDTS/8, N=6
133    FdtsDiv8N6 = 8,
134    ///9: fSAMPLING=fDTS/8, N=8
135    FdtsDiv8N8 = 9,
136    ///10: fSAMPLING=fDTS/16, N=5
137    FdtsDiv16N5 = 10,
138    ///11: fSAMPLING=fDTS/16, N=6
139    FdtsDiv16N6 = 11,
140    ///12: fSAMPLING=fDTS/16, N=8
141    FdtsDiv16N8 = 12,
142    ///13: fSAMPLING=fDTS/32, N=5
143    FdtsDiv32N5 = 13,
144    ///14: fSAMPLING=fDTS/32, N=6
145    FdtsDiv32N6 = 14,
146    ///15: fSAMPLING=fDTS/32, N=8
147    FdtsDiv32N8 = 15,
148}
149impl From<IC1F_A> for u8 {
150    #[inline(always)]
151    fn from(variant: IC1F_A) -> Self {
152        variant as _
153    }
154}
155impl IC1F_R {
156    ///Get enumerated values variant
157    #[inline(always)]
158    pub fn variant(&self) -> IC1F_A {
159        match self.bits {
160            0 => IC1F_A::NoFilter,
161            1 => IC1F_A::FckIntN2,
162            2 => IC1F_A::FckIntN4,
163            3 => IC1F_A::FckIntN8,
164            4 => IC1F_A::FdtsDiv2N6,
165            5 => IC1F_A::FdtsDiv2N8,
166            6 => IC1F_A::FdtsDiv4N6,
167            7 => IC1F_A::FdtsDiv4N8,
168            8 => IC1F_A::FdtsDiv8N6,
169            9 => IC1F_A::FdtsDiv8N8,
170            10 => IC1F_A::FdtsDiv16N5,
171            11 => IC1F_A::FdtsDiv16N6,
172            12 => IC1F_A::FdtsDiv16N8,
173            13 => IC1F_A::FdtsDiv32N5,
174            14 => IC1F_A::FdtsDiv32N6,
175            15 => IC1F_A::FdtsDiv32N8,
176            _ => unreachable!(),
177        }
178    }
179    ///Checks if the value of the field is `NoFilter`
180    #[inline(always)]
181    pub fn is_no_filter(&self) -> bool {
182        *self == IC1F_A::NoFilter
183    }
184    ///Checks if the value of the field is `FckIntN2`
185    #[inline(always)]
186    pub fn is_fck_int_n2(&self) -> bool {
187        *self == IC1F_A::FckIntN2
188    }
189    ///Checks if the value of the field is `FckIntN4`
190    #[inline(always)]
191    pub fn is_fck_int_n4(&self) -> bool {
192        *self == IC1F_A::FckIntN4
193    }
194    ///Checks if the value of the field is `FckIntN8`
195    #[inline(always)]
196    pub fn is_fck_int_n8(&self) -> bool {
197        *self == IC1F_A::FckIntN8
198    }
199    ///Checks if the value of the field is `FdtsDiv2N6`
200    #[inline(always)]
201    pub fn is_fdts_div2_n6(&self) -> bool {
202        *self == IC1F_A::FdtsDiv2N6
203    }
204    ///Checks if the value of the field is `FdtsDiv2N8`
205    #[inline(always)]
206    pub fn is_fdts_div2_n8(&self) -> bool {
207        *self == IC1F_A::FdtsDiv2N8
208    }
209    ///Checks if the value of the field is `FdtsDiv4N6`
210    #[inline(always)]
211    pub fn is_fdts_div4_n6(&self) -> bool {
212        *self == IC1F_A::FdtsDiv4N6
213    }
214    ///Checks if the value of the field is `FdtsDiv4N8`
215    #[inline(always)]
216    pub fn is_fdts_div4_n8(&self) -> bool {
217        *self == IC1F_A::FdtsDiv4N8
218    }
219    ///Checks if the value of the field is `FdtsDiv8N6`
220    #[inline(always)]
221    pub fn is_fdts_div8_n6(&self) -> bool {
222        *self == IC1F_A::FdtsDiv8N6
223    }
224    ///Checks if the value of the field is `FdtsDiv8N8`
225    #[inline(always)]
226    pub fn is_fdts_div8_n8(&self) -> bool {
227        *self == IC1F_A::FdtsDiv8N8
228    }
229    ///Checks if the value of the field is `FdtsDiv16N5`
230    #[inline(always)]
231    pub fn is_fdts_div16_n5(&self) -> bool {
232        *self == IC1F_A::FdtsDiv16N5
233    }
234    ///Checks if the value of the field is `FdtsDiv16N6`
235    #[inline(always)]
236    pub fn is_fdts_div16_n6(&self) -> bool {
237        *self == IC1F_A::FdtsDiv16N6
238    }
239    ///Checks if the value of the field is `FdtsDiv16N8`
240    #[inline(always)]
241    pub fn is_fdts_div16_n8(&self) -> bool {
242        *self == IC1F_A::FdtsDiv16N8
243    }
244    ///Checks if the value of the field is `FdtsDiv32N5`
245    #[inline(always)]
246    pub fn is_fdts_div32_n5(&self) -> bool {
247        *self == IC1F_A::FdtsDiv32N5
248    }
249    ///Checks if the value of the field is `FdtsDiv32N6`
250    #[inline(always)]
251    pub fn is_fdts_div32_n6(&self) -> bool {
252        *self == IC1F_A::FdtsDiv32N6
253    }
254    ///Checks if the value of the field is `FdtsDiv32N8`
255    #[inline(always)]
256    pub fn is_fdts_div32_n8(&self) -> bool {
257        *self == IC1F_A::FdtsDiv32N8
258    }
259}
260///Field `IC1F` writer - Input capture 1 filter
261pub type IC1F_W<'a, const O: u8> =
262    crate::FieldWriterSafe<'a, u32, CCMR1_INPUT_SPEC, u8, IC1F_A, 4, O>;
263impl<'a, const O: u8> IC1F_W<'a, O> {
264    ///No filter, sampling is done at fDTS
265    #[inline(always)]
266    pub fn no_filter(self) -> &'a mut W {
267        self.variant(IC1F_A::NoFilter)
268    }
269    ///fSAMPLING=fCK_INT, N=2
270    #[inline(always)]
271    pub fn fck_int_n2(self) -> &'a mut W {
272        self.variant(IC1F_A::FckIntN2)
273    }
274    ///fSAMPLING=fCK_INT, N=4
275    #[inline(always)]
276    pub fn fck_int_n4(self) -> &'a mut W {
277        self.variant(IC1F_A::FckIntN4)
278    }
279    ///fSAMPLING=fCK_INT, N=8
280    #[inline(always)]
281    pub fn fck_int_n8(self) -> &'a mut W {
282        self.variant(IC1F_A::FckIntN8)
283    }
284    ///fSAMPLING=fDTS/2, N=6
285    #[inline(always)]
286    pub fn fdts_div2_n6(self) -> &'a mut W {
287        self.variant(IC1F_A::FdtsDiv2N6)
288    }
289    ///fSAMPLING=fDTS/2, N=8
290    #[inline(always)]
291    pub fn fdts_div2_n8(self) -> &'a mut W {
292        self.variant(IC1F_A::FdtsDiv2N8)
293    }
294    ///fSAMPLING=fDTS/4, N=6
295    #[inline(always)]
296    pub fn fdts_div4_n6(self) -> &'a mut W {
297        self.variant(IC1F_A::FdtsDiv4N6)
298    }
299    ///fSAMPLING=fDTS/4, N=8
300    #[inline(always)]
301    pub fn fdts_div4_n8(self) -> &'a mut W {
302        self.variant(IC1F_A::FdtsDiv4N8)
303    }
304    ///fSAMPLING=fDTS/8, N=6
305    #[inline(always)]
306    pub fn fdts_div8_n6(self) -> &'a mut W {
307        self.variant(IC1F_A::FdtsDiv8N6)
308    }
309    ///fSAMPLING=fDTS/8, N=8
310    #[inline(always)]
311    pub fn fdts_div8_n8(self) -> &'a mut W {
312        self.variant(IC1F_A::FdtsDiv8N8)
313    }
314    ///fSAMPLING=fDTS/16, N=5
315    #[inline(always)]
316    pub fn fdts_div16_n5(self) -> &'a mut W {
317        self.variant(IC1F_A::FdtsDiv16N5)
318    }
319    ///fSAMPLING=fDTS/16, N=6
320    #[inline(always)]
321    pub fn fdts_div16_n6(self) -> &'a mut W {
322        self.variant(IC1F_A::FdtsDiv16N6)
323    }
324    ///fSAMPLING=fDTS/16, N=8
325    #[inline(always)]
326    pub fn fdts_div16_n8(self) -> &'a mut W {
327        self.variant(IC1F_A::FdtsDiv16N8)
328    }
329    ///fSAMPLING=fDTS/32, N=5
330    #[inline(always)]
331    pub fn fdts_div32_n5(self) -> &'a mut W {
332        self.variant(IC1F_A::FdtsDiv32N5)
333    }
334    ///fSAMPLING=fDTS/32, N=6
335    #[inline(always)]
336    pub fn fdts_div32_n6(self) -> &'a mut W {
337        self.variant(IC1F_A::FdtsDiv32N6)
338    }
339    ///fSAMPLING=fDTS/32, N=8
340    #[inline(always)]
341    pub fn fdts_div32_n8(self) -> &'a mut W {
342        self.variant(IC1F_A::FdtsDiv32N8)
343    }
344}
345///Field `CC2S` reader - Capture/compare 2 selection
346pub type CC2S_R = crate::FieldReader<u8, CC2S_A>;
347/**Capture/compare 2 selection
348
349Value on reset: 0*/
350#[derive(Clone, Copy, Debug, PartialEq, Eq)]
351#[repr(u8)]
352pub enum CC2S_A {
353    ///1: CC2 channel is configured as input, IC2 is mapped on TI2
354    Ti2 = 1,
355    ///2: CC2 channel is configured as input, IC2 is mapped on TI1
356    Ti1 = 2,
357    ///3: CC2 channel is configured as input, IC2 is mapped on TRC
358    Trc = 3,
359}
360impl From<CC2S_A> for u8 {
361    #[inline(always)]
362    fn from(variant: CC2S_A) -> Self {
363        variant as _
364    }
365}
366impl CC2S_R {
367    ///Get enumerated values variant
368    #[inline(always)]
369    pub fn variant(&self) -> Option<CC2S_A> {
370        match self.bits {
371            1 => Some(CC2S_A::Ti2),
372            2 => Some(CC2S_A::Ti1),
373            3 => Some(CC2S_A::Trc),
374            _ => None,
375        }
376    }
377    ///Checks if the value of the field is `Ti2`
378    #[inline(always)]
379    pub fn is_ti2(&self) -> bool {
380        *self == CC2S_A::Ti2
381    }
382    ///Checks if the value of the field is `Ti1`
383    #[inline(always)]
384    pub fn is_ti1(&self) -> bool {
385        *self == CC2S_A::Ti1
386    }
387    ///Checks if the value of the field is `Trc`
388    #[inline(always)]
389    pub fn is_trc(&self) -> bool {
390        *self == CC2S_A::Trc
391    }
392}
393///Field `CC2S` writer - Capture/compare 2 selection
394pub type CC2S_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCMR1_INPUT_SPEC, u8, CC2S_A, 2, O>;
395impl<'a, const O: u8> CC2S_W<'a, O> {
396    ///CC2 channel is configured as input, IC2 is mapped on TI2
397    #[inline(always)]
398    pub fn ti2(self) -> &'a mut W {
399        self.variant(CC2S_A::Ti2)
400    }
401    ///CC2 channel is configured as input, IC2 is mapped on TI1
402    #[inline(always)]
403    pub fn ti1(self) -> &'a mut W {
404        self.variant(CC2S_A::Ti1)
405    }
406    ///CC2 channel is configured as input, IC2 is mapped on TRC
407    #[inline(always)]
408    pub fn trc(self) -> &'a mut W {
409        self.variant(CC2S_A::Trc)
410    }
411}
412///Field `IC2PSC` reader - Input capture 2 prescaler
413pub type IC2PSC_R = crate::FieldReader<u8, u8>;
414///Field `IC2PSC` writer - Input capture 2 prescaler
415pub type IC2PSC_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCMR1_INPUT_SPEC, u8, u8, 2, O>;
416///Field `IC2F` reader - Input capture 2 filter
417pub type IC2F_R = crate::FieldReader<u8, u8>;
418///Field `IC2F` writer - Input capture 2 filter
419pub type IC2F_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, CCMR1_INPUT_SPEC, u8, u8, 4, O>;
420impl R {
421    ///Bits 0:1 - Capture/Compare 1 selection
422    #[inline(always)]
423    pub fn cc1s(&self) -> CC1S_R {
424        CC1S_R::new((self.bits & 3) as u8)
425    }
426    ///Bits 2:3 - Input capture 1 prescaler
427    #[inline(always)]
428    pub fn ic1psc(&self) -> IC1PSC_R {
429        IC1PSC_R::new(((self.bits >> 2) & 3) as u8)
430    }
431    ///Bits 4:7 - Input capture 1 filter
432    #[inline(always)]
433    pub fn ic1f(&self) -> IC1F_R {
434        IC1F_R::new(((self.bits >> 4) & 0x0f) as u8)
435    }
436    ///Bits 8:9 - Capture/compare 2 selection
437    #[inline(always)]
438    pub fn cc2s(&self) -> CC2S_R {
439        CC2S_R::new(((self.bits >> 8) & 3) as u8)
440    }
441    ///Bits 10:11 - Input capture 2 prescaler
442    #[inline(always)]
443    pub fn ic2psc(&self) -> IC2PSC_R {
444        IC2PSC_R::new(((self.bits >> 10) & 3) as u8)
445    }
446    ///Bits 12:15 - Input capture 2 filter
447    #[inline(always)]
448    pub fn ic2f(&self) -> IC2F_R {
449        IC2F_R::new(((self.bits >> 12) & 0x0f) as u8)
450    }
451}
452impl W {
453    ///Bits 0:1 - Capture/Compare 1 selection
454    #[inline(always)]
455    #[must_use]
456    pub fn cc1s(&mut self) -> CC1S_W<0> {
457        CC1S_W::new(self)
458    }
459    ///Bits 2:3 - Input capture 1 prescaler
460    #[inline(always)]
461    #[must_use]
462    pub fn ic1psc(&mut self) -> IC1PSC_W<2> {
463        IC1PSC_W::new(self)
464    }
465    ///Bits 4:7 - Input capture 1 filter
466    #[inline(always)]
467    #[must_use]
468    pub fn ic1f(&mut self) -> IC1F_W<4> {
469        IC1F_W::new(self)
470    }
471    ///Bits 8:9 - Capture/compare 2 selection
472    #[inline(always)]
473    #[must_use]
474    pub fn cc2s(&mut self) -> CC2S_W<8> {
475        CC2S_W::new(self)
476    }
477    ///Bits 10:11 - Input capture 2 prescaler
478    #[inline(always)]
479    #[must_use]
480    pub fn ic2psc(&mut self) -> IC2PSC_W<10> {
481        IC2PSC_W::new(self)
482    }
483    ///Bits 12:15 - Input capture 2 filter
484    #[inline(always)]
485    #[must_use]
486    pub fn ic2f(&mut self) -> IC2F_W<12> {
487        IC2F_W::new(self)
488    }
489    ///Writes raw bits to the register.
490    #[inline(always)]
491    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
492        self.0.bits(bits);
493        self
494    }
495}
496/**capture/compare mode register 1 (input mode)
497
498This register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).
499
500For information about available fields see [ccmr1_input](index.html) module*/
501pub struct CCMR1_INPUT_SPEC;
502impl crate::RegisterSpec for CCMR1_INPUT_SPEC {
503    type Ux = u32;
504}
505///`read()` method returns [ccmr1_input::R](R) reader structure
506impl crate::Readable for CCMR1_INPUT_SPEC {
507    type Reader = R;
508}
509///`write(|w| ..)` method takes [ccmr1_input::W](W) writer structure
510impl crate::Writable for CCMR1_INPUT_SPEC {
511    type Writer = W;
512    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
513    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
514}
515///`reset()` method sets CCMR1_Input to value 0
516impl crate::Resettable for CCMR1_INPUT_SPEC {
517    const RESET_VALUE: Self::Ux = 0;
518}