avr_device/devices/atmega328p/lockbit/
lockbit.rs1#[doc = "Register `LOCKBIT` reader"]
2pub struct R(crate::R<LOCKBIT_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<LOCKBIT_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<LOCKBIT_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<LOCKBIT_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `LOCKBIT` writer"]
17pub struct W(crate::W<LOCKBIT_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<LOCKBIT_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<LOCKBIT_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<LOCKBIT_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `LB` reader - Memory Lock"]
38pub type LB_R = crate::FieldReader<u8, LB_A>;
39#[doc = "Memory Lock\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum LB_A {
43 #[doc = "0: Further programming and verification disabled"]
44 PROG_VER_DISABLED = 0,
45 #[doc = "2: Further programming disabled"]
46 PROG_DISABLED = 2,
47 #[doc = "3: No memory lock features enabled"]
48 NO_LOCK = 3,
49}
50impl From<LB_A> for u8 {
51 #[inline(always)]
52 fn from(variant: LB_A) -> Self {
53 variant as _
54 }
55}
56impl LB_R {
57 #[doc = "Get enumerated values variant"]
58 #[inline(always)]
59 pub fn variant(&self) -> Option<LB_A> {
60 match self.bits {
61 0 => Some(LB_A::PROG_VER_DISABLED),
62 2 => Some(LB_A::PROG_DISABLED),
63 3 => Some(LB_A::NO_LOCK),
64 _ => None,
65 }
66 }
67 #[doc = "Checks if the value of the field is `PROG_VER_DISABLED`"]
68 #[inline(always)]
69 pub fn is_prog_ver_disabled(&self) -> bool {
70 *self == LB_A::PROG_VER_DISABLED
71 }
72 #[doc = "Checks if the value of the field is `PROG_DISABLED`"]
73 #[inline(always)]
74 pub fn is_prog_disabled(&self) -> bool {
75 *self == LB_A::PROG_DISABLED
76 }
77 #[doc = "Checks if the value of the field is `NO_LOCK`"]
78 #[inline(always)]
79 pub fn is_no_lock(&self) -> bool {
80 *self == LB_A::NO_LOCK
81 }
82}
83#[doc = "Field `LB` writer - Memory Lock"]
84pub type LB_W<'a, const O: u8> = crate::FieldWriter<'a, u8, LOCKBIT_SPEC, u8, LB_A, 2, O>;
85impl<'a, const O: u8> LB_W<'a, O> {
86 #[doc = "Further programming and verification disabled"]
87 #[inline(always)]
88 pub fn prog_ver_disabled(self) -> &'a mut W {
89 self.variant(LB_A::PROG_VER_DISABLED)
90 }
91 #[doc = "Further programming disabled"]
92 #[inline(always)]
93 pub fn prog_disabled(self) -> &'a mut W {
94 self.variant(LB_A::PROG_DISABLED)
95 }
96 #[doc = "No memory lock features enabled"]
97 #[inline(always)]
98 pub fn no_lock(self) -> &'a mut W {
99 self.variant(LB_A::NO_LOCK)
100 }
101}
102#[doc = "Field `BLB0` reader - Boot Loader Protection Mode"]
103pub type BLB0_R = crate::FieldReader<u8, BLB0_A>;
104#[doc = "Boot Loader Protection Mode\n\nValue on reset: 0"]
105#[derive(Clone, Copy, Debug, PartialEq, Eq)]
106#[repr(u8)]
107pub enum BLB0_A {
108 #[doc = "0: LPM and SPM prohibited in Application Section"]
109 LPM_SPM_DISABLE = 0,
110 #[doc = "1: LPM prohibited in Application Section"]
111 LPM_DISABLE = 1,
112 #[doc = "2: SPM prohibited in Application Section"]
113 SPM_DISABLE = 2,
114 #[doc = "3: No lock on SPM and LPM in Application Section"]
115 NO_LOCK = 3,
116}
117impl From<BLB0_A> for u8 {
118 #[inline(always)]
119 fn from(variant: BLB0_A) -> Self {
120 variant as _
121 }
122}
123impl BLB0_R {
124 #[doc = "Get enumerated values variant"]
125 #[inline(always)]
126 pub fn variant(&self) -> BLB0_A {
127 match self.bits {
128 0 => BLB0_A::LPM_SPM_DISABLE,
129 1 => BLB0_A::LPM_DISABLE,
130 2 => BLB0_A::SPM_DISABLE,
131 3 => BLB0_A::NO_LOCK,
132 _ => unreachable!(),
133 }
134 }
135 #[doc = "Checks if the value of the field is `LPM_SPM_DISABLE`"]
136 #[inline(always)]
137 pub fn is_lpm_spm_disable(&self) -> bool {
138 *self == BLB0_A::LPM_SPM_DISABLE
139 }
140 #[doc = "Checks if the value of the field is `LPM_DISABLE`"]
141 #[inline(always)]
142 pub fn is_lpm_disable(&self) -> bool {
143 *self == BLB0_A::LPM_DISABLE
144 }
145 #[doc = "Checks if the value of the field is `SPM_DISABLE`"]
146 #[inline(always)]
147 pub fn is_spm_disable(&self) -> bool {
148 *self == BLB0_A::SPM_DISABLE
149 }
150 #[doc = "Checks if the value of the field is `NO_LOCK`"]
151 #[inline(always)]
152 pub fn is_no_lock(&self) -> bool {
153 *self == BLB0_A::NO_LOCK
154 }
155}
156#[doc = "Field `BLB0` writer - Boot Loader Protection Mode"]
157pub type BLB0_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, LOCKBIT_SPEC, u8, BLB0_A, 2, O>;
158impl<'a, const O: u8> BLB0_W<'a, O> {
159 #[doc = "LPM and SPM prohibited in Application Section"]
160 #[inline(always)]
161 pub fn lpm_spm_disable(self) -> &'a mut W {
162 self.variant(BLB0_A::LPM_SPM_DISABLE)
163 }
164 #[doc = "LPM prohibited in Application Section"]
165 #[inline(always)]
166 pub fn lpm_disable(self) -> &'a mut W {
167 self.variant(BLB0_A::LPM_DISABLE)
168 }
169 #[doc = "SPM prohibited in Application Section"]
170 #[inline(always)]
171 pub fn spm_disable(self) -> &'a mut W {
172 self.variant(BLB0_A::SPM_DISABLE)
173 }
174 #[doc = "No lock on SPM and LPM in Application Section"]
175 #[inline(always)]
176 pub fn no_lock(self) -> &'a mut W {
177 self.variant(BLB0_A::NO_LOCK)
178 }
179}
180#[doc = "Field `BLB1` reader - Boot Loader Protection Mode"]
181pub type BLB1_R = crate::FieldReader<u8, BLB1_A>;
182#[doc = "Boot Loader Protection Mode\n\nValue on reset: 0"]
183#[derive(Clone, Copy, Debug, PartialEq, Eq)]
184#[repr(u8)]
185pub enum BLB1_A {
186 #[doc = "0: LPM and SPM prohibited in Boot Section"]
187 LPM_SPM_DISABLE = 0,
188 #[doc = "1: LPM prohibited in Boot Section"]
189 LPM_DISABLE = 1,
190 #[doc = "2: SPM prohibited in Boot Section"]
191 SPM_DISABLE = 2,
192 #[doc = "3: No lock on SPM and LPM in Boot Section"]
193 NO_LOCK = 3,
194}
195impl From<BLB1_A> for u8 {
196 #[inline(always)]
197 fn from(variant: BLB1_A) -> Self {
198 variant as _
199 }
200}
201impl BLB1_R {
202 #[doc = "Get enumerated values variant"]
203 #[inline(always)]
204 pub fn variant(&self) -> BLB1_A {
205 match self.bits {
206 0 => BLB1_A::LPM_SPM_DISABLE,
207 1 => BLB1_A::LPM_DISABLE,
208 2 => BLB1_A::SPM_DISABLE,
209 3 => BLB1_A::NO_LOCK,
210 _ => unreachable!(),
211 }
212 }
213 #[doc = "Checks if the value of the field is `LPM_SPM_DISABLE`"]
214 #[inline(always)]
215 pub fn is_lpm_spm_disable(&self) -> bool {
216 *self == BLB1_A::LPM_SPM_DISABLE
217 }
218 #[doc = "Checks if the value of the field is `LPM_DISABLE`"]
219 #[inline(always)]
220 pub fn is_lpm_disable(&self) -> bool {
221 *self == BLB1_A::LPM_DISABLE
222 }
223 #[doc = "Checks if the value of the field is `SPM_DISABLE`"]
224 #[inline(always)]
225 pub fn is_spm_disable(&self) -> bool {
226 *self == BLB1_A::SPM_DISABLE
227 }
228 #[doc = "Checks if the value of the field is `NO_LOCK`"]
229 #[inline(always)]
230 pub fn is_no_lock(&self) -> bool {
231 *self == BLB1_A::NO_LOCK
232 }
233}
234#[doc = "Field `BLB1` writer - Boot Loader Protection Mode"]
235pub type BLB1_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, LOCKBIT_SPEC, u8, BLB1_A, 2, O>;
236impl<'a, const O: u8> BLB1_W<'a, O> {
237 #[doc = "LPM and SPM prohibited in Boot Section"]
238 #[inline(always)]
239 pub fn lpm_spm_disable(self) -> &'a mut W {
240 self.variant(BLB1_A::LPM_SPM_DISABLE)
241 }
242 #[doc = "LPM prohibited in Boot Section"]
243 #[inline(always)]
244 pub fn lpm_disable(self) -> &'a mut W {
245 self.variant(BLB1_A::LPM_DISABLE)
246 }
247 #[doc = "SPM prohibited in Boot Section"]
248 #[inline(always)]
249 pub fn spm_disable(self) -> &'a mut W {
250 self.variant(BLB1_A::SPM_DISABLE)
251 }
252 #[doc = "No lock on SPM and LPM in Boot Section"]
253 #[inline(always)]
254 pub fn no_lock(self) -> &'a mut W {
255 self.variant(BLB1_A::NO_LOCK)
256 }
257}
258impl R {
259 #[doc = "Bits 0:1 - Memory Lock"]
260 #[inline(always)]
261 pub fn lb(&self) -> LB_R {
262 LB_R::new(self.bits & 3)
263 }
264 #[doc = "Bits 2:3 - Boot Loader Protection Mode"]
265 #[inline(always)]
266 pub fn blb0(&self) -> BLB0_R {
267 BLB0_R::new((self.bits >> 2) & 3)
268 }
269 #[doc = "Bits 4:5 - Boot Loader Protection Mode"]
270 #[inline(always)]
271 pub fn blb1(&self) -> BLB1_R {
272 BLB1_R::new((self.bits >> 4) & 3)
273 }
274}
275impl W {
276 #[doc = "Bits 0:1 - Memory Lock"]
277 #[inline(always)]
278 #[must_use]
279 pub fn lb(&mut self) -> LB_W<0> {
280 LB_W::new(self)
281 }
282 #[doc = "Bits 2:3 - Boot Loader Protection Mode"]
283 #[inline(always)]
284 #[must_use]
285 pub fn blb0(&mut self) -> BLB0_W<2> {
286 BLB0_W::new(self)
287 }
288 #[doc = "Bits 4:5 - Boot Loader Protection Mode"]
289 #[inline(always)]
290 #[must_use]
291 pub fn blb1(&mut self) -> BLB1_W<4> {
292 BLB1_W::new(self)
293 }
294 #[doc = "Writes raw bits to the register."]
295 #[inline(always)]
296 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
297 self.0.bits(bits);
298 self
299 }
300}
301#[doc = "No Description.\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 [lockbit](index.html) module"]
302pub struct LOCKBIT_SPEC;
303impl crate::RegisterSpec for LOCKBIT_SPEC {
304 type Ux = u8;
305}
306#[doc = "`read()` method returns [lockbit::R](R) reader structure"]
307impl crate::Readable for LOCKBIT_SPEC {
308 type Reader = R;
309}
310#[doc = "`write(|w| ..)` method takes [lockbit::W](W) writer structure"]
311impl crate::Writable for LOCKBIT_SPEC {
312 type Writer = W;
313 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
314 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
315}
316#[doc = "`reset()` method sets LOCKBIT to value 0"]
317impl crate::Resettable for LOCKBIT_SPEC {
318 const RESET_VALUE: Self::Ux = 0;
319}