atsaml21e18a/nvmctrl/
ctrla.rs1#[doc = "Register `CTRLA` reader"]
2pub struct R(crate::R<CTRLA_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRLA_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRLA_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRLA_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRLA` writer"]
17pub struct W(crate::W<CTRLA_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRLA_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<CTRLA_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRLA_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CMD` reader - Command"]
38pub type CMD_R = crate::FieldReader<u8, CMDSELECT_A>;
39#[doc = "Command\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CMDSELECT_A {
43 #[doc = "2: Erase Row - Erases the row addressed by the ADDR register."]
44 ER = 2,
45 #[doc = "4: Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register."]
46 WP = 4,
47 #[doc = "5: Erase Auxiliary Row - Erases the auxiliary row addressed by the ADDR register. This command can be given only when the security bit is not set and only to the user configuration row."]
48 EAR = 5,
49 #[doc = "6: Write Auxiliary Page - Writes the contents of the page buffer to the page addressed by the ADDR register. This command can be given only when the security bit is not set and only to the user configuration row."]
50 WAP = 6,
51 #[doc = "10: Security Flow Command"]
52 SF = 10,
53 #[doc = "15: Write lockbits"]
54 WL = 15,
55 #[doc = "26: RWW EEPROM area Erase Row - Erases the row addressed by the ADDR register."]
56 RWWEEER = 26,
57 #[doc = "28: RWW EEPROM Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register."]
58 RWWEEWP = 28,
59 #[doc = "64: Lock Region - Locks the region containing the address location in the ADDR register."]
60 LR = 64,
61 #[doc = "65: Unlock Region - Unlocks the region containing the address location in the ADDR register."]
62 UR = 65,
63 #[doc = "66: Sets the power reduction mode."]
64 SPRM = 66,
65 #[doc = "67: Clears the power reduction mode."]
66 CPRM = 67,
67 #[doc = "68: Page Buffer Clear - Clears the page buffer."]
68 PBC = 68,
69 #[doc = "69: Set Security Bit - Sets the security bit by writing 0x00 to the first byte in the lockbit row."]
70 SSB = 69,
71 #[doc = "70: Invalidate all cache lines."]
72 INVALL = 70,
73}
74impl From<CMDSELECT_A> for u8 {
75 #[inline(always)]
76 fn from(variant: CMDSELECT_A) -> Self {
77 variant as _
78 }
79}
80impl CMD_R {
81 #[doc = "Get enumerated values variant"]
82 #[inline(always)]
83 pub fn variant(&self) -> Option<CMDSELECT_A> {
84 match self.bits {
85 2 => Some(CMDSELECT_A::ER),
86 4 => Some(CMDSELECT_A::WP),
87 5 => Some(CMDSELECT_A::EAR),
88 6 => Some(CMDSELECT_A::WAP),
89 10 => Some(CMDSELECT_A::SF),
90 15 => Some(CMDSELECT_A::WL),
91 26 => Some(CMDSELECT_A::RWWEEER),
92 28 => Some(CMDSELECT_A::RWWEEWP),
93 64 => Some(CMDSELECT_A::LR),
94 65 => Some(CMDSELECT_A::UR),
95 66 => Some(CMDSELECT_A::SPRM),
96 67 => Some(CMDSELECT_A::CPRM),
97 68 => Some(CMDSELECT_A::PBC),
98 69 => Some(CMDSELECT_A::SSB),
99 70 => Some(CMDSELECT_A::INVALL),
100 _ => None,
101 }
102 }
103 #[doc = "Checks if the value of the field is `ER`"]
104 #[inline(always)]
105 pub fn is_er(&self) -> bool {
106 *self == CMDSELECT_A::ER
107 }
108 #[doc = "Checks if the value of the field is `WP`"]
109 #[inline(always)]
110 pub fn is_wp(&self) -> bool {
111 *self == CMDSELECT_A::WP
112 }
113 #[doc = "Checks if the value of the field is `EAR`"]
114 #[inline(always)]
115 pub fn is_ear(&self) -> bool {
116 *self == CMDSELECT_A::EAR
117 }
118 #[doc = "Checks if the value of the field is `WAP`"]
119 #[inline(always)]
120 pub fn is_wap(&self) -> bool {
121 *self == CMDSELECT_A::WAP
122 }
123 #[doc = "Checks if the value of the field is `SF`"]
124 #[inline(always)]
125 pub fn is_sf(&self) -> bool {
126 *self == CMDSELECT_A::SF
127 }
128 #[doc = "Checks if the value of the field is `WL`"]
129 #[inline(always)]
130 pub fn is_wl(&self) -> bool {
131 *self == CMDSELECT_A::WL
132 }
133 #[doc = "Checks if the value of the field is `RWWEEER`"]
134 #[inline(always)]
135 pub fn is_rwweeer(&self) -> bool {
136 *self == CMDSELECT_A::RWWEEER
137 }
138 #[doc = "Checks if the value of the field is `RWWEEWP`"]
139 #[inline(always)]
140 pub fn is_rwweewp(&self) -> bool {
141 *self == CMDSELECT_A::RWWEEWP
142 }
143 #[doc = "Checks if the value of the field is `LR`"]
144 #[inline(always)]
145 pub fn is_lr(&self) -> bool {
146 *self == CMDSELECT_A::LR
147 }
148 #[doc = "Checks if the value of the field is `UR`"]
149 #[inline(always)]
150 pub fn is_ur(&self) -> bool {
151 *self == CMDSELECT_A::UR
152 }
153 #[doc = "Checks if the value of the field is `SPRM`"]
154 #[inline(always)]
155 pub fn is_sprm(&self) -> bool {
156 *self == CMDSELECT_A::SPRM
157 }
158 #[doc = "Checks if the value of the field is `CPRM`"]
159 #[inline(always)]
160 pub fn is_cprm(&self) -> bool {
161 *self == CMDSELECT_A::CPRM
162 }
163 #[doc = "Checks if the value of the field is `PBC`"]
164 #[inline(always)]
165 pub fn is_pbc(&self) -> bool {
166 *self == CMDSELECT_A::PBC
167 }
168 #[doc = "Checks if the value of the field is `SSB`"]
169 #[inline(always)]
170 pub fn is_ssb(&self) -> bool {
171 *self == CMDSELECT_A::SSB
172 }
173 #[doc = "Checks if the value of the field is `INVALL`"]
174 #[inline(always)]
175 pub fn is_invall(&self) -> bool {
176 *self == CMDSELECT_A::INVALL
177 }
178}
179#[doc = "Field `CMD` writer - Command"]
180pub type CMD_W<'a, const O: u8> = crate::FieldWriter<'a, u16, CTRLA_SPEC, u8, CMDSELECT_A, 7, O>;
181impl<'a, const O: u8> CMD_W<'a, O> {
182 #[doc = "Erase Row - Erases the row addressed by the ADDR register."]
183 #[inline(always)]
184 pub fn er(self) -> &'a mut W {
185 self.variant(CMDSELECT_A::ER)
186 }
187 #[doc = "Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register."]
188 #[inline(always)]
189 pub fn wp(self) -> &'a mut W {
190 self.variant(CMDSELECT_A::WP)
191 }
192 #[doc = "Erase Auxiliary Row - Erases the auxiliary row addressed by the ADDR register. This command can be given only when the security bit is not set and only to the user configuration row."]
193 #[inline(always)]
194 pub fn ear(self) -> &'a mut W {
195 self.variant(CMDSELECT_A::EAR)
196 }
197 #[doc = "Write Auxiliary Page - Writes the contents of the page buffer to the page addressed by the ADDR register. This command can be given only when the security bit is not set and only to the user configuration row."]
198 #[inline(always)]
199 pub fn wap(self) -> &'a mut W {
200 self.variant(CMDSELECT_A::WAP)
201 }
202 #[doc = "Security Flow Command"]
203 #[inline(always)]
204 pub fn sf(self) -> &'a mut W {
205 self.variant(CMDSELECT_A::SF)
206 }
207 #[doc = "Write lockbits"]
208 #[inline(always)]
209 pub fn wl(self) -> &'a mut W {
210 self.variant(CMDSELECT_A::WL)
211 }
212 #[doc = "RWW EEPROM area Erase Row - Erases the row addressed by the ADDR register."]
213 #[inline(always)]
214 pub fn rwweeer(self) -> &'a mut W {
215 self.variant(CMDSELECT_A::RWWEEER)
216 }
217 #[doc = "RWW EEPROM Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register."]
218 #[inline(always)]
219 pub fn rwweewp(self) -> &'a mut W {
220 self.variant(CMDSELECT_A::RWWEEWP)
221 }
222 #[doc = "Lock Region - Locks the region containing the address location in the ADDR register."]
223 #[inline(always)]
224 pub fn lr(self) -> &'a mut W {
225 self.variant(CMDSELECT_A::LR)
226 }
227 #[doc = "Unlock Region - Unlocks the region containing the address location in the ADDR register."]
228 #[inline(always)]
229 pub fn ur(self) -> &'a mut W {
230 self.variant(CMDSELECT_A::UR)
231 }
232 #[doc = "Sets the power reduction mode."]
233 #[inline(always)]
234 pub fn sprm(self) -> &'a mut W {
235 self.variant(CMDSELECT_A::SPRM)
236 }
237 #[doc = "Clears the power reduction mode."]
238 #[inline(always)]
239 pub fn cprm(self) -> &'a mut W {
240 self.variant(CMDSELECT_A::CPRM)
241 }
242 #[doc = "Page Buffer Clear - Clears the page buffer."]
243 #[inline(always)]
244 pub fn pbc(self) -> &'a mut W {
245 self.variant(CMDSELECT_A::PBC)
246 }
247 #[doc = "Set Security Bit - Sets the security bit by writing 0x00 to the first byte in the lockbit row."]
248 #[inline(always)]
249 pub fn ssb(self) -> &'a mut W {
250 self.variant(CMDSELECT_A::SSB)
251 }
252 #[doc = "Invalidate all cache lines."]
253 #[inline(always)]
254 pub fn invall(self) -> &'a mut W {
255 self.variant(CMDSELECT_A::INVALL)
256 }
257}
258#[doc = "Field `CMDEX` reader - Command Execution"]
259pub type CMDEX_R = crate::FieldReader<u8, CMDEXSELECT_A>;
260#[doc = "Command Execution\n\nValue on reset: 0"]
261#[derive(Clone, Copy, Debug, PartialEq, Eq)]
262#[repr(u8)]
263pub enum CMDEXSELECT_A {
264 #[doc = "165: Execution Key"]
265 KEY = 165,
266}
267impl From<CMDEXSELECT_A> for u8 {
268 #[inline(always)]
269 fn from(variant: CMDEXSELECT_A) -> Self {
270 variant as _
271 }
272}
273impl CMDEX_R {
274 #[doc = "Get enumerated values variant"]
275 #[inline(always)]
276 pub fn variant(&self) -> Option<CMDEXSELECT_A> {
277 match self.bits {
278 165 => Some(CMDEXSELECT_A::KEY),
279 _ => None,
280 }
281 }
282 #[doc = "Checks if the value of the field is `KEY`"]
283 #[inline(always)]
284 pub fn is_key(&self) -> bool {
285 *self == CMDEXSELECT_A::KEY
286 }
287}
288#[doc = "Field `CMDEX` writer - Command Execution"]
289pub type CMDEX_W<'a, const O: u8> =
290 crate::FieldWriter<'a, u16, CTRLA_SPEC, u8, CMDEXSELECT_A, 8, O>;
291impl<'a, const O: u8> CMDEX_W<'a, O> {
292 #[doc = "Execution Key"]
293 #[inline(always)]
294 pub fn key(self) -> &'a mut W {
295 self.variant(CMDEXSELECT_A::KEY)
296 }
297}
298impl R {
299 #[doc = "Bits 0:6 - Command"]
300 #[inline(always)]
301 pub fn cmd(&self) -> CMD_R {
302 CMD_R::new((self.bits & 0x7f) as u8)
303 }
304 #[doc = "Bits 8:15 - Command Execution"]
305 #[inline(always)]
306 pub fn cmdex(&self) -> CMDEX_R {
307 CMDEX_R::new(((self.bits >> 8) & 0xff) as u8)
308 }
309}
310impl W {
311 #[doc = "Bits 0:6 - Command"]
312 #[inline(always)]
313 #[must_use]
314 pub fn cmd(&mut self) -> CMD_W<0> {
315 CMD_W::new(self)
316 }
317 #[doc = "Bits 8:15 - Command Execution"]
318 #[inline(always)]
319 #[must_use]
320 pub fn cmdex(&mut self) -> CMDEX_W<8> {
321 CMDEX_W::new(self)
322 }
323 #[doc = "Writes raw bits to the register."]
324 #[inline(always)]
325 pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
326 self.0.bits(bits);
327 self
328 }
329}
330#[doc = "Control A\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 [ctrla](index.html) module"]
331pub struct CTRLA_SPEC;
332impl crate::RegisterSpec for CTRLA_SPEC {
333 type Ux = u16;
334}
335#[doc = "`read()` method returns [ctrla::R](R) reader structure"]
336impl crate::Readable for CTRLA_SPEC {
337 type Reader = R;
338}
339#[doc = "`write(|w| ..)` method takes [ctrla::W](W) writer structure"]
340impl crate::Writable for CTRLA_SPEC {
341 type Writer = W;
342 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
343 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
344}
345#[doc = "`reset()` method sets CTRLA to value 0"]
346impl crate::Resettable for CTRLA_SPEC {
347 const RESET_VALUE: Self::Ux = 0;
348}