at32f4xx_pac/at32f413/tmr1/
brk.rs

1#[doc = "Register `BRK` reader"]
2pub type R = crate::R<BRK_SPEC>;
3#[doc = "Register `BRK` writer"]
4pub type W = crate::W<BRK_SPEC>;
5#[doc = "Field `DTC` reader - Dead-time configuration"]
6pub type DTC_R = crate::FieldReader;
7#[doc = "Field `DTC` writer - Dead-time configuration"]
8pub type DTC_W<'a, REG> = crate::FieldWriter<'a, REG, 8, u8, crate::Safe>;
9#[doc = "Write protected configuration\n\nValue on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u8)]
12pub enum WPC_A {
13    #[doc = "0: Write protection is OFF"]
14    NoProtect = 0,
15    #[doc = "1: Write protection level 3, and the following bits are write protected"]
16    Level3 = 1,
17    #[doc = "2: Write protection level 2. The following bits and all bits in level 3 are write protected"]
18    Level2 = 2,
19    #[doc = "3: Write protection level 1. The following bits and all bits in level 2 are write protected"]
20    Level1 = 3,
21}
22impl From<WPC_A> for u8 {
23    #[inline(always)]
24    fn from(variant: WPC_A) -> Self {
25        variant as _
26    }
27}
28impl crate::FieldSpec for WPC_A {
29    type Ux = u8;
30}
31impl crate::IsEnum for WPC_A {}
32#[doc = "Field `WPC` reader - Write protected configuration"]
33pub type WPC_R = crate::FieldReader<WPC_A>;
34impl WPC_R {
35    #[doc = "Get enumerated values variant"]
36    #[inline(always)]
37    pub const fn variant(&self) -> WPC_A {
38        match self.bits {
39            0 => WPC_A::NoProtect,
40            1 => WPC_A::Level3,
41            2 => WPC_A::Level2,
42            3 => WPC_A::Level1,
43            _ => unreachable!(),
44        }
45    }
46    #[doc = "Write protection is OFF"]
47    #[inline(always)]
48    pub fn is_no_protect(&self) -> bool {
49        *self == WPC_A::NoProtect
50    }
51    #[doc = "Write protection level 3, and the following bits are write protected"]
52    #[inline(always)]
53    pub fn is_level3(&self) -> bool {
54        *self == WPC_A::Level3
55    }
56    #[doc = "Write protection level 2. The following bits and all bits in level 3 are write protected"]
57    #[inline(always)]
58    pub fn is_level2(&self) -> bool {
59        *self == WPC_A::Level2
60    }
61    #[doc = "Write protection level 1. The following bits and all bits in level 2 are write protected"]
62    #[inline(always)]
63    pub fn is_level1(&self) -> bool {
64        *self == WPC_A::Level1
65    }
66}
67#[doc = "Field `WPC` writer - Write protected configuration"]
68pub type WPC_W<'a, REG> = crate::FieldWriter<'a, REG, 2, WPC_A, crate::Safe>;
69impl<'a, REG> WPC_W<'a, REG>
70where
71    REG: crate::Writable + crate::RegisterSpec,
72    REG::Ux: From<u8>,
73{
74    #[doc = "Write protection is OFF"]
75    #[inline(always)]
76    pub fn no_protect(self) -> &'a mut crate::W<REG> {
77        self.variant(WPC_A::NoProtect)
78    }
79    #[doc = "Write protection level 3, and the following bits are write protected"]
80    #[inline(always)]
81    pub fn level3(self) -> &'a mut crate::W<REG> {
82        self.variant(WPC_A::Level3)
83    }
84    #[doc = "Write protection level 2. The following bits and all bits in level 3 are write protected"]
85    #[inline(always)]
86    pub fn level2(self) -> &'a mut crate::W<REG> {
87        self.variant(WPC_A::Level2)
88    }
89    #[doc = "Write protection level 1. The following bits and all bits in level 2 are write protected"]
90    #[inline(always)]
91    pub fn level1(self) -> &'a mut crate::W<REG> {
92        self.variant(WPC_A::Level1)
93    }
94}
95#[doc = "Frozen channel status when holistic output disable\n\nValue on reset: 0"]
96#[derive(Clone, Copy, Debug, PartialEq, Eq)]
97pub enum Fcsodisr {
98    #[doc = "0: CxOUT/CxCOUT outputs are disabled"]
99    Disabled = 0,
100    #[doc = "1: CxOUT/CxCOUT outputs are enabled"]
101    Enabled = 1,
102}
103impl From<Fcsodisr> for bool {
104    #[inline(always)]
105    fn from(variant: Fcsodisr) -> Self {
106        variant as u8 != 0
107    }
108}
109#[doc = "Field `FCSODIS` reader - Frozen channel status when holistic output disable"]
110pub type FCSODIS_R = crate::BitReader<Fcsodisr>;
111impl FCSODIS_R {
112    #[doc = "Get enumerated values variant"]
113    #[inline(always)]
114    pub const fn variant(&self) -> Fcsodisr {
115        match self.bits {
116            false => Fcsodisr::Disabled,
117            true => Fcsodisr::Enabled,
118        }
119    }
120    #[doc = "CxOUT/CxCOUT outputs are disabled"]
121    #[inline(always)]
122    pub fn is_disabled(&self) -> bool {
123        *self == Fcsodisr::Disabled
124    }
125    #[doc = "CxOUT/CxCOUT outputs are enabled"]
126    #[inline(always)]
127    pub fn is_enabled(&self) -> bool {
128        *self == Fcsodisr::Enabled
129    }
130}
131#[doc = "Frozen channel status when holistic output disable\n\nValue on reset: 0"]
132#[derive(Clone, Copy, Debug, PartialEq, Eq)]
133pub enum FcsodiswWO {
134    #[doc = "0: CxOUT/CxCOUT outputs disable"]
135    Disable = 0,
136    #[doc = "1: CxOUT/CxCOUT outputs enable"]
137    Enable = 1,
138}
139impl From<FcsodiswWO> for bool {
140    #[inline(always)]
141    fn from(variant: FcsodiswWO) -> Self {
142        variant as u8 != 0
143    }
144}
145#[doc = "Field `FCSODIS` writer - Frozen channel status when holistic output disable"]
146pub type FCSODIS_W<'a, REG> = crate::BitWriter<'a, REG, FcsodiswWO>;
147impl<'a, REG> FCSODIS_W<'a, REG>
148where
149    REG: crate::Writable + crate::RegisterSpec,
150{
151    #[doc = "CxOUT/CxCOUT outputs disable"]
152    #[inline(always)]
153    pub fn disable(self) -> &'a mut crate::W<REG> {
154        self.variant(FcsodiswWO::Disable)
155    }
156    #[doc = "CxOUT/CxCOUT outputs enable"]
157    #[inline(always)]
158    pub fn enable(self) -> &'a mut crate::W<REG> {
159        self.variant(FcsodiswWO::Enable)
160    }
161}
162#[doc = "Frozen channel status when holistic output enable\n\nValue on reset: 0"]
163#[derive(Clone, Copy, Debug, PartialEq, Eq)]
164pub enum Fcsoenr {
165    #[doc = "0: CxOUT/CxCOUT outputs are disabled"]
166    Disabled = 0,
167    #[doc = "1: CxOUT/CxCOUT outputs are enabled"]
168    Enabled = 1,
169}
170impl From<Fcsoenr> for bool {
171    #[inline(always)]
172    fn from(variant: Fcsoenr) -> Self {
173        variant as u8 != 0
174    }
175}
176#[doc = "Field `FCSOEN` reader - Frozen channel status when holistic output enable"]
177pub type FCSOEN_R = crate::BitReader<Fcsoenr>;
178impl FCSOEN_R {
179    #[doc = "Get enumerated values variant"]
180    #[inline(always)]
181    pub const fn variant(&self) -> Fcsoenr {
182        match self.bits {
183            false => Fcsoenr::Disabled,
184            true => Fcsoenr::Enabled,
185        }
186    }
187    #[doc = "CxOUT/CxCOUT outputs are disabled"]
188    #[inline(always)]
189    pub fn is_disabled(&self) -> bool {
190        *self == Fcsoenr::Disabled
191    }
192    #[doc = "CxOUT/CxCOUT outputs are enabled"]
193    #[inline(always)]
194    pub fn is_enabled(&self) -> bool {
195        *self == Fcsoenr::Enabled
196    }
197}
198#[doc = "Frozen channel status when holistic output enable\n\nValue on reset: 0"]
199#[derive(Clone, Copy, Debug, PartialEq, Eq)]
200pub enum FcsoenwWO {
201    #[doc = "0: CxOUT/CxCOUT outputs disable"]
202    Disable = 0,
203    #[doc = "1: CxOUT/CxCOUT outputs enable"]
204    Enable = 1,
205}
206impl From<FcsoenwWO> for bool {
207    #[inline(always)]
208    fn from(variant: FcsoenwWO) -> Self {
209        variant as u8 != 0
210    }
211}
212#[doc = "Field `FCSOEN` writer - Frozen channel status when holistic output enable"]
213pub type FCSOEN_W<'a, REG> = crate::BitWriter<'a, REG, FcsoenwWO>;
214impl<'a, REG> FCSOEN_W<'a, REG>
215where
216    REG: crate::Writable + crate::RegisterSpec,
217{
218    #[doc = "CxOUT/CxCOUT outputs disable"]
219    #[inline(always)]
220    pub fn disable(self) -> &'a mut crate::W<REG> {
221        self.variant(FcsoenwWO::Disable)
222    }
223    #[doc = "CxOUT/CxCOUT outputs enable"]
224    #[inline(always)]
225    pub fn enable(self) -> &'a mut crate::W<REG> {
226        self.variant(FcsoenwWO::Enable)
227    }
228}
229#[doc = "Brake enable\n\nValue on reset: 0"]
230#[derive(Clone, Copy, Debug, PartialEq, Eq)]
231pub enum Brkenr {
232    #[doc = "0: Break input is disabled"]
233    Disabled = 0,
234    #[doc = "1: Break input is enabled"]
235    Enabled = 1,
236}
237impl From<Brkenr> for bool {
238    #[inline(always)]
239    fn from(variant: Brkenr) -> Self {
240        variant as u8 != 0
241    }
242}
243#[doc = "Field `BRKEN` reader - Brake enable"]
244pub type BRKEN_R = crate::BitReader<Brkenr>;
245impl BRKEN_R {
246    #[doc = "Get enumerated values variant"]
247    #[inline(always)]
248    pub const fn variant(&self) -> Brkenr {
249        match self.bits {
250            false => Brkenr::Disabled,
251            true => Brkenr::Enabled,
252        }
253    }
254    #[doc = "Break input is disabled"]
255    #[inline(always)]
256    pub fn is_disabled(&self) -> bool {
257        *self == Brkenr::Disabled
258    }
259    #[doc = "Break input is enabled"]
260    #[inline(always)]
261    pub fn is_enabled(&self) -> bool {
262        *self == Brkenr::Enabled
263    }
264}
265#[doc = "Brake enable\n\nValue on reset: 0"]
266#[derive(Clone, Copy, Debug, PartialEq, Eq)]
267pub enum BrkenwWO {
268    #[doc = "0: Break input disable"]
269    Disable = 0,
270    #[doc = "1: Break input enable"]
271    Enable = 1,
272}
273impl From<BrkenwWO> for bool {
274    #[inline(always)]
275    fn from(variant: BrkenwWO) -> Self {
276        variant as u8 != 0
277    }
278}
279#[doc = "Field `BRKEN` writer - Brake enable"]
280pub type BRKEN_W<'a, REG> = crate::BitWriter<'a, REG, BrkenwWO>;
281impl<'a, REG> BRKEN_W<'a, REG>
282where
283    REG: crate::Writable + crate::RegisterSpec,
284{
285    #[doc = "Break input disable"]
286    #[inline(always)]
287    pub fn disable(self) -> &'a mut crate::W<REG> {
288        self.variant(BrkenwWO::Disable)
289    }
290    #[doc = "Break input enable"]
291    #[inline(always)]
292    pub fn enable(self) -> &'a mut crate::W<REG> {
293        self.variant(BrkenwWO::Enable)
294    }
295}
296#[doc = "Brake input validity\n\nValue on reset: 0"]
297#[derive(Clone, Copy, Debug, PartialEq, Eq)]
298pub enum BRKV_A {
299    #[doc = "0: Break input is active low"]
300    Low = 0,
301    #[doc = "1: Break input is active high"]
302    High = 1,
303}
304impl From<BRKV_A> for bool {
305    #[inline(always)]
306    fn from(variant: BRKV_A) -> Self {
307        variant as u8 != 0
308    }
309}
310#[doc = "Field `BRKV` reader - Brake input validity"]
311pub type BRKV_R = crate::BitReader<BRKV_A>;
312impl BRKV_R {
313    #[doc = "Get enumerated values variant"]
314    #[inline(always)]
315    pub const fn variant(&self) -> BRKV_A {
316        match self.bits {
317            false => BRKV_A::Low,
318            true => BRKV_A::High,
319        }
320    }
321    #[doc = "Break input is active low"]
322    #[inline(always)]
323    pub fn is_low(&self) -> bool {
324        *self == BRKV_A::Low
325    }
326    #[doc = "Break input is active high"]
327    #[inline(always)]
328    pub fn is_high(&self) -> bool {
329        *self == BRKV_A::High
330    }
331}
332#[doc = "Field `BRKV` writer - Brake input validity"]
333pub type BRKV_W<'a, REG> = crate::BitWriter<'a, REG, BRKV_A>;
334impl<'a, REG> BRKV_W<'a, REG>
335where
336    REG: crate::Writable + crate::RegisterSpec,
337{
338    #[doc = "Break input is active low"]
339    #[inline(always)]
340    pub fn low(self) -> &'a mut crate::W<REG> {
341        self.variant(BRKV_A::Low)
342    }
343    #[doc = "Break input is active high"]
344    #[inline(always)]
345    pub fn high(self) -> &'a mut crate::W<REG> {
346        self.variant(BRKV_A::High)
347    }
348}
349#[doc = "Automatic output enable\n\nValue on reset: 0"]
350#[derive(Clone, Copy, Debug, PartialEq, Eq)]
351pub enum Aoenr {
352    #[doc = "0: Automatic output is disabled"]
353    Disabled = 0,
354    #[doc = "1: Automatic output is enabled"]
355    Enabled = 1,
356}
357impl From<Aoenr> for bool {
358    #[inline(always)]
359    fn from(variant: Aoenr) -> Self {
360        variant as u8 != 0
361    }
362}
363#[doc = "Field `AOEN` reader - Automatic output enable"]
364pub type AOEN_R = crate::BitReader<Aoenr>;
365impl AOEN_R {
366    #[doc = "Get enumerated values variant"]
367    #[inline(always)]
368    pub const fn variant(&self) -> Aoenr {
369        match self.bits {
370            false => Aoenr::Disabled,
371            true => Aoenr::Enabled,
372        }
373    }
374    #[doc = "Automatic output is disabled"]
375    #[inline(always)]
376    pub fn is_disabled(&self) -> bool {
377        *self == Aoenr::Disabled
378    }
379    #[doc = "Automatic output is enabled"]
380    #[inline(always)]
381    pub fn is_enabled(&self) -> bool {
382        *self == Aoenr::Enabled
383    }
384}
385#[doc = "Automatic output enable\n\nValue on reset: 0"]
386#[derive(Clone, Copy, Debug, PartialEq, Eq)]
387pub enum AoenwWO {
388    #[doc = "0: Automatic output disable"]
389    Disable = 0,
390    #[doc = "1: Automatic output enable"]
391    Enable = 1,
392}
393impl From<AoenwWO> for bool {
394    #[inline(always)]
395    fn from(variant: AoenwWO) -> Self {
396        variant as u8 != 0
397    }
398}
399#[doc = "Field `AOEN` writer - Automatic output enable"]
400pub type AOEN_W<'a, REG> = crate::BitWriter<'a, REG, AoenwWO>;
401impl<'a, REG> AOEN_W<'a, REG>
402where
403    REG: crate::Writable + crate::RegisterSpec,
404{
405    #[doc = "Automatic output disable"]
406    #[inline(always)]
407    pub fn disable(self) -> &'a mut crate::W<REG> {
408        self.variant(AoenwWO::Disable)
409    }
410    #[doc = "Automatic output enable"]
411    #[inline(always)]
412    pub fn enable(self) -> &'a mut crate::W<REG> {
413        self.variant(AoenwWO::Enable)
414    }
415}
416#[doc = "Output enable\n\nValue on reset: 0"]
417#[derive(Clone, Copy, Debug, PartialEq, Eq)]
418pub enum Oenr {
419    #[doc = "0: Output is disabled"]
420    Disabled = 0,
421    #[doc = "1: Output is enabled"]
422    Enabled = 1,
423}
424impl From<Oenr> for bool {
425    #[inline(always)]
426    fn from(variant: Oenr) -> Self {
427        variant as u8 != 0
428    }
429}
430#[doc = "Field `OEN` reader - Output enable"]
431pub type OEN_R = crate::BitReader<Oenr>;
432impl OEN_R {
433    #[doc = "Get enumerated values variant"]
434    #[inline(always)]
435    pub const fn variant(&self) -> Oenr {
436        match self.bits {
437            false => Oenr::Disabled,
438            true => Oenr::Enabled,
439        }
440    }
441    #[doc = "Output is disabled"]
442    #[inline(always)]
443    pub fn is_disabled(&self) -> bool {
444        *self == Oenr::Disabled
445    }
446    #[doc = "Output is enabled"]
447    #[inline(always)]
448    pub fn is_enabled(&self) -> bool {
449        *self == Oenr::Enabled
450    }
451}
452#[doc = "Output enable\n\nValue on reset: 0"]
453#[derive(Clone, Copy, Debug, PartialEq, Eq)]
454pub enum OenwWO {
455    #[doc = "0: Output disable"]
456    Disable = 0,
457    #[doc = "1: Output enable"]
458    Enable = 1,
459}
460impl From<OenwWO> for bool {
461    #[inline(always)]
462    fn from(variant: OenwWO) -> Self {
463        variant as u8 != 0
464    }
465}
466#[doc = "Field `OEN` writer - Output enable"]
467pub type OEN_W<'a, REG> = crate::BitWriter<'a, REG, OenwWO>;
468impl<'a, REG> OEN_W<'a, REG>
469where
470    REG: crate::Writable + crate::RegisterSpec,
471{
472    #[doc = "Output disable"]
473    #[inline(always)]
474    pub fn disable(self) -> &'a mut crate::W<REG> {
475        self.variant(OenwWO::Disable)
476    }
477    #[doc = "Output enable"]
478    #[inline(always)]
479    pub fn enable(self) -> &'a mut crate::W<REG> {
480        self.variant(OenwWO::Enable)
481    }
482}
483impl R {
484    #[doc = "Bits 0:7 - Dead-time configuration"]
485    #[inline(always)]
486    pub fn dtc(&self) -> DTC_R {
487        DTC_R::new((self.bits & 0xff) as u8)
488    }
489    #[doc = "Bits 8:9 - Write protected configuration"]
490    #[inline(always)]
491    pub fn wpc(&self) -> WPC_R {
492        WPC_R::new(((self.bits >> 8) & 3) as u8)
493    }
494    #[doc = "Bit 10 - Frozen channel status when holistic output disable"]
495    #[inline(always)]
496    pub fn fcsodis(&self) -> FCSODIS_R {
497        FCSODIS_R::new(((self.bits >> 10) & 1) != 0)
498    }
499    #[doc = "Bit 11 - Frozen channel status when holistic output enable"]
500    #[inline(always)]
501    pub fn fcsoen(&self) -> FCSOEN_R {
502        FCSOEN_R::new(((self.bits >> 11) & 1) != 0)
503    }
504    #[doc = "Bit 12 - Brake enable"]
505    #[inline(always)]
506    pub fn brken(&self) -> BRKEN_R {
507        BRKEN_R::new(((self.bits >> 12) & 1) != 0)
508    }
509    #[doc = "Bit 13 - Brake input validity"]
510    #[inline(always)]
511    pub fn brkv(&self) -> BRKV_R {
512        BRKV_R::new(((self.bits >> 13) & 1) != 0)
513    }
514    #[doc = "Bit 14 - Automatic output enable"]
515    #[inline(always)]
516    pub fn aoen(&self) -> AOEN_R {
517        AOEN_R::new(((self.bits >> 14) & 1) != 0)
518    }
519    #[doc = "Bit 15 - Output enable"]
520    #[inline(always)]
521    pub fn oen(&self) -> OEN_R {
522        OEN_R::new(((self.bits >> 15) & 1) != 0)
523    }
524}
525impl core::fmt::Debug for R {
526    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
527        f.debug_struct("BRK")
528            .field("oen", &self.oen())
529            .field("aoen", &self.aoen())
530            .field("brkv", &self.brkv())
531            .field("brken", &self.brken())
532            .field("fcsoen", &self.fcsoen())
533            .field("fcsodis", &self.fcsodis())
534            .field("wpc", &self.wpc())
535            .field("dtc", &self.dtc())
536            .finish()
537    }
538}
539impl W {
540    #[doc = "Bits 0:7 - Dead-time configuration"]
541    #[inline(always)]
542    #[must_use]
543    pub fn dtc(&mut self) -> DTC_W<BRK_SPEC> {
544        DTC_W::new(self, 0)
545    }
546    #[doc = "Bits 8:9 - Write protected configuration"]
547    #[inline(always)]
548    #[must_use]
549    pub fn wpc(&mut self) -> WPC_W<BRK_SPEC> {
550        WPC_W::new(self, 8)
551    }
552    #[doc = "Bit 10 - Frozen channel status when holistic output disable"]
553    #[inline(always)]
554    #[must_use]
555    pub fn fcsodis(&mut self) -> FCSODIS_W<BRK_SPEC> {
556        FCSODIS_W::new(self, 10)
557    }
558    #[doc = "Bit 11 - Frozen channel status when holistic output enable"]
559    #[inline(always)]
560    #[must_use]
561    pub fn fcsoen(&mut self) -> FCSOEN_W<BRK_SPEC> {
562        FCSOEN_W::new(self, 11)
563    }
564    #[doc = "Bit 12 - Brake enable"]
565    #[inline(always)]
566    #[must_use]
567    pub fn brken(&mut self) -> BRKEN_W<BRK_SPEC> {
568        BRKEN_W::new(self, 12)
569    }
570    #[doc = "Bit 13 - Brake input validity"]
571    #[inline(always)]
572    #[must_use]
573    pub fn brkv(&mut self) -> BRKV_W<BRK_SPEC> {
574        BRKV_W::new(self, 13)
575    }
576    #[doc = "Bit 14 - Automatic output enable"]
577    #[inline(always)]
578    #[must_use]
579    pub fn aoen(&mut self) -> AOEN_W<BRK_SPEC> {
580        AOEN_W::new(self, 14)
581    }
582    #[doc = "Bit 15 - Output enable"]
583    #[inline(always)]
584    #[must_use]
585    pub fn oen(&mut self) -> OEN_W<BRK_SPEC> {
586        OEN_W::new(self, 15)
587    }
588}
589#[doc = "Brake register\n\nYou can [`read`](crate::Reg::read) this register and get [`brk::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`brk::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
590pub struct BRK_SPEC;
591impl crate::RegisterSpec for BRK_SPEC {
592    type Ux = u32;
593}
594#[doc = "`read()` method returns [`brk::R`](R) reader structure"]
595impl crate::Readable for BRK_SPEC {}
596#[doc = "`write(|w| ..)` method takes [`brk::W`](W) writer structure"]
597impl crate::Writable for BRK_SPEC {
598    type Safety = crate::Unsafe;
599    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
600    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
601}
602#[doc = "`reset()` method sets BRK to value 0"]
603impl crate::Resettable for BRK_SPEC {
604    const RESET_VALUE: u32 = 0;
605}