1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#[doc = "Register `FCMD` reader"]
pub struct R(crate::R<FCMD_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<FCMD_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl From<crate::R<FCMD_SPEC>> for R {
    #[inline(always)]
    fn from(reader: crate::R<FCMD_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `FCMD` writer"]
pub struct W(crate::W<FCMD_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<FCMD_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl From<crate::W<FCMD_SPEC>> for W {
    #[inline(always)]
    fn from(writer: crate::W<FCMD_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `CMD` reader - Command"]
pub type CMD_R = crate::FieldReader<u8, CMDSELECT_A>;
#[doc = "Command\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum CMDSELECT_A {
    #[doc = "0: No Operation"]
    NOP = 0,
    #[doc = "1: Write Page"]
    WP = 1,
    #[doc = "2: Erase Page"]
    EP = 2,
    #[doc = "3: Clear Page Buffer"]
    CPB = 3,
    #[doc = "4: Lock Region containing page"]
    LP = 4,
    #[doc = "5: Unlock Region containing page"]
    UP = 5,
    #[doc = "6: Erase All, including secuity and fuse bits"]
    EA = 6,
    #[doc = "7: Write General-Purpose fuse Bit"]
    WGPB = 7,
    #[doc = "8: Erase General-Purpose fuse Bit"]
    EGPB = 8,
    #[doc = "9: Set Security Bit"]
    SSB = 9,
    #[doc = "10: Program GPFuse Byte"]
    PGPFB = 10,
    #[doc = "11: Erase All GP Fuses"]
    EAGPF = 11,
    #[doc = "12: Quick Page Read"]
    QPR = 12,
    #[doc = "13: Write User Page"]
    WUP = 13,
    #[doc = "14: Erase User Page"]
    EUP = 14,
    #[doc = "15: Quick Page Read User Page"]
    QPRUP = 15,
    #[doc = "16: High Speed Mode Enable"]
    HSEN = 16,
    #[doc = "17: High Speed Mode Disable"]
    HSDIS = 17,
}
impl From<CMDSELECT_A> for u8 {
    #[inline(always)]
    fn from(variant: CMDSELECT_A) -> Self {
        variant as _
    }
}
impl CMD_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> Option<CMDSELECT_A> {
        match self.bits {
            0 => Some(CMDSELECT_A::NOP),
            1 => Some(CMDSELECT_A::WP),
            2 => Some(CMDSELECT_A::EP),
            3 => Some(CMDSELECT_A::CPB),
            4 => Some(CMDSELECT_A::LP),
            5 => Some(CMDSELECT_A::UP),
            6 => Some(CMDSELECT_A::EA),
            7 => Some(CMDSELECT_A::WGPB),
            8 => Some(CMDSELECT_A::EGPB),
            9 => Some(CMDSELECT_A::SSB),
            10 => Some(CMDSELECT_A::PGPFB),
            11 => Some(CMDSELECT_A::EAGPF),
            12 => Some(CMDSELECT_A::QPR),
            13 => Some(CMDSELECT_A::WUP),
            14 => Some(CMDSELECT_A::EUP),
            15 => Some(CMDSELECT_A::QPRUP),
            16 => Some(CMDSELECT_A::HSEN),
            17 => Some(CMDSELECT_A::HSDIS),
            _ => None,
        }
    }
    #[doc = "Checks if the value of the field is `NOP`"]
    #[inline(always)]
    pub fn is_nop(&self) -> bool {
        *self == CMDSELECT_A::NOP
    }
    #[doc = "Checks if the value of the field is `WP`"]
    #[inline(always)]
    pub fn is_wp(&self) -> bool {
        *self == CMDSELECT_A::WP
    }
    #[doc = "Checks if the value of the field is `EP`"]
    #[inline(always)]
    pub fn is_ep(&self) -> bool {
        *self == CMDSELECT_A::EP
    }
    #[doc = "Checks if the value of the field is `CPB`"]
    #[inline(always)]
    pub fn is_cpb(&self) -> bool {
        *self == CMDSELECT_A::CPB
    }
    #[doc = "Checks if the value of the field is `LP`"]
    #[inline(always)]
    pub fn is_lp(&self) -> bool {
        *self == CMDSELECT_A::LP
    }
    #[doc = "Checks if the value of the field is `UP`"]
    #[inline(always)]
    pub fn is_up(&self) -> bool {
        *self == CMDSELECT_A::UP
    }
    #[doc = "Checks if the value of the field is `EA`"]
    #[inline(always)]
    pub fn is_ea(&self) -> bool {
        *self == CMDSELECT_A::EA
    }
    #[doc = "Checks if the value of the field is `WGPB`"]
    #[inline(always)]
    pub fn is_wgpb(&self) -> bool {
        *self == CMDSELECT_A::WGPB
    }
    #[doc = "Checks if the value of the field is `EGPB`"]
    #[inline(always)]
    pub fn is_egpb(&self) -> bool {
        *self == CMDSELECT_A::EGPB
    }
    #[doc = "Checks if the value of the field is `SSB`"]
    #[inline(always)]
    pub fn is_ssb(&self) -> bool {
        *self == CMDSELECT_A::SSB
    }
    #[doc = "Checks if the value of the field is `PGPFB`"]
    #[inline(always)]
    pub fn is_pgpfb(&self) -> bool {
        *self == CMDSELECT_A::PGPFB
    }
    #[doc = "Checks if the value of the field is `EAGPF`"]
    #[inline(always)]
    pub fn is_eagpf(&self) -> bool {
        *self == CMDSELECT_A::EAGPF
    }
    #[doc = "Checks if the value of the field is `QPR`"]
    #[inline(always)]
    pub fn is_qpr(&self) -> bool {
        *self == CMDSELECT_A::QPR
    }
    #[doc = "Checks if the value of the field is `WUP`"]
    #[inline(always)]
    pub fn is_wup(&self) -> bool {
        *self == CMDSELECT_A::WUP
    }
    #[doc = "Checks if the value of the field is `EUP`"]
    #[inline(always)]
    pub fn is_eup(&self) -> bool {
        *self == CMDSELECT_A::EUP
    }
    #[doc = "Checks if the value of the field is `QPRUP`"]
    #[inline(always)]
    pub fn is_qprup(&self) -> bool {
        *self == CMDSELECT_A::QPRUP
    }
    #[doc = "Checks if the value of the field is `HSEN`"]
    #[inline(always)]
    pub fn is_hsen(&self) -> bool {
        *self == CMDSELECT_A::HSEN
    }
    #[doc = "Checks if the value of the field is `HSDIS`"]
    #[inline(always)]
    pub fn is_hsdis(&self) -> bool {
        *self == CMDSELECT_A::HSDIS
    }
}
#[doc = "Field `CMD` writer - Command"]
pub type CMD_W<'a, const O: u8> = crate::FieldWriter<'a, u32, FCMD_SPEC, u8, CMDSELECT_A, 6, O>;
impl<'a, const O: u8> CMD_W<'a, O> {
    #[doc = "No Operation"]
    #[inline(always)]
    pub fn nop(self) -> &'a mut W {
        self.variant(CMDSELECT_A::NOP)
    }
    #[doc = "Write Page"]
    #[inline(always)]
    pub fn wp(self) -> &'a mut W {
        self.variant(CMDSELECT_A::WP)
    }
    #[doc = "Erase Page"]
    #[inline(always)]
    pub fn ep(self) -> &'a mut W {
        self.variant(CMDSELECT_A::EP)
    }
    #[doc = "Clear Page Buffer"]
    #[inline(always)]
    pub fn cpb(self) -> &'a mut W {
        self.variant(CMDSELECT_A::CPB)
    }
    #[doc = "Lock Region containing page"]
    #[inline(always)]
    pub fn lp(self) -> &'a mut W {
        self.variant(CMDSELECT_A::LP)
    }
    #[doc = "Unlock Region containing page"]
    #[inline(always)]
    pub fn up(self) -> &'a mut W {
        self.variant(CMDSELECT_A::UP)
    }
    #[doc = "Erase All, including secuity and fuse bits"]
    #[inline(always)]
    pub fn ea(self) -> &'a mut W {
        self.variant(CMDSELECT_A::EA)
    }
    #[doc = "Write General-Purpose fuse Bit"]
    #[inline(always)]
    pub fn wgpb(self) -> &'a mut W {
        self.variant(CMDSELECT_A::WGPB)
    }
    #[doc = "Erase General-Purpose fuse Bit"]
    #[inline(always)]
    pub fn egpb(self) -> &'a mut W {
        self.variant(CMDSELECT_A::EGPB)
    }
    #[doc = "Set Security Bit"]
    #[inline(always)]
    pub fn ssb(self) -> &'a mut W {
        self.variant(CMDSELECT_A::SSB)
    }
    #[doc = "Program GPFuse Byte"]
    #[inline(always)]
    pub fn pgpfb(self) -> &'a mut W {
        self.variant(CMDSELECT_A::PGPFB)
    }
    #[doc = "Erase All GP Fuses"]
    #[inline(always)]
    pub fn eagpf(self) -> &'a mut W {
        self.variant(CMDSELECT_A::EAGPF)
    }
    #[doc = "Quick Page Read"]
    #[inline(always)]
    pub fn qpr(self) -> &'a mut W {
        self.variant(CMDSELECT_A::QPR)
    }
    #[doc = "Write User Page"]
    #[inline(always)]
    pub fn wup(self) -> &'a mut W {
        self.variant(CMDSELECT_A::WUP)
    }
    #[doc = "Erase User Page"]
    #[inline(always)]
    pub fn eup(self) -> &'a mut W {
        self.variant(CMDSELECT_A::EUP)
    }
    #[doc = "Quick Page Read User Page"]
    #[inline(always)]
    pub fn qprup(self) -> &'a mut W {
        self.variant(CMDSELECT_A::QPRUP)
    }
    #[doc = "High Speed Mode Enable"]
    #[inline(always)]
    pub fn hsen(self) -> &'a mut W {
        self.variant(CMDSELECT_A::HSEN)
    }
    #[doc = "High Speed Mode Disable"]
    #[inline(always)]
    pub fn hsdis(self) -> &'a mut W {
        self.variant(CMDSELECT_A::HSDIS)
    }
}
#[doc = "Field `PAGEN` reader - Page number"]
pub type PAGEN_R = crate::FieldReader<u16, u16>;
#[doc = "Field `PAGEN` writer - Page number"]
pub type PAGEN_W<'a, const O: u8> = crate::FieldWriter<'a, u32, FCMD_SPEC, u16, u16, 16, O>;
#[doc = "Field `KEY` reader - Write protection key"]
pub type KEY_R = crate::FieldReader<u8, KEYSELECT_A>;
#[doc = "Write protection key\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum KEYSELECT_A {
    #[doc = "165: `10100101`"]
    KEY = 165,
}
impl From<KEYSELECT_A> for u8 {
    #[inline(always)]
    fn from(variant: KEYSELECT_A) -> Self {
        variant as _
    }
}
impl KEY_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> Option<KEYSELECT_A> {
        match self.bits {
            165 => Some(KEYSELECT_A::KEY),
            _ => None,
        }
    }
    #[doc = "Checks if the value of the field is `KEY`"]
    #[inline(always)]
    pub fn is_key(&self) -> bool {
        *self == KEYSELECT_A::KEY
    }
}
#[doc = "Field `KEY` writer - Write protection key"]
pub type KEY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, FCMD_SPEC, u8, KEYSELECT_A, 8, O>;
impl<'a, const O: u8> KEY_W<'a, O> {
    #[doc = "`10100101`"]
    #[inline(always)]
    pub fn key(self) -> &'a mut W {
        self.variant(KEYSELECT_A::KEY)
    }
}
impl R {
    #[doc = "Bits 0:5 - Command"]
    #[inline(always)]
    pub fn cmd(&self) -> CMD_R {
        CMD_R::new((self.bits & 0x3f) as u8)
    }
    #[doc = "Bits 8:23 - Page number"]
    #[inline(always)]
    pub fn pagen(&self) -> PAGEN_R {
        PAGEN_R::new(((self.bits >> 8) & 0xffff) as u16)
    }
    #[doc = "Bits 24:31 - Write protection key"]
    #[inline(always)]
    pub fn key(&self) -> KEY_R {
        KEY_R::new(((self.bits >> 24) & 0xff) as u8)
    }
}
impl W {
    #[doc = "Bits 0:5 - Command"]
    #[inline(always)]
    #[must_use]
    pub fn cmd(&mut self) -> CMD_W<0> {
        CMD_W::new(self)
    }
    #[doc = "Bits 8:23 - Page number"]
    #[inline(always)]
    #[must_use]
    pub fn pagen(&mut self) -> PAGEN_W<8> {
        PAGEN_W::new(self)
    }
    #[doc = "Bits 24:31 - Write protection key"]
    #[inline(always)]
    #[must_use]
    pub fn key(&mut self) -> KEY_W<24> {
        KEY_W::new(self)
    }
    #[doc = "Writes raw bits to the register."]
    #[inline(always)]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "Flash Controller Command 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 [fcmd](index.html) module"]
pub struct FCMD_SPEC;
impl crate::RegisterSpec for FCMD_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [fcmd::R](R) reader structure"]
impl crate::Readable for FCMD_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [fcmd::W](W) writer structure"]
impl crate::Writable for FCMD_SPEC {
    type Writer = W;
    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
}
#[doc = "`reset()` method sets FCMD to value 0"]
impl crate::Resettable for FCMD_SPEC {
    const RESET_VALUE: Self::Ux = 0;
}