stm32f0/stm32f0x2/tim2/
ccmr1_input.rs

1#[doc = "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#[doc = "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#[doc = "Field `IC2F` reader - Input capture 2 filter"]
38pub type IC2F_R = crate::FieldReader<u8, u8>;
39#[doc = "Field `IC2F` writer - Input capture 2 filter"]
40pub type IC2F_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u32, CCMR1_INPUT_SPEC, u8, u8, 4, O>;
41#[doc = "Field `IC2PSC` reader - Input capture 2 prescaler"]
42pub type IC2PSC_R = crate::FieldReader<u8, u8>;
43#[doc = "Field `IC2PSC` writer - Input capture 2 prescaler"]
44pub type IC2PSC_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCMR1_INPUT_SPEC, u8, u8, 2, O>;
45#[doc = "Capture/compare 2 selection\n\nValue on reset: 0"]
46#[derive(Clone, Copy, Debug, PartialEq)]
47#[repr(u8)]
48pub enum CC2S_A {
49    #[doc = "1: CC2 channel is configured as input, IC2 is mapped on TI2"]
50    Ti2 = 1,
51    #[doc = "2: CC2 channel is configured as input, IC2 is mapped on TI1"]
52    Ti1 = 2,
53    #[doc = "3: CC2 channel is configured as input, IC2 is mapped on TRC"]
54    Trc = 3,
55}
56impl From<CC2S_A> for u8 {
57    #[inline(always)]
58    fn from(variant: CC2S_A) -> Self {
59        variant as _
60    }
61}
62#[doc = "Field `CC2S` reader - Capture/compare 2 selection"]
63pub type CC2S_R = crate::FieldReader<u8, CC2S_A>;
64impl CC2S_R {
65    #[doc = "Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<CC2S_A> {
68        match self.bits {
69            1 => Some(CC2S_A::Ti2),
70            2 => Some(CC2S_A::Ti1),
71            3 => Some(CC2S_A::Trc),
72            _ => None,
73        }
74    }
75    #[doc = "Checks if the value of the field is `Ti2`"]
76    #[inline(always)]
77    pub fn is_ti2(&self) -> bool {
78        *self == CC2S_A::Ti2
79    }
80    #[doc = "Checks if the value of the field is `Ti1`"]
81    #[inline(always)]
82    pub fn is_ti1(&self) -> bool {
83        *self == CC2S_A::Ti1
84    }
85    #[doc = "Checks if the value of the field is `Trc`"]
86    #[inline(always)]
87    pub fn is_trc(&self) -> bool {
88        *self == CC2S_A::Trc
89    }
90}
91#[doc = "Field `CC2S` writer - Capture/compare 2 selection"]
92pub type CC2S_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCMR1_INPUT_SPEC, u8, CC2S_A, 2, O>;
93impl<'a, const O: u8> CC2S_W<'a, O> {
94    #[doc = "CC2 channel is configured as input, IC2 is mapped on TI2"]
95    #[inline(always)]
96    pub fn ti2(self) -> &'a mut W {
97        self.variant(CC2S_A::Ti2)
98    }
99    #[doc = "CC2 channel is configured as input, IC2 is mapped on TI1"]
100    #[inline(always)]
101    pub fn ti1(self) -> &'a mut W {
102        self.variant(CC2S_A::Ti1)
103    }
104    #[doc = "CC2 channel is configured as input, IC2 is mapped on TRC"]
105    #[inline(always)]
106    pub fn trc(self) -> &'a mut W {
107        self.variant(CC2S_A::Trc)
108    }
109}
110#[doc = "Input capture 1 filter\n\nValue on reset: 0"]
111#[derive(Clone, Copy, Debug, PartialEq)]
112#[repr(u8)]
113pub enum IC1F_A {
114    #[doc = "0: No filter, sampling is done at fDTS"]
115    NoFilter = 0,
116    #[doc = "1: fSAMPLING=fCK_INT, N=2"]
117    FckIntN2 = 1,
118    #[doc = "2: fSAMPLING=fCK_INT, N=4"]
119    FckIntN4 = 2,
120    #[doc = "3: fSAMPLING=fCK_INT, N=8"]
121    FckIntN8 = 3,
122    #[doc = "4: fSAMPLING=fDTS/2, N=6"]
123    FdtsDiv2N6 = 4,
124    #[doc = "5: fSAMPLING=fDTS/2, N=8"]
125    FdtsDiv2N8 = 5,
126    #[doc = "6: fSAMPLING=fDTS/4, N=6"]
127    FdtsDiv4N6 = 6,
128    #[doc = "7: fSAMPLING=fDTS/4, N=8"]
129    FdtsDiv4N8 = 7,
130    #[doc = "8: fSAMPLING=fDTS/8, N=6"]
131    FdtsDiv8N6 = 8,
132    #[doc = "9: fSAMPLING=fDTS/8, N=8"]
133    FdtsDiv8N8 = 9,
134    #[doc = "10: fSAMPLING=fDTS/16, N=5"]
135    FdtsDiv16N5 = 10,
136    #[doc = "11: fSAMPLING=fDTS/16, N=6"]
137    FdtsDiv16N6 = 11,
138    #[doc = "12: fSAMPLING=fDTS/16, N=8"]
139    FdtsDiv16N8 = 12,
140    #[doc = "13: fSAMPLING=fDTS/32, N=5"]
141    FdtsDiv32N5 = 13,
142    #[doc = "14: fSAMPLING=fDTS/32, N=6"]
143    FdtsDiv32N6 = 14,
144    #[doc = "15: fSAMPLING=fDTS/32, N=8"]
145    FdtsDiv32N8 = 15,
146}
147impl From<IC1F_A> for u8 {
148    #[inline(always)]
149    fn from(variant: IC1F_A) -> Self {
150        variant as _
151    }
152}
153#[doc = "Field `IC1F` reader - Input capture 1 filter"]
154pub type IC1F_R = crate::FieldReader<u8, IC1F_A>;
155impl IC1F_R {
156    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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#[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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    #[doc = "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#[doc = "Field `IC1PSC` reader - Input capture 1 prescaler"]
346pub type IC1PSC_R = crate::FieldReader<u8, u8>;
347#[doc = "Field `IC1PSC` writer - Input capture 1 prescaler"]
348pub type IC1PSC_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCMR1_INPUT_SPEC, u8, u8, 2, O>;
349#[doc = "Capture/Compare 1 selection\n\nValue on reset: 0"]
350#[derive(Clone, Copy, Debug, PartialEq)]
351#[repr(u8)]
352pub enum CC1S_A {
353    #[doc = "1: CC1 channel is configured as input, IC1 is mapped on TI1"]
354    Ti1 = 1,
355    #[doc = "2: CC1 channel is configured as input, IC1 is mapped on TI2"]
356    Ti2 = 2,
357    #[doc = "3: CC1 channel is configured as input, IC1 is mapped on TRC"]
358    Trc = 3,
359}
360impl From<CC1S_A> for u8 {
361    #[inline(always)]
362    fn from(variant: CC1S_A) -> Self {
363        variant as _
364    }
365}
366#[doc = "Field `CC1S` reader - Capture/Compare 1 selection"]
367pub type CC1S_R = crate::FieldReader<u8, CC1S_A>;
368impl CC1S_R {
369    #[doc = "Get enumerated values variant"]
370    #[inline(always)]
371    pub fn variant(&self) -> Option<CC1S_A> {
372        match self.bits {
373            1 => Some(CC1S_A::Ti1),
374            2 => Some(CC1S_A::Ti2),
375            3 => Some(CC1S_A::Trc),
376            _ => None,
377        }
378    }
379    #[doc = "Checks if the value of the field is `Ti1`"]
380    #[inline(always)]
381    pub fn is_ti1(&self) -> bool {
382        *self == CC1S_A::Ti1
383    }
384    #[doc = "Checks if the value of the field is `Ti2`"]
385    #[inline(always)]
386    pub fn is_ti2(&self) -> bool {
387        *self == CC1S_A::Ti2
388    }
389    #[doc = "Checks if the value of the field is `Trc`"]
390    #[inline(always)]
391    pub fn is_trc(&self) -> bool {
392        *self == CC1S_A::Trc
393    }
394}
395#[doc = "Field `CC1S` writer - Capture/Compare 1 selection"]
396pub type CC1S_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CCMR1_INPUT_SPEC, u8, CC1S_A, 2, O>;
397impl<'a, const O: u8> CC1S_W<'a, O> {
398    #[doc = "CC1 channel is configured as input, IC1 is mapped on TI1"]
399    #[inline(always)]
400    pub fn ti1(self) -> &'a mut W {
401        self.variant(CC1S_A::Ti1)
402    }
403    #[doc = "CC1 channel is configured as input, IC1 is mapped on TI2"]
404    #[inline(always)]
405    pub fn ti2(self) -> &'a mut W {
406        self.variant(CC1S_A::Ti2)
407    }
408    #[doc = "CC1 channel is configured as input, IC1 is mapped on TRC"]
409    #[inline(always)]
410    pub fn trc(self) -> &'a mut W {
411        self.variant(CC1S_A::Trc)
412    }
413}
414impl R {
415    #[doc = "Bits 12:15 - Input capture 2 filter"]
416    #[inline(always)]
417    pub fn ic2f(&self) -> IC2F_R {
418        IC2F_R::new(((self.bits >> 12) & 0x0f) as u8)
419    }
420    #[doc = "Bits 10:11 - Input capture 2 prescaler"]
421    #[inline(always)]
422    pub fn ic2psc(&self) -> IC2PSC_R {
423        IC2PSC_R::new(((self.bits >> 10) & 3) as u8)
424    }
425    #[doc = "Bits 8:9 - Capture/compare 2 selection"]
426    #[inline(always)]
427    pub fn cc2s(&self) -> CC2S_R {
428        CC2S_R::new(((self.bits >> 8) & 3) as u8)
429    }
430    #[doc = "Bits 4:7 - Input capture 1 filter"]
431    #[inline(always)]
432    pub fn ic1f(&self) -> IC1F_R {
433        IC1F_R::new(((self.bits >> 4) & 0x0f) as u8)
434    }
435    #[doc = "Bits 2:3 - Input capture 1 prescaler"]
436    #[inline(always)]
437    pub fn ic1psc(&self) -> IC1PSC_R {
438        IC1PSC_R::new(((self.bits >> 2) & 3) as u8)
439    }
440    #[doc = "Bits 0:1 - Capture/Compare 1 selection"]
441    #[inline(always)]
442    pub fn cc1s(&self) -> CC1S_R {
443        CC1S_R::new((self.bits & 3) as u8)
444    }
445}
446impl W {
447    #[doc = "Bits 12:15 - Input capture 2 filter"]
448    #[inline(always)]
449    pub fn ic2f(&mut self) -> IC2F_W<12> {
450        IC2F_W::new(self)
451    }
452    #[doc = "Bits 10:11 - Input capture 2 prescaler"]
453    #[inline(always)]
454    pub fn ic2psc(&mut self) -> IC2PSC_W<10> {
455        IC2PSC_W::new(self)
456    }
457    #[doc = "Bits 8:9 - Capture/compare 2 selection"]
458    #[inline(always)]
459    pub fn cc2s(&mut self) -> CC2S_W<8> {
460        CC2S_W::new(self)
461    }
462    #[doc = "Bits 4:7 - Input capture 1 filter"]
463    #[inline(always)]
464    pub fn ic1f(&mut self) -> IC1F_W<4> {
465        IC1F_W::new(self)
466    }
467    #[doc = "Bits 2:3 - Input capture 1 prescaler"]
468    #[inline(always)]
469    pub fn ic1psc(&mut self) -> IC1PSC_W<2> {
470        IC1PSC_W::new(self)
471    }
472    #[doc = "Bits 0:1 - Capture/Compare 1 selection"]
473    #[inline(always)]
474    pub fn cc1s(&mut self) -> CC1S_W<0> {
475        CC1S_W::new(self)
476    }
477    #[doc = "Writes raw bits to the register."]
478    #[inline(always)]
479    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
480        self.0.bits(bits);
481        self
482    }
483}
484#[doc = "capture/compare mode register 1 (input mode)\n\nThis 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).\n\nFor information about available fields see [ccmr1_input](index.html) module"]
485pub struct CCMR1_INPUT_SPEC;
486impl crate::RegisterSpec for CCMR1_INPUT_SPEC {
487    type Ux = u32;
488}
489#[doc = "`read()` method returns [ccmr1_input::R](R) reader structure"]
490impl crate::Readable for CCMR1_INPUT_SPEC {
491    type Reader = R;
492}
493#[doc = "`write(|w| ..)` method takes [ccmr1_input::W](W) writer structure"]
494impl crate::Writable for CCMR1_INPUT_SPEC {
495    type Writer = W;
496}
497#[doc = "`reset()` method sets CCMR1_Input to value 0"]
498impl crate::Resettable for CCMR1_INPUT_SPEC {
499    #[inline(always)]
500    fn reset_value() -> Self::Ux {
501        0
502    }
503}