atsamd11c/nvmctrl/
ctrla.rs
1#[doc = "Register `CTRLA` reader"]
2pub type R = crate::R<CtrlaSpec>;
3#[doc = "Register `CTRLA` writer"]
4pub type W = crate::W<CtrlaSpec>;
5#[doc = "Command\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Cmdselect {
9 #[doc = "2: Erase Row - Erases the row addressed by the ADDR register."]
10 Er = 2,
11 #[doc = "4: Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register."]
12 Wp = 4,
13 #[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."]
14 Ear = 5,
15 #[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."]
16 Wap = 6,
17 #[doc = "10: Security Flow Command"]
18 Sf = 10,
19 #[doc = "15: Write lockbits"]
20 Wl = 15,
21 #[doc = "64: Lock Region - Locks the region containing the address location in the ADDR register."]
22 Lr = 64,
23 #[doc = "65: Unlock Region - Unlocks the region containing the address location in the ADDR register."]
24 Ur = 65,
25 #[doc = "66: Sets the power reduction mode."]
26 Sprm = 66,
27 #[doc = "67: Clears the power reduction mode."]
28 Cprm = 67,
29 #[doc = "68: Page Buffer Clear - Clears the page buffer."]
30 Pbc = 68,
31 #[doc = "69: Set Security Bit - Sets the security bit by writing 0x00 to the first byte in the lockbit row."]
32 Ssb = 69,
33 #[doc = "70: Invalidates all cache lines."]
34 Invall = 70,
35}
36impl From<Cmdselect> for u8 {
37 #[inline(always)]
38 fn from(variant: Cmdselect) -> Self {
39 variant as _
40 }
41}
42impl crate::FieldSpec for Cmdselect {
43 type Ux = u8;
44}
45impl crate::IsEnum for Cmdselect {}
46#[doc = "Field `CMD` reader - Command"]
47pub type CmdR = crate::FieldReader<Cmdselect>;
48impl CmdR {
49 #[doc = "Get enumerated values variant"]
50 #[inline(always)]
51 pub const fn variant(&self) -> Option<Cmdselect> {
52 match self.bits {
53 2 => Some(Cmdselect::Er),
54 4 => Some(Cmdselect::Wp),
55 5 => Some(Cmdselect::Ear),
56 6 => Some(Cmdselect::Wap),
57 10 => Some(Cmdselect::Sf),
58 15 => Some(Cmdselect::Wl),
59 64 => Some(Cmdselect::Lr),
60 65 => Some(Cmdselect::Ur),
61 66 => Some(Cmdselect::Sprm),
62 67 => Some(Cmdselect::Cprm),
63 68 => Some(Cmdselect::Pbc),
64 69 => Some(Cmdselect::Ssb),
65 70 => Some(Cmdselect::Invall),
66 _ => None,
67 }
68 }
69 #[doc = "Erase Row - Erases the row addressed by the ADDR register."]
70 #[inline(always)]
71 pub fn is_er(&self) -> bool {
72 *self == Cmdselect::Er
73 }
74 #[doc = "Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register."]
75 #[inline(always)]
76 pub fn is_wp(&self) -> bool {
77 *self == Cmdselect::Wp
78 }
79 #[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."]
80 #[inline(always)]
81 pub fn is_ear(&self) -> bool {
82 *self == Cmdselect::Ear
83 }
84 #[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."]
85 #[inline(always)]
86 pub fn is_wap(&self) -> bool {
87 *self == Cmdselect::Wap
88 }
89 #[doc = "Security Flow Command"]
90 #[inline(always)]
91 pub fn is_sf(&self) -> bool {
92 *self == Cmdselect::Sf
93 }
94 #[doc = "Write lockbits"]
95 #[inline(always)]
96 pub fn is_wl(&self) -> bool {
97 *self == Cmdselect::Wl
98 }
99 #[doc = "Lock Region - Locks the region containing the address location in the ADDR register."]
100 #[inline(always)]
101 pub fn is_lr(&self) -> bool {
102 *self == Cmdselect::Lr
103 }
104 #[doc = "Unlock Region - Unlocks the region containing the address location in the ADDR register."]
105 #[inline(always)]
106 pub fn is_ur(&self) -> bool {
107 *self == Cmdselect::Ur
108 }
109 #[doc = "Sets the power reduction mode."]
110 #[inline(always)]
111 pub fn is_sprm(&self) -> bool {
112 *self == Cmdselect::Sprm
113 }
114 #[doc = "Clears the power reduction mode."]
115 #[inline(always)]
116 pub fn is_cprm(&self) -> bool {
117 *self == Cmdselect::Cprm
118 }
119 #[doc = "Page Buffer Clear - Clears the page buffer."]
120 #[inline(always)]
121 pub fn is_pbc(&self) -> bool {
122 *self == Cmdselect::Pbc
123 }
124 #[doc = "Set Security Bit - Sets the security bit by writing 0x00 to the first byte in the lockbit row."]
125 #[inline(always)]
126 pub fn is_ssb(&self) -> bool {
127 *self == Cmdselect::Ssb
128 }
129 #[doc = "Invalidates all cache lines."]
130 #[inline(always)]
131 pub fn is_invall(&self) -> bool {
132 *self == Cmdselect::Invall
133 }
134}
135#[doc = "Field `CMD` writer - Command"]
136pub type CmdW<'a, REG> = crate::FieldWriter<'a, REG, 7, Cmdselect>;
137impl<'a, REG> CmdW<'a, REG>
138where
139 REG: crate::Writable + crate::RegisterSpec,
140 REG::Ux: From<u8>,
141{
142 #[doc = "Erase Row - Erases the row addressed by the ADDR register."]
143 #[inline(always)]
144 pub fn er(self) -> &'a mut crate::W<REG> {
145 self.variant(Cmdselect::Er)
146 }
147 #[doc = "Write Page - Writes the contents of the page buffer to the page addressed by the ADDR register."]
148 #[inline(always)]
149 pub fn wp(self) -> &'a mut crate::W<REG> {
150 self.variant(Cmdselect::Wp)
151 }
152 #[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."]
153 #[inline(always)]
154 pub fn ear(self) -> &'a mut crate::W<REG> {
155 self.variant(Cmdselect::Ear)
156 }
157 #[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."]
158 #[inline(always)]
159 pub fn wap(self) -> &'a mut crate::W<REG> {
160 self.variant(Cmdselect::Wap)
161 }
162 #[doc = "Security Flow Command"]
163 #[inline(always)]
164 pub fn sf(self) -> &'a mut crate::W<REG> {
165 self.variant(Cmdselect::Sf)
166 }
167 #[doc = "Write lockbits"]
168 #[inline(always)]
169 pub fn wl(self) -> &'a mut crate::W<REG> {
170 self.variant(Cmdselect::Wl)
171 }
172 #[doc = "Lock Region - Locks the region containing the address location in the ADDR register."]
173 #[inline(always)]
174 pub fn lr(self) -> &'a mut crate::W<REG> {
175 self.variant(Cmdselect::Lr)
176 }
177 #[doc = "Unlock Region - Unlocks the region containing the address location in the ADDR register."]
178 #[inline(always)]
179 pub fn ur(self) -> &'a mut crate::W<REG> {
180 self.variant(Cmdselect::Ur)
181 }
182 #[doc = "Sets the power reduction mode."]
183 #[inline(always)]
184 pub fn sprm(self) -> &'a mut crate::W<REG> {
185 self.variant(Cmdselect::Sprm)
186 }
187 #[doc = "Clears the power reduction mode."]
188 #[inline(always)]
189 pub fn cprm(self) -> &'a mut crate::W<REG> {
190 self.variant(Cmdselect::Cprm)
191 }
192 #[doc = "Page Buffer Clear - Clears the page buffer."]
193 #[inline(always)]
194 pub fn pbc(self) -> &'a mut crate::W<REG> {
195 self.variant(Cmdselect::Pbc)
196 }
197 #[doc = "Set Security Bit - Sets the security bit by writing 0x00 to the first byte in the lockbit row."]
198 #[inline(always)]
199 pub fn ssb(self) -> &'a mut crate::W<REG> {
200 self.variant(Cmdselect::Ssb)
201 }
202 #[doc = "Invalidates all cache lines."]
203 #[inline(always)]
204 pub fn invall(self) -> &'a mut crate::W<REG> {
205 self.variant(Cmdselect::Invall)
206 }
207}
208#[doc = "Command Execution\n\nValue on reset: 0"]
209#[derive(Clone, Copy, Debug, PartialEq, Eq)]
210#[repr(u8)]
211pub enum Cmdexselect {
212 #[doc = "165: Execution Key"]
213 Key = 165,
214}
215impl From<Cmdexselect> for u8 {
216 #[inline(always)]
217 fn from(variant: Cmdexselect) -> Self {
218 variant as _
219 }
220}
221impl crate::FieldSpec for Cmdexselect {
222 type Ux = u8;
223}
224impl crate::IsEnum for Cmdexselect {}
225#[doc = "Field `CMDEX` reader - Command Execution"]
226pub type CmdexR = crate::FieldReader<Cmdexselect>;
227impl CmdexR {
228 #[doc = "Get enumerated values variant"]
229 #[inline(always)]
230 pub const fn variant(&self) -> Option<Cmdexselect> {
231 match self.bits {
232 165 => Some(Cmdexselect::Key),
233 _ => None,
234 }
235 }
236 #[doc = "Execution Key"]
237 #[inline(always)]
238 pub fn is_key(&self) -> bool {
239 *self == Cmdexselect::Key
240 }
241}
242#[doc = "Field `CMDEX` writer - Command Execution"]
243pub type CmdexW<'a, REG> = crate::FieldWriter<'a, REG, 8, Cmdexselect>;
244impl<'a, REG> CmdexW<'a, REG>
245where
246 REG: crate::Writable + crate::RegisterSpec,
247 REG::Ux: From<u8>,
248{
249 #[doc = "Execution Key"]
250 #[inline(always)]
251 pub fn key(self) -> &'a mut crate::W<REG> {
252 self.variant(Cmdexselect::Key)
253 }
254}
255impl R {
256 #[doc = "Bits 0:6 - Command"]
257 #[inline(always)]
258 pub fn cmd(&self) -> CmdR {
259 CmdR::new((self.bits & 0x7f) as u8)
260 }
261 #[doc = "Bits 8:15 - Command Execution"]
262 #[inline(always)]
263 pub fn cmdex(&self) -> CmdexR {
264 CmdexR::new(((self.bits >> 8) & 0xff) as u8)
265 }
266}
267impl W {
268 #[doc = "Bits 0:6 - Command"]
269 #[inline(always)]
270 #[must_use]
271 pub fn cmd(&mut self) -> CmdW<CtrlaSpec> {
272 CmdW::new(self, 0)
273 }
274 #[doc = "Bits 8:15 - Command Execution"]
275 #[inline(always)]
276 #[must_use]
277 pub fn cmdex(&mut self) -> CmdexW<CtrlaSpec> {
278 CmdexW::new(self, 8)
279 }
280}
281#[doc = "Control A\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrla::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrla::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
282pub struct CtrlaSpec;
283impl crate::RegisterSpec for CtrlaSpec {
284 type Ux = u16;
285}
286#[doc = "`read()` method returns [`ctrla::R`](R) reader structure"]
287impl crate::Readable for CtrlaSpec {}
288#[doc = "`write(|w| ..)` method takes [`ctrla::W`](W) writer structure"]
289impl crate::Writable for CtrlaSpec {
290 type Safety = crate::Unsafe;
291 const ZERO_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
292 const ONE_TO_MODIFY_FIELDS_BITMAP: u16 = 0;
293}
294#[doc = "`reset()` method sets CTRLA to value 0"]
295impl crate::Resettable for CtrlaSpec {
296 const RESET_VALUE: u16 = 0;
297}