stm32l4x2_pac/lptim1/
cfgr.rs

1#[doc = r" Value read from the register"]
2pub struct R {
3    bits: u32,
4}
5#[doc = r" Value to write to the register"]
6pub struct W {
7    bits: u32,
8}
9impl super::CFGR {
10    #[doc = r" Modifies the contents of the register"]
11    #[inline]
12    pub fn modify<F>(&self, f: F)
13    where
14        for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
15    {
16        let bits = self.register.get();
17        let r = R { bits: bits };
18        let mut w = W { bits: bits };
19        f(&r, &mut w);
20        self.register.set(w.bits);
21    }
22    #[doc = r" Reads the contents of the register"]
23    #[inline]
24    pub fn read(&self) -> R {
25        R {
26            bits: self.register.get(),
27        }
28    }
29    #[doc = r" Writes to the register"]
30    #[inline]
31    pub fn write<F>(&self, f: F)
32    where
33        F: FnOnce(&mut W) -> &mut W,
34    {
35        let mut w = W::reset_value();
36        f(&mut w);
37        self.register.set(w.bits);
38    }
39    #[doc = r" Writes the reset value to the register"]
40    #[inline]
41    pub fn reset(&self) {
42        self.write(|w| w)
43    }
44}
45#[doc = r" Value of the field"]
46pub struct ENCR {
47    bits: bool,
48}
49impl ENCR {
50    #[doc = r" Value of the field as raw bits"]
51    #[inline]
52    pub fn bit(&self) -> bool {
53        self.bits
54    }
55    #[doc = r" Returns `true` if the bit is clear (0)"]
56    #[inline]
57    pub fn bit_is_clear(&self) -> bool {
58        !self.bit()
59    }
60    #[doc = r" Returns `true` if the bit is set (1)"]
61    #[inline]
62    pub fn bit_is_set(&self) -> bool {
63        self.bit()
64    }
65}
66#[doc = r" Value of the field"]
67pub struct COUNTMODER {
68    bits: bool,
69}
70impl COUNTMODER {
71    #[doc = r" Value of the field as raw bits"]
72    #[inline]
73    pub fn bit(&self) -> bool {
74        self.bits
75    }
76    #[doc = r" Returns `true` if the bit is clear (0)"]
77    #[inline]
78    pub fn bit_is_clear(&self) -> bool {
79        !self.bit()
80    }
81    #[doc = r" Returns `true` if the bit is set (1)"]
82    #[inline]
83    pub fn bit_is_set(&self) -> bool {
84        self.bit()
85    }
86}
87#[doc = r" Value of the field"]
88pub struct PRELOADR {
89    bits: bool,
90}
91impl PRELOADR {
92    #[doc = r" Value of the field as raw bits"]
93    #[inline]
94    pub fn bit(&self) -> bool {
95        self.bits
96    }
97    #[doc = r" Returns `true` if the bit is clear (0)"]
98    #[inline]
99    pub fn bit_is_clear(&self) -> bool {
100        !self.bit()
101    }
102    #[doc = r" Returns `true` if the bit is set (1)"]
103    #[inline]
104    pub fn bit_is_set(&self) -> bool {
105        self.bit()
106    }
107}
108#[doc = r" Value of the field"]
109pub struct WAVPOLR {
110    bits: bool,
111}
112impl WAVPOLR {
113    #[doc = r" Value of the field as raw bits"]
114    #[inline]
115    pub fn bit(&self) -> bool {
116        self.bits
117    }
118    #[doc = r" Returns `true` if the bit is clear (0)"]
119    #[inline]
120    pub fn bit_is_clear(&self) -> bool {
121        !self.bit()
122    }
123    #[doc = r" Returns `true` if the bit is set (1)"]
124    #[inline]
125    pub fn bit_is_set(&self) -> bool {
126        self.bit()
127    }
128}
129#[doc = r" Value of the field"]
130pub struct WAVER {
131    bits: bool,
132}
133impl WAVER {
134    #[doc = r" Value of the field as raw bits"]
135    #[inline]
136    pub fn bit(&self) -> bool {
137        self.bits
138    }
139    #[doc = r" Returns `true` if the bit is clear (0)"]
140    #[inline]
141    pub fn bit_is_clear(&self) -> bool {
142        !self.bit()
143    }
144    #[doc = r" Returns `true` if the bit is set (1)"]
145    #[inline]
146    pub fn bit_is_set(&self) -> bool {
147        self.bit()
148    }
149}
150#[doc = r" Value of the field"]
151pub struct TIMOUTR {
152    bits: bool,
153}
154impl TIMOUTR {
155    #[doc = r" Value of the field as raw bits"]
156    #[inline]
157    pub fn bit(&self) -> bool {
158        self.bits
159    }
160    #[doc = r" Returns `true` if the bit is clear (0)"]
161    #[inline]
162    pub fn bit_is_clear(&self) -> bool {
163        !self.bit()
164    }
165    #[doc = r" Returns `true` if the bit is set (1)"]
166    #[inline]
167    pub fn bit_is_set(&self) -> bool {
168        self.bit()
169    }
170}
171#[doc = r" Value of the field"]
172pub struct TRIGENR {
173    bits: u8,
174}
175impl TRIGENR {
176    #[doc = r" Value of the field as raw bits"]
177    #[inline]
178    pub fn bits(&self) -> u8 {
179        self.bits
180    }
181}
182#[doc = r" Value of the field"]
183pub struct TRIGSELR {
184    bits: u8,
185}
186impl TRIGSELR {
187    #[doc = r" Value of the field as raw bits"]
188    #[inline]
189    pub fn bits(&self) -> u8 {
190        self.bits
191    }
192}
193#[doc = r" Value of the field"]
194pub struct PRESCR {
195    bits: u8,
196}
197impl PRESCR {
198    #[doc = r" Value of the field as raw bits"]
199    #[inline]
200    pub fn bits(&self) -> u8 {
201        self.bits
202    }
203}
204#[doc = r" Value of the field"]
205pub struct TRGFLTR {
206    bits: u8,
207}
208impl TRGFLTR {
209    #[doc = r" Value of the field as raw bits"]
210    #[inline]
211    pub fn bits(&self) -> u8 {
212        self.bits
213    }
214}
215#[doc = r" Value of the field"]
216pub struct CKFLTR {
217    bits: u8,
218}
219impl CKFLTR {
220    #[doc = r" Value of the field as raw bits"]
221    #[inline]
222    pub fn bits(&self) -> u8 {
223        self.bits
224    }
225}
226#[doc = r" Value of the field"]
227pub struct CKPOLR {
228    bits: u8,
229}
230impl CKPOLR {
231    #[doc = r" Value of the field as raw bits"]
232    #[inline]
233    pub fn bits(&self) -> u8 {
234        self.bits
235    }
236}
237#[doc = r" Value of the field"]
238pub struct CKSELR {
239    bits: bool,
240}
241impl CKSELR {
242    #[doc = r" Value of the field as raw bits"]
243    #[inline]
244    pub fn bit(&self) -> bool {
245        self.bits
246    }
247    #[doc = r" Returns `true` if the bit is clear (0)"]
248    #[inline]
249    pub fn bit_is_clear(&self) -> bool {
250        !self.bit()
251    }
252    #[doc = r" Returns `true` if the bit is set (1)"]
253    #[inline]
254    pub fn bit_is_set(&self) -> bool {
255        self.bit()
256    }
257}
258#[doc = r" Proxy"]
259pub struct _ENCW<'a> {
260    w: &'a mut W,
261}
262impl<'a> _ENCW<'a> {
263    #[doc = r" Sets the field bit"]
264    pub fn set_bit(self) -> &'a mut W {
265        self.bit(true)
266    }
267    #[doc = r" Clears the field bit"]
268    pub fn clear_bit(self) -> &'a mut W {
269        self.bit(false)
270    }
271    #[doc = r" Writes raw bits to the field"]
272    #[inline]
273    pub fn bit(self, value: bool) -> &'a mut W {
274        const MASK: bool = true;
275        const OFFSET: u8 = 24;
276        self.w.bits &= !((MASK as u32) << OFFSET);
277        self.w.bits |= ((value & MASK) as u32) << OFFSET;
278        self.w
279    }
280}
281#[doc = r" Proxy"]
282pub struct _COUNTMODEW<'a> {
283    w: &'a mut W,
284}
285impl<'a> _COUNTMODEW<'a> {
286    #[doc = r" Sets the field bit"]
287    pub fn set_bit(self) -> &'a mut W {
288        self.bit(true)
289    }
290    #[doc = r" Clears the field bit"]
291    pub fn clear_bit(self) -> &'a mut W {
292        self.bit(false)
293    }
294    #[doc = r" Writes raw bits to the field"]
295    #[inline]
296    pub fn bit(self, value: bool) -> &'a mut W {
297        const MASK: bool = true;
298        const OFFSET: u8 = 23;
299        self.w.bits &= !((MASK as u32) << OFFSET);
300        self.w.bits |= ((value & MASK) as u32) << OFFSET;
301        self.w
302    }
303}
304#[doc = r" Proxy"]
305pub struct _PRELOADW<'a> {
306    w: &'a mut W,
307}
308impl<'a> _PRELOADW<'a> {
309    #[doc = r" Sets the field bit"]
310    pub fn set_bit(self) -> &'a mut W {
311        self.bit(true)
312    }
313    #[doc = r" Clears the field bit"]
314    pub fn clear_bit(self) -> &'a mut W {
315        self.bit(false)
316    }
317    #[doc = r" Writes raw bits to the field"]
318    #[inline]
319    pub fn bit(self, value: bool) -> &'a mut W {
320        const MASK: bool = true;
321        const OFFSET: u8 = 22;
322        self.w.bits &= !((MASK as u32) << OFFSET);
323        self.w.bits |= ((value & MASK) as u32) << OFFSET;
324        self.w
325    }
326}
327#[doc = r" Proxy"]
328pub struct _WAVPOLW<'a> {
329    w: &'a mut W,
330}
331impl<'a> _WAVPOLW<'a> {
332    #[doc = r" Sets the field bit"]
333    pub fn set_bit(self) -> &'a mut W {
334        self.bit(true)
335    }
336    #[doc = r" Clears the field bit"]
337    pub fn clear_bit(self) -> &'a mut W {
338        self.bit(false)
339    }
340    #[doc = r" Writes raw bits to the field"]
341    #[inline]
342    pub fn bit(self, value: bool) -> &'a mut W {
343        const MASK: bool = true;
344        const OFFSET: u8 = 21;
345        self.w.bits &= !((MASK as u32) << OFFSET);
346        self.w.bits |= ((value & MASK) as u32) << OFFSET;
347        self.w
348    }
349}
350#[doc = r" Proxy"]
351pub struct _WAVEW<'a> {
352    w: &'a mut W,
353}
354impl<'a> _WAVEW<'a> {
355    #[doc = r" Sets the field bit"]
356    pub fn set_bit(self) -> &'a mut W {
357        self.bit(true)
358    }
359    #[doc = r" Clears the field bit"]
360    pub fn clear_bit(self) -> &'a mut W {
361        self.bit(false)
362    }
363    #[doc = r" Writes raw bits to the field"]
364    #[inline]
365    pub fn bit(self, value: bool) -> &'a mut W {
366        const MASK: bool = true;
367        const OFFSET: u8 = 20;
368        self.w.bits &= !((MASK as u32) << OFFSET);
369        self.w.bits |= ((value & MASK) as u32) << OFFSET;
370        self.w
371    }
372}
373#[doc = r" Proxy"]
374pub struct _TIMOUTW<'a> {
375    w: &'a mut W,
376}
377impl<'a> _TIMOUTW<'a> {
378    #[doc = r" Sets the field bit"]
379    pub fn set_bit(self) -> &'a mut W {
380        self.bit(true)
381    }
382    #[doc = r" Clears the field bit"]
383    pub fn clear_bit(self) -> &'a mut W {
384        self.bit(false)
385    }
386    #[doc = r" Writes raw bits to the field"]
387    #[inline]
388    pub fn bit(self, value: bool) -> &'a mut W {
389        const MASK: bool = true;
390        const OFFSET: u8 = 19;
391        self.w.bits &= !((MASK as u32) << OFFSET);
392        self.w.bits |= ((value & MASK) as u32) << OFFSET;
393        self.w
394    }
395}
396#[doc = r" Proxy"]
397pub struct _TRIGENW<'a> {
398    w: &'a mut W,
399}
400impl<'a> _TRIGENW<'a> {
401    #[doc = r" Writes raw bits to the field"]
402    #[inline]
403    pub unsafe fn bits(self, value: u8) -> &'a mut W {
404        const MASK: u8 = 3;
405        const OFFSET: u8 = 17;
406        self.w.bits &= !((MASK as u32) << OFFSET);
407        self.w.bits |= ((value & MASK) as u32) << OFFSET;
408        self.w
409    }
410}
411#[doc = r" Proxy"]
412pub struct _TRIGSELW<'a> {
413    w: &'a mut W,
414}
415impl<'a> _TRIGSELW<'a> {
416    #[doc = r" Writes raw bits to the field"]
417    #[inline]
418    pub unsafe fn bits(self, value: u8) -> &'a mut W {
419        const MASK: u8 = 7;
420        const OFFSET: u8 = 13;
421        self.w.bits &= !((MASK as u32) << OFFSET);
422        self.w.bits |= ((value & MASK) as u32) << OFFSET;
423        self.w
424    }
425}
426#[doc = r" Proxy"]
427pub struct _PRESCW<'a> {
428    w: &'a mut W,
429}
430impl<'a> _PRESCW<'a> {
431    #[doc = r" Writes raw bits to the field"]
432    #[inline]
433    pub unsafe fn bits(self, value: u8) -> &'a mut W {
434        const MASK: u8 = 7;
435        const OFFSET: u8 = 9;
436        self.w.bits &= !((MASK as u32) << OFFSET);
437        self.w.bits |= ((value & MASK) as u32) << OFFSET;
438        self.w
439    }
440}
441#[doc = r" Proxy"]
442pub struct _TRGFLTW<'a> {
443    w: &'a mut W,
444}
445impl<'a> _TRGFLTW<'a> {
446    #[doc = r" Writes raw bits to the field"]
447    #[inline]
448    pub unsafe fn bits(self, value: u8) -> &'a mut W {
449        const MASK: u8 = 3;
450        const OFFSET: u8 = 6;
451        self.w.bits &= !((MASK as u32) << OFFSET);
452        self.w.bits |= ((value & MASK) as u32) << OFFSET;
453        self.w
454    }
455}
456#[doc = r" Proxy"]
457pub struct _CKFLTW<'a> {
458    w: &'a mut W,
459}
460impl<'a> _CKFLTW<'a> {
461    #[doc = r" Writes raw bits to the field"]
462    #[inline]
463    pub unsafe fn bits(self, value: u8) -> &'a mut W {
464        const MASK: u8 = 3;
465        const OFFSET: u8 = 3;
466        self.w.bits &= !((MASK as u32) << OFFSET);
467        self.w.bits |= ((value & MASK) as u32) << OFFSET;
468        self.w
469    }
470}
471#[doc = r" Proxy"]
472pub struct _CKPOLW<'a> {
473    w: &'a mut W,
474}
475impl<'a> _CKPOLW<'a> {
476    #[doc = r" Writes raw bits to the field"]
477    #[inline]
478    pub unsafe fn bits(self, value: u8) -> &'a mut W {
479        const MASK: u8 = 3;
480        const OFFSET: u8 = 1;
481        self.w.bits &= !((MASK as u32) << OFFSET);
482        self.w.bits |= ((value & MASK) as u32) << OFFSET;
483        self.w
484    }
485}
486#[doc = r" Proxy"]
487pub struct _CKSELW<'a> {
488    w: &'a mut W,
489}
490impl<'a> _CKSELW<'a> {
491    #[doc = r" Sets the field bit"]
492    pub fn set_bit(self) -> &'a mut W {
493        self.bit(true)
494    }
495    #[doc = r" Clears the field bit"]
496    pub fn clear_bit(self) -> &'a mut W {
497        self.bit(false)
498    }
499    #[doc = r" Writes raw bits to the field"]
500    #[inline]
501    pub fn bit(self, value: bool) -> &'a mut W {
502        const MASK: bool = true;
503        const OFFSET: u8 = 0;
504        self.w.bits &= !((MASK as u32) << OFFSET);
505        self.w.bits |= ((value & MASK) as u32) << OFFSET;
506        self.w
507    }
508}
509impl R {
510    #[doc = r" Value of the register as raw bits"]
511    #[inline]
512    pub fn bits(&self) -> u32 {
513        self.bits
514    }
515    #[doc = "Bit 24 - Encoder mode enable"]
516    #[inline]
517    pub fn enc(&self) -> ENCR {
518        let bits = {
519            const MASK: bool = true;
520            const OFFSET: u8 = 24;
521            ((self.bits >> OFFSET) & MASK as u32) != 0
522        };
523        ENCR { bits }
524    }
525    #[doc = "Bit 23 - counter mode enabled"]
526    #[inline]
527    pub fn countmode(&self) -> COUNTMODER {
528        let bits = {
529            const MASK: bool = true;
530            const OFFSET: u8 = 23;
531            ((self.bits >> OFFSET) & MASK as u32) != 0
532        };
533        COUNTMODER { bits }
534    }
535    #[doc = "Bit 22 - Registers update mode"]
536    #[inline]
537    pub fn preload(&self) -> PRELOADR {
538        let bits = {
539            const MASK: bool = true;
540            const OFFSET: u8 = 22;
541            ((self.bits >> OFFSET) & MASK as u32) != 0
542        };
543        PRELOADR { bits }
544    }
545    #[doc = "Bit 21 - Waveform shape polarity"]
546    #[inline]
547    pub fn wavpol(&self) -> WAVPOLR {
548        let bits = {
549            const MASK: bool = true;
550            const OFFSET: u8 = 21;
551            ((self.bits >> OFFSET) & MASK as u32) != 0
552        };
553        WAVPOLR { bits }
554    }
555    #[doc = "Bit 20 - Waveform shape"]
556    #[inline]
557    pub fn wave(&self) -> WAVER {
558        let bits = {
559            const MASK: bool = true;
560            const OFFSET: u8 = 20;
561            ((self.bits >> OFFSET) & MASK as u32) != 0
562        };
563        WAVER { bits }
564    }
565    #[doc = "Bit 19 - Timeout enable"]
566    #[inline]
567    pub fn timout(&self) -> TIMOUTR {
568        let bits = {
569            const MASK: bool = true;
570            const OFFSET: u8 = 19;
571            ((self.bits >> OFFSET) & MASK as u32) != 0
572        };
573        TIMOUTR { bits }
574    }
575    #[doc = "Bits 17:18 - Trigger enable and polarity"]
576    #[inline]
577    pub fn trigen(&self) -> TRIGENR {
578        let bits = {
579            const MASK: u8 = 3;
580            const OFFSET: u8 = 17;
581            ((self.bits >> OFFSET) & MASK as u32) as u8
582        };
583        TRIGENR { bits }
584    }
585    #[doc = "Bits 13:15 - Trigger selector"]
586    #[inline]
587    pub fn trigsel(&self) -> TRIGSELR {
588        let bits = {
589            const MASK: u8 = 7;
590            const OFFSET: u8 = 13;
591            ((self.bits >> OFFSET) & MASK as u32) as u8
592        };
593        TRIGSELR { bits }
594    }
595    #[doc = "Bits 9:11 - Clock prescaler"]
596    #[inline]
597    pub fn presc(&self) -> PRESCR {
598        let bits = {
599            const MASK: u8 = 7;
600            const OFFSET: u8 = 9;
601            ((self.bits >> OFFSET) & MASK as u32) as u8
602        };
603        PRESCR { bits }
604    }
605    #[doc = "Bits 6:7 - Configurable digital filter for trigger"]
606    #[inline]
607    pub fn trgflt(&self) -> TRGFLTR {
608        let bits = {
609            const MASK: u8 = 3;
610            const OFFSET: u8 = 6;
611            ((self.bits >> OFFSET) & MASK as u32) as u8
612        };
613        TRGFLTR { bits }
614    }
615    #[doc = "Bits 3:4 - Configurable digital filter for external clock"]
616    #[inline]
617    pub fn ckflt(&self) -> CKFLTR {
618        let bits = {
619            const MASK: u8 = 3;
620            const OFFSET: u8 = 3;
621            ((self.bits >> OFFSET) & MASK as u32) as u8
622        };
623        CKFLTR { bits }
624    }
625    #[doc = "Bits 1:2 - Clock Polarity"]
626    #[inline]
627    pub fn ckpol(&self) -> CKPOLR {
628        let bits = {
629            const MASK: u8 = 3;
630            const OFFSET: u8 = 1;
631            ((self.bits >> OFFSET) & MASK as u32) as u8
632        };
633        CKPOLR { bits }
634    }
635    #[doc = "Bit 0 - Clock selector"]
636    #[inline]
637    pub fn cksel(&self) -> CKSELR {
638        let bits = {
639            const MASK: bool = true;
640            const OFFSET: u8 = 0;
641            ((self.bits >> OFFSET) & MASK as u32) != 0
642        };
643        CKSELR { bits }
644    }
645}
646impl W {
647    #[doc = r" Reset value of the register"]
648    #[inline]
649    pub fn reset_value() -> W {
650        W { bits: 0 }
651    }
652    #[doc = r" Writes raw bits to the register"]
653    #[inline]
654    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
655        self.bits = bits;
656        self
657    }
658    #[doc = "Bit 24 - Encoder mode enable"]
659    #[inline]
660    pub fn enc(&mut self) -> _ENCW {
661        _ENCW { w: self }
662    }
663    #[doc = "Bit 23 - counter mode enabled"]
664    #[inline]
665    pub fn countmode(&mut self) -> _COUNTMODEW {
666        _COUNTMODEW { w: self }
667    }
668    #[doc = "Bit 22 - Registers update mode"]
669    #[inline]
670    pub fn preload(&mut self) -> _PRELOADW {
671        _PRELOADW { w: self }
672    }
673    #[doc = "Bit 21 - Waveform shape polarity"]
674    #[inline]
675    pub fn wavpol(&mut self) -> _WAVPOLW {
676        _WAVPOLW { w: self }
677    }
678    #[doc = "Bit 20 - Waveform shape"]
679    #[inline]
680    pub fn wave(&mut self) -> _WAVEW {
681        _WAVEW { w: self }
682    }
683    #[doc = "Bit 19 - Timeout enable"]
684    #[inline]
685    pub fn timout(&mut self) -> _TIMOUTW {
686        _TIMOUTW { w: self }
687    }
688    #[doc = "Bits 17:18 - Trigger enable and polarity"]
689    #[inline]
690    pub fn trigen(&mut self) -> _TRIGENW {
691        _TRIGENW { w: self }
692    }
693    #[doc = "Bits 13:15 - Trigger selector"]
694    #[inline]
695    pub fn trigsel(&mut self) -> _TRIGSELW {
696        _TRIGSELW { w: self }
697    }
698    #[doc = "Bits 9:11 - Clock prescaler"]
699    #[inline]
700    pub fn presc(&mut self) -> _PRESCW {
701        _PRESCW { w: self }
702    }
703    #[doc = "Bits 6:7 - Configurable digital filter for trigger"]
704    #[inline]
705    pub fn trgflt(&mut self) -> _TRGFLTW {
706        _TRGFLTW { w: self }
707    }
708    #[doc = "Bits 3:4 - Configurable digital filter for external clock"]
709    #[inline]
710    pub fn ckflt(&mut self) -> _CKFLTW {
711        _CKFLTW { w: self }
712    }
713    #[doc = "Bits 1:2 - Clock Polarity"]
714    #[inline]
715    pub fn ckpol(&mut self) -> _CKPOLW {
716        _CKPOLW { w: self }
717    }
718    #[doc = "Bit 0 - Clock selector"]
719    #[inline]
720    pub fn cksel(&mut self) -> _CKSELW {
721        _CKSELW { w: self }
722    }
723}