1#[doc = "Register `LOCK` reader"]
2pub struct R(crate::R<LOCK_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<LOCK_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<LOCK_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<LOCK_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `LOCK` writer"]
17pub struct W(crate::W<LOCK_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<LOCK_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<LOCK_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<LOCK_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum LOCK_A {
40 #[doc = "0: unlock"]
41 UNLOCK = 0,
42 #[doc = "1: Lock to current security level"]
43 LOCK = 1,
44}
45impl From<LOCK_A> for bool {
46 #[inline(always)]
47 fn from(variant: LOCK_A) -> Self {
48 variant as u8 != 0
49 }
50}
51#[doc = "Field `LOCK` reader - Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock."]
52pub struct LOCK_R(crate::FieldReader<bool, LOCK_A>);
53impl LOCK_R {
54 #[inline(always)]
55 pub(crate) fn new(bits: bool) -> Self {
56 LOCK_R(crate::FieldReader::new(bits))
57 }
58 #[doc = r"Get enumerated values variant"]
59 #[inline(always)]
60 pub fn variant(&self) -> LOCK_A {
61 match self.bits {
62 false => LOCK_A::UNLOCK,
63 true => LOCK_A::LOCK,
64 }
65 }
66 #[doc = "Checks if the value of the field is `UNLOCK`"]
67 #[inline(always)]
68 pub fn is_unlock(&self) -> bool {
69 **self == LOCK_A::UNLOCK
70 }
71 #[doc = "Checks if the value of the field is `LOCK`"]
72 #[inline(always)]
73 pub fn is_lock(&self) -> bool {
74 **self == LOCK_A::LOCK
75 }
76}
77impl core::ops::Deref for LOCK_R {
78 type Target = crate::FieldReader<bool, LOCK_A>;
79 #[inline(always)]
80 fn deref(&self) -> &Self::Target {
81 &self.0
82 }
83}
84#[doc = "Field `LOCK` writer - Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock."]
85pub struct LOCK_W<'a> {
86 w: &'a mut W,
87}
88impl<'a> LOCK_W<'a> {
89 #[doc = r"Writes `variant` to the field"]
90 #[inline(always)]
91 pub fn variant(self, variant: LOCK_A) -> &'a mut W {
92 self.bit(variant.into())
93 }
94 #[doc = "unlock"]
95 #[inline(always)]
96 pub fn unlock(self) -> &'a mut W {
97 self.variant(LOCK_A::UNLOCK)
98 }
99 #[doc = "Lock to current security level"]
100 #[inline(always)]
101 pub fn lock(self) -> &'a mut W {
102 self.variant(LOCK_A::LOCK)
103 }
104 #[doc = r"Sets the field bit"]
105 #[inline(always)]
106 pub fn set_bit(self) -> &'a mut W {
107 self.bit(true)
108 }
109 #[doc = r"Clears the field bit"]
110 #[inline(always)]
111 pub fn clear_bit(self) -> &'a mut W {
112 self.bit(false)
113 }
114 #[doc = r"Writes raw bits to the field"]
115 #[inline(always)]
116 pub fn bit(self, value: bool) -> &'a mut W {
117 self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
118 self.w
119 }
120}
121#[doc = "Must be written as 0x73D to change the register.\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq)]
123#[repr(u16)]
124pub enum KEY_A {
125 #[doc = "1853: If set during write, will allow lock or unlock"]
126 KWY_VALUE = 1853,
127}
128impl From<KEY_A> for u16 {
129 #[inline(always)]
130 fn from(variant: KEY_A) -> Self {
131 variant as _
132 }
133}
134#[doc = "Field `KEY` reader - Must be written as 0x73D to change the register."]
135pub struct KEY_R(crate::FieldReader<u16, KEY_A>);
136impl KEY_R {
137 #[inline(always)]
138 pub(crate) fn new(bits: u16) -> Self {
139 KEY_R(crate::FieldReader::new(bits))
140 }
141 #[doc = r"Get enumerated values variant"]
142 #[inline(always)]
143 pub fn variant(&self) -> Option<KEY_A> {
144 match self.bits {
145 1853 => Some(KEY_A::KWY_VALUE),
146 _ => None,
147 }
148 }
149 #[doc = "Checks if the value of the field is `KWY_VALUE`"]
150 #[inline(always)]
151 pub fn is_kwy_value(&self) -> bool {
152 **self == KEY_A::KWY_VALUE
153 }
154}
155impl core::ops::Deref for KEY_R {
156 type Target = crate::FieldReader<u16, KEY_A>;
157 #[inline(always)]
158 fn deref(&self) -> &Self::Target {
159 &self.0
160 }
161}
162#[doc = "Field `KEY` writer - Must be written as 0x73D to change the register."]
163pub struct KEY_W<'a> {
164 w: &'a mut W,
165}
166impl<'a> KEY_W<'a> {
167 #[doc = r"Writes `variant` to the field"]
168 #[inline(always)]
169 pub fn variant(self, variant: KEY_A) -> &'a mut W {
170 unsafe { self.bits(variant.into()) }
171 }
172 #[doc = "If set during write, will allow lock or unlock"]
173 #[inline(always)]
174 pub fn kwy_value(self) -> &'a mut W {
175 self.variant(KEY_A::KWY_VALUE)
176 }
177 #[doc = r"Writes raw bits to the field"]
178 #[inline(always)]
179 pub unsafe fn bits(self, value: u16) -> &'a mut W {
180 self.w.bits = (self.w.bits & !(0x1fff << 4)) | ((value as u32 & 0x1fff) << 4);
181 self.w
182 }
183}
184impl R {
185 #[doc = "Bit 0 - Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock."]
186 #[inline(always)]
187 pub fn lock(&self) -> LOCK_R {
188 LOCK_R::new((self.bits & 0x01) != 0)
189 }
190 #[doc = "Bits 4:16 - Must be written as 0x73D to change the register."]
191 #[inline(always)]
192 pub fn key(&self) -> KEY_R {
193 KEY_R::new(((self.bits >> 4) & 0x1fff) as u16)
194 }
195}
196impl W {
197 #[doc = "Bit 0 - Reads back with security level locked to, or 0. Writes as 0 to unlock, 1 to lock."]
198 #[inline(always)]
199 pub fn lock(&mut self) -> LOCK_W {
200 LOCK_W { w: self }
201 }
202 #[doc = "Bits 4:16 - Must be written as 0x73D to change the register."]
203 #[inline(always)]
204 pub fn key(&mut self) -> KEY_W {
205 KEY_W { w: self }
206 }
207 #[doc = "Writes raw bits to the register."]
208 #[inline(always)]
209 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
210 self.0.bits(bits);
211 self
212 }
213}
214#[doc = "Security lock register\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 [lock](index.html) module"]
215pub struct LOCK_SPEC;
216impl crate::RegisterSpec for LOCK_SPEC {
217 type Ux = u32;
218}
219#[doc = "`read()` method returns [lock::R](R) reader structure"]
220impl crate::Readable for LOCK_SPEC {
221 type Reader = R;
222}
223#[doc = "`write(|w| ..)` method takes [lock::W](W) writer structure"]
224impl crate::Writable for LOCK_SPEC {
225 type Writer = W;
226}
227#[doc = "`reset()` method sets LOCK to value 0"]
228impl crate::Resettable for LOCK_SPEC {
229 #[inline(always)]
230 fn reset_value() -> Self::Ux {
231 0
232 }
233}