atsam4e8c_pac/pwm/
wpcr.rs

1#[doc = "Register `WPCR` writer"]
2pub struct W(crate::W<WPCR_SPEC>);
3impl core::ops::Deref for W {
4    type Target = crate::W<WPCR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl core::ops::DerefMut for W {
11    #[inline(always)]
12    fn deref_mut(&mut self) -> &mut Self::Target {
13        &mut self.0
14    }
15}
16impl From<crate::W<WPCR_SPEC>> for W {
17    #[inline(always)]
18    fn from(writer: crate::W<WPCR_SPEC>) -> Self {
19        W(writer)
20    }
21}
22#[doc = "Write Protection Command"]
23#[derive(Clone, Copy, Debug, PartialEq, Eq)]
24#[repr(u8)]
25pub enum WPCMD_AW {
26    #[doc = "0: Disables the software write protection of the register groups of which the bit WPRGx is at '1'."]
27    DISABLE_SW_PROT = 0,
28    #[doc = "1: Enables the software write protection of the register groups of which the bit WPRGx is at '1'."]
29    ENABLE_SW_PROT = 1,
30    #[doc = "2: Enables the hardware write protection of the register groups of which the bit WPRGx is at '1'. Only a hardware reset of the PWM controller can disable the hardware write protection. Moreover, to meet security requirements, the PIO lines associated with the PWM can not be configured through the PIO interface."]
31    ENABLE_HW_PROT = 2,
32}
33impl From<WPCMD_AW> for u8 {
34    #[inline(always)]
35    fn from(variant: WPCMD_AW) -> Self {
36        variant as _
37    }
38}
39#[doc = "Field `WPCMD` writer - Write Protection Command"]
40pub type WPCMD_W<'a, const O: u8> = crate::FieldWriter<'a, u32, WPCR_SPEC, u8, WPCMD_AW, 2, O>;
41impl<'a, const O: u8> WPCMD_W<'a, O> {
42    #[doc = "Disables the software write protection of the register groups of which the bit WPRGx is at '1'."]
43    #[inline(always)]
44    pub fn disable_sw_prot(self) -> &'a mut W {
45        self.variant(WPCMD_AW::DISABLE_SW_PROT)
46    }
47    #[doc = "Enables the software write protection of the register groups of which the bit WPRGx is at '1'."]
48    #[inline(always)]
49    pub fn enable_sw_prot(self) -> &'a mut W {
50        self.variant(WPCMD_AW::ENABLE_SW_PROT)
51    }
52    #[doc = "Enables the hardware write protection of the register groups of which the bit WPRGx is at '1'. Only a hardware reset of the PWM controller can disable the hardware write protection. Moreover, to meet security requirements, the PIO lines associated with the PWM can not be configured through the PIO interface."]
53    #[inline(always)]
54    pub fn enable_hw_prot(self) -> &'a mut W {
55        self.variant(WPCMD_AW::ENABLE_HW_PROT)
56    }
57}
58#[doc = "Field `WPRG0` writer - Write Protection Register Group 0"]
59pub type WPRG0_W<'a, const O: u8> = crate::BitWriter<'a, u32, WPCR_SPEC, bool, O>;
60#[doc = "Field `WPRG1` writer - Write Protection Register Group 1"]
61pub type WPRG1_W<'a, const O: u8> = crate::BitWriter<'a, u32, WPCR_SPEC, bool, O>;
62#[doc = "Field `WPRG2` writer - Write Protection Register Group 2"]
63pub type WPRG2_W<'a, const O: u8> = crate::BitWriter<'a, u32, WPCR_SPEC, bool, O>;
64#[doc = "Field `WPRG3` writer - Write Protection Register Group 3"]
65pub type WPRG3_W<'a, const O: u8> = crate::BitWriter<'a, u32, WPCR_SPEC, bool, O>;
66#[doc = "Field `WPRG4` writer - Write Protection Register Group 4"]
67pub type WPRG4_W<'a, const O: u8> = crate::BitWriter<'a, u32, WPCR_SPEC, bool, O>;
68#[doc = "Field `WPRG5` writer - Write Protection Register Group 5"]
69pub type WPRG5_W<'a, const O: u8> = crate::BitWriter<'a, u32, WPCR_SPEC, bool, O>;
70#[doc = "Write Protection Key"]
71#[derive(Clone, Copy, Debug, PartialEq, Eq)]
72#[repr(u32)]
73pub enum WPKEY_AW {
74    #[doc = "5265229: Writing any other value in this field aborts the write operation of the WPCMD field.Always reads as 0"]
75    PASSWD = 5265229,
76}
77impl From<WPKEY_AW> for u32 {
78    #[inline(always)]
79    fn from(variant: WPKEY_AW) -> Self {
80        variant as _
81    }
82}
83#[doc = "Field `WPKEY` writer - Write Protection Key"]
84pub type WPKEY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, WPCR_SPEC, u32, WPKEY_AW, 24, O>;
85impl<'a, const O: u8> WPKEY_W<'a, O> {
86    #[doc = "Writing any other value in this field aborts the write operation of the WPCMD field.Always reads as 0"]
87    #[inline(always)]
88    pub fn passwd(self) -> &'a mut W {
89        self.variant(WPKEY_AW::PASSWD)
90    }
91}
92impl W {
93    #[doc = "Bits 0:1 - Write Protection Command"]
94    #[inline(always)]
95    #[must_use]
96    pub fn wpcmd(&mut self) -> WPCMD_W<0> {
97        WPCMD_W::new(self)
98    }
99    #[doc = "Bit 2 - Write Protection Register Group 0"]
100    #[inline(always)]
101    #[must_use]
102    pub fn wprg0(&mut self) -> WPRG0_W<2> {
103        WPRG0_W::new(self)
104    }
105    #[doc = "Bit 3 - Write Protection Register Group 1"]
106    #[inline(always)]
107    #[must_use]
108    pub fn wprg1(&mut self) -> WPRG1_W<3> {
109        WPRG1_W::new(self)
110    }
111    #[doc = "Bit 4 - Write Protection Register Group 2"]
112    #[inline(always)]
113    #[must_use]
114    pub fn wprg2(&mut self) -> WPRG2_W<4> {
115        WPRG2_W::new(self)
116    }
117    #[doc = "Bit 5 - Write Protection Register Group 3"]
118    #[inline(always)]
119    #[must_use]
120    pub fn wprg3(&mut self) -> WPRG3_W<5> {
121        WPRG3_W::new(self)
122    }
123    #[doc = "Bit 6 - Write Protection Register Group 4"]
124    #[inline(always)]
125    #[must_use]
126    pub fn wprg4(&mut self) -> WPRG4_W<6> {
127        WPRG4_W::new(self)
128    }
129    #[doc = "Bit 7 - Write Protection Register Group 5"]
130    #[inline(always)]
131    #[must_use]
132    pub fn wprg5(&mut self) -> WPRG5_W<7> {
133        WPRG5_W::new(self)
134    }
135    #[doc = "Bits 8:31 - Write Protection Key"]
136    #[inline(always)]
137    #[must_use]
138    pub fn wpkey(&mut self) -> WPKEY_W<8> {
139        WPKEY_W::new(self)
140    }
141    #[doc = "Writes raw bits to the register."]
142    #[inline(always)]
143    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
144        self.0.bits(bits);
145        self
146    }
147}
148#[doc = "PWM Write Protection Control Register\n\nThis register you can [`write_with_zero`](crate::generic::Reg::write_with_zero). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [wpcr](index.html) module"]
149pub struct WPCR_SPEC;
150impl crate::RegisterSpec for WPCR_SPEC {
151    type Ux = u32;
152}
153#[doc = "`write(|w| ..)` method takes [wpcr::W](W) writer structure"]
154impl crate::Writable for WPCR_SPEC {
155    type Writer = W;
156    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
157    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
158}