saml10d15a/pac/
wrctrl.rs

1#[doc = "Reader of register WRCTRL"]
2pub type R = crate::R<u32, super::WRCTRL>;
3#[doc = "Writer for register WRCTRL"]
4pub type W = crate::W<u32, super::WRCTRL>;
5#[doc = "Register WRCTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::WRCTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Reader of field `PERID`"]
14pub type PERID_R = crate::R<u16, u16>;
15#[doc = "Write proxy for field `PERID`"]
16pub struct PERID_W<'a> {
17    w: &'a mut W,
18}
19impl<'a> PERID_W<'a> {
20    #[doc = r"Writes raw bits to the field"]
21    #[inline(always)]
22    pub unsafe fn bits(self, value: u16) -> &'a mut W {
23        self.w.bits = (self.w.bits & !0xffff) | ((value as u32) & 0xffff);
24        self.w
25    }
26}
27#[doc = "Possible values of the field `KEY`"]
28#[derive(Clone, Copy, Debug, PartialEq)]
29pub enum KEY_A {
30    #[doc = "No action"]
31    OFF,
32    #[doc = "Clear protection"]
33    CLR,
34    #[doc = "Set protection"]
35    SET,
36    #[doc = "Set and lock protection"]
37    SETLCK,
38    #[doc = "Set IP secure"]
39    SETSEC,
40    #[doc = "Set IP non-secure"]
41    SETNONSEC,
42    #[doc = "Lock IP security value"]
43    SECLOCK,
44}
45impl crate::ToBits<u8> for KEY_A {
46    #[inline(always)]
47    fn _bits(&self) -> u8 {
48        match *self {
49            KEY_A::OFF => 0,
50            KEY_A::CLR => 1,
51            KEY_A::SET => 2,
52            KEY_A::SETLCK => 3,
53            KEY_A::SETSEC => 4,
54            KEY_A::SETNONSEC => 5,
55            KEY_A::SECLOCK => 6,
56        }
57    }
58}
59#[doc = "Reader of field `KEY`"]
60pub type KEY_R = crate::R<u8, KEY_A>;
61impl KEY_R {
62    #[doc = r"Get enumerated values variant"]
63    #[inline(always)]
64    pub fn variant(&self) -> crate::Variant<u8, KEY_A> {
65        use crate::Variant::*;
66        match self.bits {
67            0 => Val(KEY_A::OFF),
68            1 => Val(KEY_A::CLR),
69            2 => Val(KEY_A::SET),
70            3 => Val(KEY_A::SETLCK),
71            4 => Val(KEY_A::SETSEC),
72            5 => Val(KEY_A::SETNONSEC),
73            6 => Val(KEY_A::SECLOCK),
74            i => Res(i),
75        }
76    }
77    #[doc = "Checks if the value of the field is `OFF`"]
78    #[inline(always)]
79    pub fn is_off(&self) -> bool {
80        *self == KEY_A::OFF
81    }
82    #[doc = "Checks if the value of the field is `CLR`"]
83    #[inline(always)]
84    pub fn is_clr(&self) -> bool {
85        *self == KEY_A::CLR
86    }
87    #[doc = "Checks if the value of the field is `SET`"]
88    #[inline(always)]
89    pub fn is_set(&self) -> bool {
90        *self == KEY_A::SET
91    }
92    #[doc = "Checks if the value of the field is `SETLCK`"]
93    #[inline(always)]
94    pub fn is_setlck(&self) -> bool {
95        *self == KEY_A::SETLCK
96    }
97    #[doc = "Checks if the value of the field is `SETSEC`"]
98    #[inline(always)]
99    pub fn is_setsec(&self) -> bool {
100        *self == KEY_A::SETSEC
101    }
102    #[doc = "Checks if the value of the field is `SETNONSEC`"]
103    #[inline(always)]
104    pub fn is_setnonsec(&self) -> bool {
105        *self == KEY_A::SETNONSEC
106    }
107    #[doc = "Checks if the value of the field is `SECLOCK`"]
108    #[inline(always)]
109    pub fn is_seclock(&self) -> bool {
110        *self == KEY_A::SECLOCK
111    }
112}
113#[doc = "Write proxy for field `KEY`"]
114pub struct KEY_W<'a> {
115    w: &'a mut W,
116}
117impl<'a> KEY_W<'a> {
118    #[doc = r"Writes `variant` to the field"]
119    #[inline(always)]
120    pub fn variant(self, variant: KEY_A) -> &'a mut W {
121        use crate::ToBits;
122        unsafe { self.bits(variant._bits()) }
123    }
124    #[doc = "No action"]
125    #[inline(always)]
126    pub fn off(self) -> &'a mut W {
127        self.variant(KEY_A::OFF)
128    }
129    #[doc = "Clear protection"]
130    #[inline(always)]
131    pub fn clr(self) -> &'a mut W {
132        self.variant(KEY_A::CLR)
133    }
134    #[doc = "Set protection"]
135    #[inline(always)]
136    pub fn set(self) -> &'a mut W {
137        self.variant(KEY_A::SET)
138    }
139    #[doc = "Set and lock protection"]
140    #[inline(always)]
141    pub fn setlck(self) -> &'a mut W {
142        self.variant(KEY_A::SETLCK)
143    }
144    #[doc = "Set IP secure"]
145    #[inline(always)]
146    pub fn setsec(self) -> &'a mut W {
147        self.variant(KEY_A::SETSEC)
148    }
149    #[doc = "Set IP non-secure"]
150    #[inline(always)]
151    pub fn setnonsec(self) -> &'a mut W {
152        self.variant(KEY_A::SETNONSEC)
153    }
154    #[doc = "Lock IP security value"]
155    #[inline(always)]
156    pub fn seclock(self) -> &'a mut W {
157        self.variant(KEY_A::SECLOCK)
158    }
159    #[doc = r"Writes raw bits to the field"]
160    #[inline(always)]
161    pub unsafe fn bits(self, value: u8) -> &'a mut W {
162        self.w.bits = (self.w.bits & !(0xff << 16)) | (((value as u32) & 0xff) << 16);
163        self.w
164    }
165}
166impl R {
167    #[doc = "Bits 0:15 - Peripheral identifier"]
168    #[inline(always)]
169    pub fn perid(&self) -> PERID_R {
170        PERID_R::new((self.bits & 0xffff) as u16)
171    }
172    #[doc = "Bits 16:23 - Peripheral access control key"]
173    #[inline(always)]
174    pub fn key(&self) -> KEY_R {
175        KEY_R::new(((self.bits >> 16) & 0xff) as u8)
176    }
177}
178impl W {
179    #[doc = "Bits 0:15 - Peripheral identifier"]
180    #[inline(always)]
181    pub fn perid(&mut self) -> PERID_W {
182        PERID_W { w: self }
183    }
184    #[doc = "Bits 16:23 - Peripheral access control key"]
185    #[inline(always)]
186    pub fn key(&mut self) -> KEY_W {
187        KEY_W { w: self }
188    }
189}