py32f0/py32f002a/flash/
cr.rs

1///Register `CR` reader
2pub struct R(crate::R<CR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16///Register `CR` writer
17pub struct W(crate::W<CR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CR_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<CR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37///Field `PG` reader - Programming
38pub type PG_R = crate::BitReader<PG_A>;
39/**Programming
40
41Value on reset: 0*/
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum PG_A {
44    ///1: Flash programming activated
45    Program = 1,
46}
47impl From<PG_A> for bool {
48    #[inline(always)]
49    fn from(variant: PG_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl PG_R {
54    ///Get enumerated values variant
55    #[inline(always)]
56    pub fn variant(&self) -> Option<PG_A> {
57        match self.bits {
58            true => Some(PG_A::Program),
59            _ => None,
60        }
61    }
62    ///Checks if the value of the field is `Program`
63    #[inline(always)]
64    pub fn is_program(&self) -> bool {
65        *self == PG_A::Program
66    }
67}
68///Field `PG` writer - Programming
69pub type PG_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, PG_A, O>;
70impl<'a, const O: u8> PG_W<'a, O> {
71    ///Flash programming activated
72    #[inline(always)]
73    pub fn program(self) -> &'a mut W {
74        self.variant(PG_A::Program)
75    }
76}
77///Field `PER` reader - Page erase
78pub type PER_R = crate::BitReader<PER_A>;
79/**Page erase
80
81Value on reset: 0*/
82#[derive(Clone, Copy, Debug, PartialEq, Eq)]
83pub enum PER_A {
84    ///1: Erase activated for selected page
85    PageErase = 1,
86}
87impl From<PER_A> for bool {
88    #[inline(always)]
89    fn from(variant: PER_A) -> Self {
90        variant as u8 != 0
91    }
92}
93impl PER_R {
94    ///Get enumerated values variant
95    #[inline(always)]
96    pub fn variant(&self) -> Option<PER_A> {
97        match self.bits {
98            true => Some(PER_A::PageErase),
99            _ => None,
100        }
101    }
102    ///Checks if the value of the field is `PageErase`
103    #[inline(always)]
104    pub fn is_page_erase(&self) -> bool {
105        *self == PER_A::PageErase
106    }
107}
108///Field `PER` writer - Page erase
109pub type PER_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, PER_A, O>;
110impl<'a, const O: u8> PER_W<'a, O> {
111    ///Erase activated for selected page
112    #[inline(always)]
113    pub fn page_erase(self) -> &'a mut W {
114        self.variant(PER_A::PageErase)
115    }
116}
117///Field `MER` reader - Mass erase
118pub type MER_R = crate::BitReader<MER_A>;
119/**Mass erase
120
121Value on reset: 0*/
122#[derive(Clone, Copy, Debug, PartialEq, Eq)]
123pub enum MER_A {
124    ///1: Erase activated for all user sectors
125    MassErase = 1,
126}
127impl From<MER_A> for bool {
128    #[inline(always)]
129    fn from(variant: MER_A) -> Self {
130        variant as u8 != 0
131    }
132}
133impl MER_R {
134    ///Get enumerated values variant
135    #[inline(always)]
136    pub fn variant(&self) -> Option<MER_A> {
137        match self.bits {
138            true => Some(MER_A::MassErase),
139            _ => None,
140        }
141    }
142    ///Checks if the value of the field is `MassErase`
143    #[inline(always)]
144    pub fn is_mass_erase(&self) -> bool {
145        *self == MER_A::MassErase
146    }
147}
148///Field `MER` writer - Mass erase
149pub type MER_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, MER_A, O>;
150impl<'a, const O: u8> MER_W<'a, O> {
151    ///Erase activated for all user sectors
152    #[inline(always)]
153    pub fn mass_erase(self) -> &'a mut W {
154        self.variant(MER_A::MassErase)
155    }
156}
157///Field `SER` reader - Sector erase
158pub type SER_R = crate::BitReader<SER_A>;
159/**Sector erase
160
161Value on reset: 0*/
162#[derive(Clone, Copy, Debug, PartialEq, Eq)]
163pub enum SER_A {
164    ///1: Erase activated for user sectors
165    SectorErase = 1,
166}
167impl From<SER_A> for bool {
168    #[inline(always)]
169    fn from(variant: SER_A) -> Self {
170        variant as u8 != 0
171    }
172}
173impl SER_R {
174    ///Get enumerated values variant
175    #[inline(always)]
176    pub fn variant(&self) -> Option<SER_A> {
177        match self.bits {
178            true => Some(SER_A::SectorErase),
179            _ => None,
180        }
181    }
182    ///Checks if the value of the field is `SectorErase`
183    #[inline(always)]
184    pub fn is_sector_erase(&self) -> bool {
185        *self == SER_A::SectorErase
186    }
187}
188///Field `SER` writer - Sector erase
189pub type SER_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, SER_A, O>;
190impl<'a, const O: u8> SER_W<'a, O> {
191    ///Erase activated for user sectors
192    #[inline(always)]
193    pub fn sector_erase(self) -> &'a mut W {
194        self.variant(SER_A::SectorErase)
195    }
196}
197///Field `OPTSTRT` reader - Option byte program start
198pub type OPTSTRT_R = crate::BitReader<OPTSTRT_A>;
199/**Option byte program start
200
201Value on reset: 0*/
202#[derive(Clone, Copy, Debug, PartialEq, Eq)]
203pub enum OPTSTRT_A {
204    ///1: Option byte program start
205    OptionByteProgram = 1,
206}
207impl From<OPTSTRT_A> for bool {
208    #[inline(always)]
209    fn from(variant: OPTSTRT_A) -> Self {
210        variant as u8 != 0
211    }
212}
213impl OPTSTRT_R {
214    ///Get enumerated values variant
215    #[inline(always)]
216    pub fn variant(&self) -> Option<OPTSTRT_A> {
217        match self.bits {
218            true => Some(OPTSTRT_A::OptionByteProgram),
219            _ => None,
220        }
221    }
222    ///Checks if the value of the field is `OptionByteProgram`
223    #[inline(always)]
224    pub fn is_option_byte_program(&self) -> bool {
225        *self == OPTSTRT_A::OptionByteProgram
226    }
227}
228///Field `OPTSTRT` writer - Option byte program start
229pub type OPTSTRT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, OPTSTRT_A, O>;
230impl<'a, const O: u8> OPTSTRT_W<'a, O> {
231    ///Option byte program start
232    #[inline(always)]
233    pub fn option_byte_program(self) -> &'a mut W {
234        self.variant(OPTSTRT_A::OptionByteProgram)
235    }
236}
237///Field `PGSTRT` reader - Flash main memory program start
238pub type PGSTRT_R = crate::BitReader<bool>;
239///Field `PGSTRT` writer - Flash main memory program start
240pub type PGSTRT_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, bool, O>;
241///Field `EOPIE` reader - End of operation interrupt enable
242pub type EOPIE_R = crate::BitReader<EOPIE_A>;
243/**End of operation interrupt enable
244
245Value on reset: 0*/
246#[derive(Clone, Copy, Debug, PartialEq, Eq)]
247pub enum EOPIE_A {
248    ///0: End of operation interrupt disabled
249    Disabled = 0,
250    ///1: End of operation interrupt enabled
251    Enabled = 1,
252}
253impl From<EOPIE_A> for bool {
254    #[inline(always)]
255    fn from(variant: EOPIE_A) -> Self {
256        variant as u8 != 0
257    }
258}
259impl EOPIE_R {
260    ///Get enumerated values variant
261    #[inline(always)]
262    pub fn variant(&self) -> EOPIE_A {
263        match self.bits {
264            false => EOPIE_A::Disabled,
265            true => EOPIE_A::Enabled,
266        }
267    }
268    ///Checks if the value of the field is `Disabled`
269    #[inline(always)]
270    pub fn is_disabled(&self) -> bool {
271        *self == EOPIE_A::Disabled
272    }
273    ///Checks if the value of the field is `Enabled`
274    #[inline(always)]
275    pub fn is_enabled(&self) -> bool {
276        *self == EOPIE_A::Enabled
277    }
278}
279///Field `EOPIE` writer - End of operation interrupt enable
280pub type EOPIE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, EOPIE_A, O>;
281impl<'a, const O: u8> EOPIE_W<'a, O> {
282    ///End of operation interrupt disabled
283    #[inline(always)]
284    pub fn disabled(self) -> &'a mut W {
285        self.variant(EOPIE_A::Disabled)
286    }
287    ///End of operation interrupt enabled
288    #[inline(always)]
289    pub fn enabled(self) -> &'a mut W {
290        self.variant(EOPIE_A::Enabled)
291    }
292}
293///Field `ERRIE` reader - Error interrupt enable
294pub type ERRIE_R = crate::BitReader<ERRIE_A>;
295/**Error interrupt enable
296
297Value on reset: 0*/
298#[derive(Clone, Copy, Debug, PartialEq, Eq)]
299pub enum ERRIE_A {
300    ///0: Error interrupt generation disabled
301    Disabled = 0,
302    ///1: Error interrupt generation enabled
303    Enabled = 1,
304}
305impl From<ERRIE_A> for bool {
306    #[inline(always)]
307    fn from(variant: ERRIE_A) -> Self {
308        variant as u8 != 0
309    }
310}
311impl ERRIE_R {
312    ///Get enumerated values variant
313    #[inline(always)]
314    pub fn variant(&self) -> ERRIE_A {
315        match self.bits {
316            false => ERRIE_A::Disabled,
317            true => ERRIE_A::Enabled,
318        }
319    }
320    ///Checks if the value of the field is `Disabled`
321    #[inline(always)]
322    pub fn is_disabled(&self) -> bool {
323        *self == ERRIE_A::Disabled
324    }
325    ///Checks if the value of the field is `Enabled`
326    #[inline(always)]
327    pub fn is_enabled(&self) -> bool {
328        *self == ERRIE_A::Enabled
329    }
330}
331///Field `ERRIE` writer - Error interrupt enable
332pub type ERRIE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, ERRIE_A, O>;
333impl<'a, const O: u8> ERRIE_W<'a, O> {
334    ///Error interrupt generation disabled
335    #[inline(always)]
336    pub fn disabled(self) -> &'a mut W {
337        self.variant(ERRIE_A::Disabled)
338    }
339    ///Error interrupt generation enabled
340    #[inline(always)]
341    pub fn enabled(self) -> &'a mut W {
342        self.variant(ERRIE_A::Enabled)
343    }
344}
345///Field `OBL_LAUNCH` reader - Force the option byte loading
346pub type OBL_LAUNCH_R = crate::BitReader<OBL_LAUNCH_A>;
347/**Force the option byte loading
348
349Value on reset: 0*/
350#[derive(Clone, Copy, Debug, PartialEq, Eq)]
351pub enum OBL_LAUNCH_A {
352    ///0: Force option byte loading inactive
353    Inactive = 0,
354    ///1: Force option byte loading active
355    Active = 1,
356}
357impl From<OBL_LAUNCH_A> for bool {
358    #[inline(always)]
359    fn from(variant: OBL_LAUNCH_A) -> Self {
360        variant as u8 != 0
361    }
362}
363impl OBL_LAUNCH_R {
364    ///Get enumerated values variant
365    #[inline(always)]
366    pub fn variant(&self) -> OBL_LAUNCH_A {
367        match self.bits {
368            false => OBL_LAUNCH_A::Inactive,
369            true => OBL_LAUNCH_A::Active,
370        }
371    }
372    ///Checks if the value of the field is `Inactive`
373    #[inline(always)]
374    pub fn is_inactive(&self) -> bool {
375        *self == OBL_LAUNCH_A::Inactive
376    }
377    ///Checks if the value of the field is `Active`
378    #[inline(always)]
379    pub fn is_active(&self) -> bool {
380        *self == OBL_LAUNCH_A::Active
381    }
382}
383///Field `OBL_LAUNCH` writer - Force the option byte loading
384pub type OBL_LAUNCH_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, OBL_LAUNCH_A, O>;
385impl<'a, const O: u8> OBL_LAUNCH_W<'a, O> {
386    ///Force option byte loading inactive
387    #[inline(always)]
388    pub fn inactive(self) -> &'a mut W {
389        self.variant(OBL_LAUNCH_A::Inactive)
390    }
391    ///Force option byte loading active
392    #[inline(always)]
393    pub fn active(self) -> &'a mut W {
394        self.variant(OBL_LAUNCH_A::Active)
395    }
396}
397///Field `OPTLOCK` reader - Options Lock
398pub type OPTLOCK_R = crate::BitReader<OPTLOCK_A>;
399/**Options Lock
400
401Value on reset: 1*/
402#[derive(Clone, Copy, Debug, PartialEq, Eq)]
403pub enum OPTLOCK_A {
404    ///0: Options is unlocked
405    Unlocked = 0,
406    ///1: Options is locked
407    Locked = 1,
408}
409impl From<OPTLOCK_A> for bool {
410    #[inline(always)]
411    fn from(variant: OPTLOCK_A) -> Self {
412        variant as u8 != 0
413    }
414}
415impl OPTLOCK_R {
416    ///Get enumerated values variant
417    #[inline(always)]
418    pub fn variant(&self) -> OPTLOCK_A {
419        match self.bits {
420            false => OPTLOCK_A::Unlocked,
421            true => OPTLOCK_A::Locked,
422        }
423    }
424    ///Checks if the value of the field is `Unlocked`
425    #[inline(always)]
426    pub fn is_unlocked(&self) -> bool {
427        *self == OPTLOCK_A::Unlocked
428    }
429    ///Checks if the value of the field is `Locked`
430    #[inline(always)]
431    pub fn is_locked(&self) -> bool {
432        *self == OPTLOCK_A::Locked
433    }
434}
435///Field `OPTLOCK` writer - Options Lock
436pub type OPTLOCK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, OPTLOCK_A, O>;
437impl<'a, const O: u8> OPTLOCK_W<'a, O> {
438    ///Options is unlocked
439    #[inline(always)]
440    pub fn unlocked(self) -> &'a mut W {
441        self.variant(OPTLOCK_A::Unlocked)
442    }
443    ///Options is locked
444    #[inline(always)]
445    pub fn locked(self) -> &'a mut W {
446        self.variant(OPTLOCK_A::Locked)
447    }
448}
449///Field `LOCK` reader - FLASH_CR Lock
450pub type LOCK_R = crate::BitReader<LOCK_A>;
451/**FLASH_CR Lock
452
453Value on reset: 1*/
454#[derive(Clone, Copy, Debug, PartialEq, Eq)]
455pub enum LOCK_A {
456    ///0: FLASH_CR register is unlocked
457    Unlocked = 0,
458    ///1: FLASH_CR register is locked
459    Locked = 1,
460}
461impl From<LOCK_A> for bool {
462    #[inline(always)]
463    fn from(variant: LOCK_A) -> Self {
464        variant as u8 != 0
465    }
466}
467impl LOCK_R {
468    ///Get enumerated values variant
469    #[inline(always)]
470    pub fn variant(&self) -> LOCK_A {
471        match self.bits {
472            false => LOCK_A::Unlocked,
473            true => LOCK_A::Locked,
474        }
475    }
476    ///Checks if the value of the field is `Unlocked`
477    #[inline(always)]
478    pub fn is_unlocked(&self) -> bool {
479        *self == LOCK_A::Unlocked
480    }
481    ///Checks if the value of the field is `Locked`
482    #[inline(always)]
483    pub fn is_locked(&self) -> bool {
484        *self == LOCK_A::Locked
485    }
486}
487///Field `LOCK` writer - FLASH_CR Lock
488pub type LOCK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, LOCK_A, O>;
489impl<'a, const O: u8> LOCK_W<'a, O> {
490    ///FLASH_CR register is unlocked
491    #[inline(always)]
492    pub fn unlocked(self) -> &'a mut W {
493        self.variant(LOCK_A::Unlocked)
494    }
495    ///FLASH_CR register is locked
496    #[inline(always)]
497    pub fn locked(self) -> &'a mut W {
498        self.variant(LOCK_A::Locked)
499    }
500}
501impl R {
502    ///Bit 0 - Programming
503    #[inline(always)]
504    pub fn pg(&self) -> PG_R {
505        PG_R::new((self.bits & 1) != 0)
506    }
507    ///Bit 1 - Page erase
508    #[inline(always)]
509    pub fn per(&self) -> PER_R {
510        PER_R::new(((self.bits >> 1) & 1) != 0)
511    }
512    ///Bit 2 - Mass erase
513    #[inline(always)]
514    pub fn mer(&self) -> MER_R {
515        MER_R::new(((self.bits >> 2) & 1) != 0)
516    }
517    ///Bit 11 - Sector erase
518    #[inline(always)]
519    pub fn ser(&self) -> SER_R {
520        SER_R::new(((self.bits >> 11) & 1) != 0)
521    }
522    ///Bit 17 - Option byte program start
523    #[inline(always)]
524    pub fn optstrt(&self) -> OPTSTRT_R {
525        OPTSTRT_R::new(((self.bits >> 17) & 1) != 0)
526    }
527    ///Bit 19 - Flash main memory program start
528    #[inline(always)]
529    pub fn pgstrt(&self) -> PGSTRT_R {
530        PGSTRT_R::new(((self.bits >> 19) & 1) != 0)
531    }
532    ///Bit 24 - End of operation interrupt enable
533    #[inline(always)]
534    pub fn eopie(&self) -> EOPIE_R {
535        EOPIE_R::new(((self.bits >> 24) & 1) != 0)
536    }
537    ///Bit 25 - Error interrupt enable
538    #[inline(always)]
539    pub fn errie(&self) -> ERRIE_R {
540        ERRIE_R::new(((self.bits >> 25) & 1) != 0)
541    }
542    ///Bit 27 - Force the option byte loading
543    #[inline(always)]
544    pub fn obl_launch(&self) -> OBL_LAUNCH_R {
545        OBL_LAUNCH_R::new(((self.bits >> 27) & 1) != 0)
546    }
547    ///Bit 30 - Options Lock
548    #[inline(always)]
549    pub fn optlock(&self) -> OPTLOCK_R {
550        OPTLOCK_R::new(((self.bits >> 30) & 1) != 0)
551    }
552    ///Bit 31 - FLASH_CR Lock
553    #[inline(always)]
554    pub fn lock(&self) -> LOCK_R {
555        LOCK_R::new(((self.bits >> 31) & 1) != 0)
556    }
557}
558impl W {
559    ///Bit 0 - Programming
560    #[inline(always)]
561    #[must_use]
562    pub fn pg(&mut self) -> PG_W<0> {
563        PG_W::new(self)
564    }
565    ///Bit 1 - Page erase
566    #[inline(always)]
567    #[must_use]
568    pub fn per(&mut self) -> PER_W<1> {
569        PER_W::new(self)
570    }
571    ///Bit 2 - Mass erase
572    #[inline(always)]
573    #[must_use]
574    pub fn mer(&mut self) -> MER_W<2> {
575        MER_W::new(self)
576    }
577    ///Bit 11 - Sector erase
578    #[inline(always)]
579    #[must_use]
580    pub fn ser(&mut self) -> SER_W<11> {
581        SER_W::new(self)
582    }
583    ///Bit 17 - Option byte program start
584    #[inline(always)]
585    #[must_use]
586    pub fn optstrt(&mut self) -> OPTSTRT_W<17> {
587        OPTSTRT_W::new(self)
588    }
589    ///Bit 19 - Flash main memory program start
590    #[inline(always)]
591    #[must_use]
592    pub fn pgstrt(&mut self) -> PGSTRT_W<19> {
593        PGSTRT_W::new(self)
594    }
595    ///Bit 24 - End of operation interrupt enable
596    #[inline(always)]
597    #[must_use]
598    pub fn eopie(&mut self) -> EOPIE_W<24> {
599        EOPIE_W::new(self)
600    }
601    ///Bit 25 - Error interrupt enable
602    #[inline(always)]
603    #[must_use]
604    pub fn errie(&mut self) -> ERRIE_W<25> {
605        ERRIE_W::new(self)
606    }
607    ///Bit 27 - Force the option byte loading
608    #[inline(always)]
609    #[must_use]
610    pub fn obl_launch(&mut self) -> OBL_LAUNCH_W<27> {
611        OBL_LAUNCH_W::new(self)
612    }
613    ///Bit 30 - Options Lock
614    #[inline(always)]
615    #[must_use]
616    pub fn optlock(&mut self) -> OPTLOCK_W<30> {
617        OPTLOCK_W::new(self)
618    }
619    ///Bit 31 - FLASH_CR Lock
620    #[inline(always)]
621    #[must_use]
622    pub fn lock(&mut self) -> LOCK_W<31> {
623        LOCK_W::new(self)
624    }
625    ///Writes raw bits to the register.
626    #[inline(always)]
627    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
628        self.0.bits(bits);
629        self
630    }
631}
632/**Flash control register
633
634This 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).
635
636For information about available fields see [cr](index.html) module*/
637pub struct CR_SPEC;
638impl crate::RegisterSpec for CR_SPEC {
639    type Ux = u32;
640}
641///`read()` method returns [cr::R](R) reader structure
642impl crate::Readable for CR_SPEC {
643    type Reader = R;
644}
645///`write(|w| ..)` method takes [cr::W](W) writer structure
646impl crate::Writable for CR_SPEC {
647    type Writer = W;
648    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
649    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
650}
651///`reset()` method sets CR to value 0xc000_0000
652impl crate::Resettable for CR_SPEC {
653    const RESET_VALUE: Self::Ux = 0xc000_0000;
654}