atsam4lc2c_pac/hflashc/
fcmd.rs

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