1#[doc = "Register `CTRL` reader"]
2pub type R = crate::R<CtrlSpec>;
3#[doc = "Register `CTRL` writer"]
4pub type W = crate::W<CtrlSpec>;
5#[doc = "Write. This bit is automatically cleared after the operation.\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum Wr {
8 #[doc = "0: No operation/complete."]
9 Complete = 0,
10 #[doc = "1: Start operation."]
11 Start = 1,
12}
13impl From<Wr> for bool {
14 #[inline(always)]
15 fn from(variant: Wr) -> Self {
16 variant as u8 != 0
17 }
18}
19#[doc = "Field `WR` reader - Write. This bit is automatically cleared after the operation."]
20pub type WrR = crate::BitReader<Wr>;
21impl WrR {
22 #[doc = "Get enumerated values variant"]
23 #[inline(always)]
24 pub const fn variant(&self) -> Wr {
25 match self.bits {
26 false => Wr::Complete,
27 true => Wr::Start,
28 }
29 }
30 #[doc = "No operation/complete."]
31 #[inline(always)]
32 pub fn is_complete(&self) -> bool {
33 *self == Wr::Complete
34 }
35 #[doc = "Start operation."]
36 #[inline(always)]
37 pub fn is_start(&self) -> bool {
38 *self == Wr::Start
39 }
40}
41#[doc = "Field `WR` writer - Write. This bit is automatically cleared after the operation."]
42pub type WrW<'a, REG> = crate::BitWriter<'a, REG, Wr>;
43impl<'a, REG> WrW<'a, REG>
44where
45 REG: crate::Writable + crate::RegisterSpec,
46{
47 #[doc = "No operation/complete."]
48 #[inline(always)]
49 pub fn complete(self) -> &'a mut crate::W<REG> {
50 self.variant(Wr::Complete)
51 }
52 #[doc = "Start operation."]
53 #[inline(always)]
54 pub fn start(self) -> &'a mut crate::W<REG> {
55 self.variant(Wr::Start)
56 }
57}
58#[doc = "Mass Erase. This bit is automatically cleared after the operation."]
59pub use Wr as Me;
60#[doc = "Page Erase. This bit is automatically cleared after the operation."]
61pub use Wr as Pge;
62#[doc = "Field `ME` reader - Mass Erase. This bit is automatically cleared after the operation."]
63pub use WrR as MeR;
64#[doc = "Field `PGE` reader - Page Erase. This bit is automatically cleared after the operation."]
65pub use WrR as PgeR;
66#[doc = "Field `ME` writer - Mass Erase. This bit is automatically cleared after the operation."]
67pub use WrW as MeW;
68#[doc = "Field `PGE` writer - Page Erase. This bit is automatically cleared after the operation."]
69pub use WrW as PgeW;
70#[doc = "Erase Code. The ERASE_CODE must be set up property before erase operation can be initiated. These bits are automatically cleared after the operation is complete.\n\nValue on reset: 0"]
71#[derive(Clone, Copy, Debug, PartialEq, Eq)]
72#[repr(u8)]
73pub enum EraseCode {
74 #[doc = "0: No operation."]
75 Nop = 0,
76 #[doc = "85: Enable Page Erase."]
77 ErasePage = 85,
78 #[doc = "170: Enable Mass Erase. The debug port must be enabled."]
79 EraseAll = 170,
80}
81impl From<EraseCode> for u8 {
82 #[inline(always)]
83 fn from(variant: EraseCode) -> Self {
84 variant as _
85 }
86}
87impl crate::FieldSpec for EraseCode {
88 type Ux = u8;
89}
90impl crate::IsEnum for EraseCode {}
91#[doc = "Field `ERASE_CODE` reader - Erase Code. The ERASE_CODE must be set up property before erase operation can be initiated. These bits are automatically cleared after the operation is complete."]
92pub type EraseCodeR = crate::FieldReader<EraseCode>;
93impl EraseCodeR {
94 #[doc = "Get enumerated values variant"]
95 #[inline(always)]
96 pub const fn variant(&self) -> Option<EraseCode> {
97 match self.bits {
98 0 => Some(EraseCode::Nop),
99 85 => Some(EraseCode::ErasePage),
100 170 => Some(EraseCode::EraseAll),
101 _ => None,
102 }
103 }
104 #[doc = "No operation."]
105 #[inline(always)]
106 pub fn is_nop(&self) -> bool {
107 *self == EraseCode::Nop
108 }
109 #[doc = "Enable Page Erase."]
110 #[inline(always)]
111 pub fn is_erase_page(&self) -> bool {
112 *self == EraseCode::ErasePage
113 }
114 #[doc = "Enable Mass Erase. The debug port must be enabled."]
115 #[inline(always)]
116 pub fn is_erase_all(&self) -> bool {
117 *self == EraseCode::EraseAll
118 }
119}
120#[doc = "Field `ERASE_CODE` writer - Erase Code. The ERASE_CODE must be set up property before erase operation can be initiated. These bits are automatically cleared after the operation is complete."]
121pub type EraseCodeW<'a, REG> = crate::FieldWriter<'a, REG, 8, EraseCode>;
122impl<'a, REG> EraseCodeW<'a, REG>
123where
124 REG: crate::Writable + crate::RegisterSpec,
125 REG::Ux: From<u8>,
126{
127 #[doc = "No operation."]
128 #[inline(always)]
129 pub fn nop(self) -> &'a mut crate::W<REG> {
130 self.variant(EraseCode::Nop)
131 }
132 #[doc = "Enable Page Erase."]
133 #[inline(always)]
134 pub fn erase_page(self) -> &'a mut crate::W<REG> {
135 self.variant(EraseCode::ErasePage)
136 }
137 #[doc = "Enable Mass Erase. The debug port must be enabled."]
138 #[inline(always)]
139 pub fn erase_all(self) -> &'a mut crate::W<REG> {
140 self.variant(EraseCode::EraseAll)
141 }
142}
143#[doc = "Flash Pending. When Flash operation is in progress (busy), Flash reads and writes will fail. When PEND is set, write to all Flash registers, with exception of the Flash interrupt register, are ignored.\n\nValue on reset: 0"]
144#[derive(Clone, Copy, Debug, PartialEq, Eq)]
145pub enum Pend {
146 #[doc = "0: Idle."]
147 Idle = 0,
148 #[doc = "1: Busy."]
149 Busy = 1,
150}
151impl From<Pend> for bool {
152 #[inline(always)]
153 fn from(variant: Pend) -> Self {
154 variant as u8 != 0
155 }
156}
157#[doc = "Field `PEND` reader - Flash Pending. When Flash operation is in progress (busy), Flash reads and writes will fail. When PEND is set, write to all Flash registers, with exception of the Flash interrupt register, are ignored."]
158pub type PendR = crate::BitReader<Pend>;
159impl PendR {
160 #[doc = "Get enumerated values variant"]
161 #[inline(always)]
162 pub const fn variant(&self) -> Pend {
163 match self.bits {
164 false => Pend::Idle,
165 true => Pend::Busy,
166 }
167 }
168 #[doc = "Idle."]
169 #[inline(always)]
170 pub fn is_idle(&self) -> bool {
171 *self == Pend::Idle
172 }
173 #[doc = "Busy."]
174 #[inline(always)]
175 pub fn is_busy(&self) -> bool {
176 *self == Pend::Busy
177 }
178}
179#[doc = "Field `LVE` reader - Low Voltage enable."]
180pub type LveR = crate::BitReader;
181#[doc = "Field `LVE` writer - Low Voltage enable."]
182pub type LveW<'a, REG> = crate::BitWriter<'a, REG>;
183#[doc = "Flash Unlock. The correct unlock code must be written to these four bits before any Flash write or erase operation is allowed.\n\nValue on reset: 0"]
184#[derive(Clone, Copy, Debug, PartialEq, Eq)]
185#[repr(u8)]
186pub enum Unlock {
187 #[doc = "2: Flash Unlocked."]
188 Unlocked = 2,
189 #[doc = "3: Flash Locked."]
190 Locked = 3,
191}
192impl From<Unlock> for u8 {
193 #[inline(always)]
194 fn from(variant: Unlock) -> Self {
195 variant as _
196 }
197}
198impl crate::FieldSpec for Unlock {
199 type Ux = u8;
200}
201impl crate::IsEnum for Unlock {}
202#[doc = "Field `UNLOCK` reader - Flash Unlock. The correct unlock code must be written to these four bits before any Flash write or erase operation is allowed."]
203pub type UnlockR = crate::FieldReader<Unlock>;
204impl UnlockR {
205 #[doc = "Get enumerated values variant"]
206 #[inline(always)]
207 pub const fn variant(&self) -> Option<Unlock> {
208 match self.bits {
209 2 => Some(Unlock::Unlocked),
210 3 => Some(Unlock::Locked),
211 _ => None,
212 }
213 }
214 #[doc = "Flash Unlocked."]
215 #[inline(always)]
216 pub fn is_unlocked(&self) -> bool {
217 *self == Unlock::Unlocked
218 }
219 #[doc = "Flash Locked."]
220 #[inline(always)]
221 pub fn is_locked(&self) -> bool {
222 *self == Unlock::Locked
223 }
224}
225#[doc = "Field `UNLOCK` writer - Flash Unlock. The correct unlock code must be written to these four bits before any Flash write or erase operation is allowed."]
226pub type UnlockW<'a, REG> = crate::FieldWriter<'a, REG, 4, Unlock>;
227impl<'a, REG> UnlockW<'a, REG>
228where
229 REG: crate::Writable + crate::RegisterSpec,
230 REG::Ux: From<u8>,
231{
232 #[doc = "Flash Unlocked."]
233 #[inline(always)]
234 pub fn unlocked(self) -> &'a mut crate::W<REG> {
235 self.variant(Unlock::Unlocked)
236 }
237 #[doc = "Flash Locked."]
238 #[inline(always)]
239 pub fn locked(self) -> &'a mut crate::W<REG> {
240 self.variant(Unlock::Locked)
241 }
242}
243impl R {
244 #[doc = "Bit 0 - Write. This bit is automatically cleared after the operation."]
245 #[inline(always)]
246 pub fn wr(&self) -> WrR {
247 WrR::new((self.bits & 1) != 0)
248 }
249 #[doc = "Bit 1 - Mass Erase. This bit is automatically cleared after the operation."]
250 #[inline(always)]
251 pub fn me(&self) -> MeR {
252 MeR::new(((self.bits >> 1) & 1) != 0)
253 }
254 #[doc = "Bit 2 - Page Erase. This bit is automatically cleared after the operation."]
255 #[inline(always)]
256 pub fn pge(&self) -> PgeR {
257 PgeR::new(((self.bits >> 2) & 1) != 0)
258 }
259 #[doc = "Bits 8:15 - Erase Code. The ERASE_CODE must be set up property before erase operation can be initiated. These bits are automatically cleared after the operation is complete."]
260 #[inline(always)]
261 pub fn erase_code(&self) -> EraseCodeR {
262 EraseCodeR::new(((self.bits >> 8) & 0xff) as u8)
263 }
264 #[doc = "Bit 24 - Flash Pending. When Flash operation is in progress (busy), Flash reads and writes will fail. When PEND is set, write to all Flash registers, with exception of the Flash interrupt register, are ignored."]
265 #[inline(always)]
266 pub fn pend(&self) -> PendR {
267 PendR::new(((self.bits >> 24) & 1) != 0)
268 }
269 #[doc = "Bit 25 - Low Voltage enable."]
270 #[inline(always)]
271 pub fn lve(&self) -> LveR {
272 LveR::new(((self.bits >> 25) & 1) != 0)
273 }
274 #[doc = "Bits 28:31 - Flash Unlock. The correct unlock code must be written to these four bits before any Flash write or erase operation is allowed."]
275 #[inline(always)]
276 pub fn unlock(&self) -> UnlockR {
277 UnlockR::new(((self.bits >> 28) & 0x0f) as u8)
278 }
279}
280impl W {
281 #[doc = "Bit 0 - Write. This bit is automatically cleared after the operation."]
282 #[inline(always)]
283 pub fn wr(&mut self) -> WrW<CtrlSpec> {
284 WrW::new(self, 0)
285 }
286 #[doc = "Bit 1 - Mass Erase. This bit is automatically cleared after the operation."]
287 #[inline(always)]
288 pub fn me(&mut self) -> MeW<CtrlSpec> {
289 MeW::new(self, 1)
290 }
291 #[doc = "Bit 2 - Page Erase. This bit is automatically cleared after the operation."]
292 #[inline(always)]
293 pub fn pge(&mut self) -> PgeW<CtrlSpec> {
294 PgeW::new(self, 2)
295 }
296 #[doc = "Bits 8:15 - Erase Code. The ERASE_CODE must be set up property before erase operation can be initiated. These bits are automatically cleared after the operation is complete."]
297 #[inline(always)]
298 pub fn erase_code(&mut self) -> EraseCodeW<CtrlSpec> {
299 EraseCodeW::new(self, 8)
300 }
301 #[doc = "Bit 25 - Low Voltage enable."]
302 #[inline(always)]
303 pub fn lve(&mut self) -> LveW<CtrlSpec> {
304 LveW::new(self, 25)
305 }
306 #[doc = "Bits 28:31 - Flash Unlock. The correct unlock code must be written to these four bits before any Flash write or erase operation is allowed."]
307 #[inline(always)]
308 pub fn unlock(&mut self) -> UnlockW<CtrlSpec> {
309 UnlockW::new(self, 28)
310 }
311}
312#[doc = "Flash Control Register.\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
313pub struct CtrlSpec;
314impl crate::RegisterSpec for CtrlSpec {
315 type Ux = u32;
316}
317#[doc = "`read()` method returns [`ctrl::R`](R) reader structure"]
318impl crate::Readable for CtrlSpec {}
319#[doc = "`write(|w| ..)` method takes [`ctrl::W`](W) writer structure"]
320impl crate::Writable for CtrlSpec {
321 type Safety = crate::Unsafe;
322 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
323 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
324}
325#[doc = "`reset()` method sets CTRL to value 0"]
326impl crate::Resettable for CtrlSpec {
327 const RESET_VALUE: u32 = 0;
328}