stm32f4_staging/stm32f469/flash/
cr.rs

1///Register `CR` reader
2pub type R = crate::R<CRrs>;
3///Register `CR` writer
4pub type W = crate::W<CRrs>;
5/**Programming
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum PG {
11    ///1: Flash programming activated
12    Program = 1,
13}
14impl From<PG> for bool {
15    #[inline(always)]
16    fn from(variant: PG) -> Self {
17        variant as u8 != 0
18    }
19}
20///Field `PG` reader - Programming
21pub type PG_R = crate::BitReader<PG>;
22impl PG_R {
23    ///Get enumerated values variant
24    #[inline(always)]
25    pub const fn variant(&self) -> Option<PG> {
26        match self.bits {
27            true => Some(PG::Program),
28            _ => None,
29        }
30    }
31    ///Flash programming activated
32    #[inline(always)]
33    pub fn is_program(&self) -> bool {
34        *self == PG::Program
35    }
36}
37///Field `PG` writer - Programming
38pub type PG_W<'a, REG> = crate::BitWriter<'a, REG, PG>;
39impl<'a, REG> PG_W<'a, REG>
40where
41    REG: crate::Writable + crate::RegisterSpec,
42{
43    ///Flash programming activated
44    #[inline(always)]
45    pub fn program(self) -> &'a mut crate::W<REG> {
46        self.variant(PG::Program)
47    }
48}
49/**Sector Erase
50
51Value on reset: 0*/
52#[cfg_attr(feature = "defmt", derive(defmt::Format))]
53#[derive(Clone, Copy, Debug, PartialEq, Eq)]
54pub enum SER {
55    ///1: Erase activated for selected sector
56    SectorErase = 1,
57}
58impl From<SER> for bool {
59    #[inline(always)]
60    fn from(variant: SER) -> Self {
61        variant as u8 != 0
62    }
63}
64///Field `SER` reader - Sector Erase
65pub type SER_R = crate::BitReader<SER>;
66impl SER_R {
67    ///Get enumerated values variant
68    #[inline(always)]
69    pub const fn variant(&self) -> Option<SER> {
70        match self.bits {
71            true => Some(SER::SectorErase),
72            _ => None,
73        }
74    }
75    ///Erase activated for selected sector
76    #[inline(always)]
77    pub fn is_sector_erase(&self) -> bool {
78        *self == SER::SectorErase
79    }
80}
81///Field `SER` writer - Sector Erase
82pub type SER_W<'a, REG> = crate::BitWriter<'a, REG, SER>;
83impl<'a, REG> SER_W<'a, REG>
84where
85    REG: crate::Writable + crate::RegisterSpec,
86{
87    ///Erase activated for selected sector
88    #[inline(always)]
89    pub fn sector_erase(self) -> &'a mut crate::W<REG> {
90        self.variant(SER::SectorErase)
91    }
92}
93/**Mass Erase of sectors 0 to 11
94
95Value on reset: 0*/
96#[cfg_attr(feature = "defmt", derive(defmt::Format))]
97#[derive(Clone, Copy, Debug, PartialEq, Eq)]
98pub enum MER {
99    ///1: Erase activated for bank 1 sectors
100    MassErase = 1,
101}
102impl From<MER> for bool {
103    #[inline(always)]
104    fn from(variant: MER) -> Self {
105        variant as u8 != 0
106    }
107}
108///Field `MER` reader - Mass Erase of sectors 0 to 11
109pub type MER_R = crate::BitReader<MER>;
110impl MER_R {
111    ///Get enumerated values variant
112    #[inline(always)]
113    pub const fn variant(&self) -> Option<MER> {
114        match self.bits {
115            true => Some(MER::MassErase),
116            _ => None,
117        }
118    }
119    ///Erase activated for bank 1 sectors
120    #[inline(always)]
121    pub fn is_mass_erase(&self) -> bool {
122        *self == MER::MassErase
123    }
124}
125///Field `MER` writer - Mass Erase of sectors 0 to 11
126pub type MER_W<'a, REG> = crate::BitWriter<'a, REG, MER>;
127impl<'a, REG> MER_W<'a, REG>
128where
129    REG: crate::Writable + crate::RegisterSpec,
130{
131    ///Erase activated for bank 1 sectors
132    #[inline(always)]
133    pub fn mass_erase(self) -> &'a mut crate::W<REG> {
134        self.variant(MER::MassErase)
135    }
136}
137///Field `SNB` reader - Sector number
138pub type SNB_R = crate::FieldReader;
139///Field `SNB` writer - Sector number
140pub type SNB_W<'a, REG> = crate::FieldWriter<'a, REG, 5>;
141/**Program size
142
143Value on reset: 0*/
144#[cfg_attr(feature = "defmt", derive(defmt::Format))]
145#[derive(Clone, Copy, Debug, PartialEq, Eq)]
146#[repr(u8)]
147pub enum PSIZE {
148    ///0: Program x8
149    Psize8 = 0,
150    ///1: Program x16
151    Psize16 = 1,
152    ///2: Program x32
153    Psize32 = 2,
154    ///3: Program x64
155    Psize64 = 3,
156}
157impl From<PSIZE> for u8 {
158    #[inline(always)]
159    fn from(variant: PSIZE) -> Self {
160        variant as _
161    }
162}
163impl crate::FieldSpec for PSIZE {
164    type Ux = u8;
165}
166impl crate::IsEnum for PSIZE {}
167///Field `PSIZE` reader - Program size
168pub type PSIZE_R = crate::FieldReader<PSIZE>;
169impl PSIZE_R {
170    ///Get enumerated values variant
171    #[inline(always)]
172    pub const fn variant(&self) -> PSIZE {
173        match self.bits {
174            0 => PSIZE::Psize8,
175            1 => PSIZE::Psize16,
176            2 => PSIZE::Psize32,
177            3 => PSIZE::Psize64,
178            _ => unreachable!(),
179        }
180    }
181    ///Program x8
182    #[inline(always)]
183    pub fn is_psize8(&self) -> bool {
184        *self == PSIZE::Psize8
185    }
186    ///Program x16
187    #[inline(always)]
188    pub fn is_psize16(&self) -> bool {
189        *self == PSIZE::Psize16
190    }
191    ///Program x32
192    #[inline(always)]
193    pub fn is_psize32(&self) -> bool {
194        *self == PSIZE::Psize32
195    }
196    ///Program x64
197    #[inline(always)]
198    pub fn is_psize64(&self) -> bool {
199        *self == PSIZE::Psize64
200    }
201}
202///Field `PSIZE` writer - Program size
203pub type PSIZE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, PSIZE, crate::Safe>;
204impl<'a, REG> PSIZE_W<'a, REG>
205where
206    REG: crate::Writable + crate::RegisterSpec,
207    REG::Ux: From<u8>,
208{
209    ///Program x8
210    #[inline(always)]
211    pub fn psize8(self) -> &'a mut crate::W<REG> {
212        self.variant(PSIZE::Psize8)
213    }
214    ///Program x16
215    #[inline(always)]
216    pub fn psize16(self) -> &'a mut crate::W<REG> {
217        self.variant(PSIZE::Psize16)
218    }
219    ///Program x32
220    #[inline(always)]
221    pub fn psize32(self) -> &'a mut crate::W<REG> {
222        self.variant(PSIZE::Psize32)
223    }
224    ///Program x64
225    #[inline(always)]
226    pub fn psize64(self) -> &'a mut crate::W<REG> {
227        self.variant(PSIZE::Psize64)
228    }
229}
230/**Mass Erase of sectors 12 to 23
231
232Value on reset: 0*/
233#[cfg_attr(feature = "defmt", derive(defmt::Format))]
234#[derive(Clone, Copy, Debug, PartialEq, Eq)]
235pub enum MER1 {
236    ///1: Erase activated for bank 2 sectors
237    MassErase = 1,
238}
239impl From<MER1> for bool {
240    #[inline(always)]
241    fn from(variant: MER1) -> Self {
242        variant as u8 != 0
243    }
244}
245///Field `MER1` reader - Mass Erase of sectors 12 to 23
246pub type MER1_R = crate::BitReader<MER1>;
247impl MER1_R {
248    ///Get enumerated values variant
249    #[inline(always)]
250    pub const fn variant(&self) -> Option<MER1> {
251        match self.bits {
252            true => Some(MER1::MassErase),
253            _ => None,
254        }
255    }
256    ///Erase activated for bank 2 sectors
257    #[inline(always)]
258    pub fn is_mass_erase(&self) -> bool {
259        *self == MER1::MassErase
260    }
261}
262///Field `MER1` writer - Mass Erase of sectors 12 to 23
263pub type MER1_W<'a, REG> = crate::BitWriter<'a, REG, MER1>;
264impl<'a, REG> MER1_W<'a, REG>
265where
266    REG: crate::Writable + crate::RegisterSpec,
267{
268    ///Erase activated for bank 2 sectors
269    #[inline(always)]
270    pub fn mass_erase(self) -> &'a mut crate::W<REG> {
271        self.variant(MER1::MassErase)
272    }
273}
274/**Start
275
276Value on reset: 0*/
277#[cfg_attr(feature = "defmt", derive(defmt::Format))]
278#[derive(Clone, Copy, Debug, PartialEq, Eq)]
279pub enum STRT {
280    ///1: Trigger an erase operation
281    Start = 1,
282}
283impl From<STRT> for bool {
284    #[inline(always)]
285    fn from(variant: STRT) -> Self {
286        variant as u8 != 0
287    }
288}
289///Field `STRT` reader - Start
290pub type STRT_R = crate::BitReader<STRT>;
291impl STRT_R {
292    ///Get enumerated values variant
293    #[inline(always)]
294    pub const fn variant(&self) -> Option<STRT> {
295        match self.bits {
296            true => Some(STRT::Start),
297            _ => None,
298        }
299    }
300    ///Trigger an erase operation
301    #[inline(always)]
302    pub fn is_start(&self) -> bool {
303        *self == STRT::Start
304    }
305}
306///Field `STRT` writer - Start
307pub type STRT_W<'a, REG> = crate::BitWriter<'a, REG, STRT>;
308impl<'a, REG> STRT_W<'a, REG>
309where
310    REG: crate::Writable + crate::RegisterSpec,
311{
312    ///Trigger an erase operation
313    #[inline(always)]
314    pub fn start(self) -> &'a mut crate::W<REG> {
315        self.variant(STRT::Start)
316    }
317}
318/**End of operation interrupt enable
319
320Value on reset: 0*/
321#[cfg_attr(feature = "defmt", derive(defmt::Format))]
322#[derive(Clone, Copy, Debug, PartialEq, Eq)]
323pub enum EOPIE {
324    ///0: End of operation interrupt disabled
325    Disabled = 0,
326    ///1: End of operation interrupt enabled
327    Enabled = 1,
328}
329impl From<EOPIE> for bool {
330    #[inline(always)]
331    fn from(variant: EOPIE) -> Self {
332        variant as u8 != 0
333    }
334}
335///Field `EOPIE` reader - End of operation interrupt enable
336pub type EOPIE_R = crate::BitReader<EOPIE>;
337impl EOPIE_R {
338    ///Get enumerated values variant
339    #[inline(always)]
340    pub const fn variant(&self) -> EOPIE {
341        match self.bits {
342            false => EOPIE::Disabled,
343            true => EOPIE::Enabled,
344        }
345    }
346    ///End of operation interrupt disabled
347    #[inline(always)]
348    pub fn is_disabled(&self) -> bool {
349        *self == EOPIE::Disabled
350    }
351    ///End of operation interrupt enabled
352    #[inline(always)]
353    pub fn is_enabled(&self) -> bool {
354        *self == EOPIE::Enabled
355    }
356}
357///Field `EOPIE` writer - End of operation interrupt enable
358pub type EOPIE_W<'a, REG> = crate::BitWriter<'a, REG, EOPIE>;
359impl<'a, REG> EOPIE_W<'a, REG>
360where
361    REG: crate::Writable + crate::RegisterSpec,
362{
363    ///End of operation interrupt disabled
364    #[inline(always)]
365    pub fn disabled(self) -> &'a mut crate::W<REG> {
366        self.variant(EOPIE::Disabled)
367    }
368    ///End of operation interrupt enabled
369    #[inline(always)]
370    pub fn enabled(self) -> &'a mut crate::W<REG> {
371        self.variant(EOPIE::Enabled)
372    }
373}
374/**Error interrupt enable
375
376Value on reset: 0*/
377#[cfg_attr(feature = "defmt", derive(defmt::Format))]
378#[derive(Clone, Copy, Debug, PartialEq, Eq)]
379pub enum ERRIE {
380    ///0: Error interrupt generation disabled
381    Disabled = 0,
382    ///1: Error interrupt generation enabled
383    Enabled = 1,
384}
385impl From<ERRIE> for bool {
386    #[inline(always)]
387    fn from(variant: ERRIE) -> Self {
388        variant as u8 != 0
389    }
390}
391///Field `ERRIE` reader - Error interrupt enable
392pub type ERRIE_R = crate::BitReader<ERRIE>;
393impl ERRIE_R {
394    ///Get enumerated values variant
395    #[inline(always)]
396    pub const fn variant(&self) -> ERRIE {
397        match self.bits {
398            false => ERRIE::Disabled,
399            true => ERRIE::Enabled,
400        }
401    }
402    ///Error interrupt generation disabled
403    #[inline(always)]
404    pub fn is_disabled(&self) -> bool {
405        *self == ERRIE::Disabled
406    }
407    ///Error interrupt generation enabled
408    #[inline(always)]
409    pub fn is_enabled(&self) -> bool {
410        *self == ERRIE::Enabled
411    }
412}
413///Field `ERRIE` writer - Error interrupt enable
414pub type ERRIE_W<'a, REG> = crate::BitWriter<'a, REG, ERRIE>;
415impl<'a, REG> ERRIE_W<'a, REG>
416where
417    REG: crate::Writable + crate::RegisterSpec,
418{
419    ///Error interrupt generation disabled
420    #[inline(always)]
421    pub fn disabled(self) -> &'a mut crate::W<REG> {
422        self.variant(ERRIE::Disabled)
423    }
424    ///Error interrupt generation enabled
425    #[inline(always)]
426    pub fn enabled(self) -> &'a mut crate::W<REG> {
427        self.variant(ERRIE::Enabled)
428    }
429}
430/**Lock
431
432Value on reset: 1*/
433#[cfg_attr(feature = "defmt", derive(defmt::Format))]
434#[derive(Clone, Copy, Debug, PartialEq, Eq)]
435pub enum LOCK {
436    ///0: FLASH_CR register is unlocked
437    Unlocked = 0,
438    ///1: FLASH_CR register is locked
439    Locked = 1,
440}
441impl From<LOCK> for bool {
442    #[inline(always)]
443    fn from(variant: LOCK) -> Self {
444        variant as u8 != 0
445    }
446}
447///Field `LOCK` reader - Lock
448pub type LOCK_R = crate::BitReader<LOCK>;
449impl LOCK_R {
450    ///Get enumerated values variant
451    #[inline(always)]
452    pub const fn variant(&self) -> LOCK {
453        match self.bits {
454            false => LOCK::Unlocked,
455            true => LOCK::Locked,
456        }
457    }
458    ///FLASH_CR register is unlocked
459    #[inline(always)]
460    pub fn is_unlocked(&self) -> bool {
461        *self == LOCK::Unlocked
462    }
463    ///FLASH_CR register is locked
464    #[inline(always)]
465    pub fn is_locked(&self) -> bool {
466        *self == LOCK::Locked
467    }
468}
469///Field `LOCK` writer - Lock
470pub type LOCK_W<'a, REG> = crate::BitWriter<'a, REG, LOCK>;
471impl<'a, REG> LOCK_W<'a, REG>
472where
473    REG: crate::Writable + crate::RegisterSpec,
474{
475    ///FLASH_CR register is unlocked
476    #[inline(always)]
477    pub fn unlocked(self) -> &'a mut crate::W<REG> {
478        self.variant(LOCK::Unlocked)
479    }
480    ///FLASH_CR register is locked
481    #[inline(always)]
482    pub fn locked(self) -> &'a mut crate::W<REG> {
483        self.variant(LOCK::Locked)
484    }
485}
486impl R {
487    ///Bit 0 - Programming
488    #[inline(always)]
489    pub fn pg(&self) -> PG_R {
490        PG_R::new((self.bits & 1) != 0)
491    }
492    ///Bit 1 - Sector Erase
493    #[inline(always)]
494    pub fn ser(&self) -> SER_R {
495        SER_R::new(((self.bits >> 1) & 1) != 0)
496    }
497    ///Bit 2 - Mass Erase of sectors 0 to 11
498    #[inline(always)]
499    pub fn mer(&self) -> MER_R {
500        MER_R::new(((self.bits >> 2) & 1) != 0)
501    }
502    ///Bits 3:7 - Sector number
503    #[inline(always)]
504    pub fn snb(&self) -> SNB_R {
505        SNB_R::new(((self.bits >> 3) & 0x1f) as u8)
506    }
507    ///Bits 8:9 - Program size
508    #[inline(always)]
509    pub fn psize(&self) -> PSIZE_R {
510        PSIZE_R::new(((self.bits >> 8) & 3) as u8)
511    }
512    ///Bit 15 - Mass Erase of sectors 12 to 23
513    #[inline(always)]
514    pub fn mer1(&self) -> MER1_R {
515        MER1_R::new(((self.bits >> 15) & 1) != 0)
516    }
517    ///Bit 16 - Start
518    #[inline(always)]
519    pub fn strt(&self) -> STRT_R {
520        STRT_R::new(((self.bits >> 16) & 1) != 0)
521    }
522    ///Bit 24 - End of operation interrupt enable
523    #[inline(always)]
524    pub fn eopie(&self) -> EOPIE_R {
525        EOPIE_R::new(((self.bits >> 24) & 1) != 0)
526    }
527    ///Bit 25 - Error interrupt enable
528    #[inline(always)]
529    pub fn errie(&self) -> ERRIE_R {
530        ERRIE_R::new(((self.bits >> 25) & 1) != 0)
531    }
532    ///Bit 31 - Lock
533    #[inline(always)]
534    pub fn lock(&self) -> LOCK_R {
535        LOCK_R::new(((self.bits >> 31) & 1) != 0)
536    }
537}
538impl core::fmt::Debug for R {
539    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
540        f.debug_struct("CR")
541            .field("pg", &self.pg())
542            .field("ser", &self.ser())
543            .field("mer", &self.mer())
544            .field("snb", &self.snb())
545            .field("psize", &self.psize())
546            .field("mer1", &self.mer1())
547            .field("strt", &self.strt())
548            .field("eopie", &self.eopie())
549            .field("errie", &self.errie())
550            .field("lock", &self.lock())
551            .finish()
552    }
553}
554impl W {
555    ///Bit 0 - Programming
556    #[inline(always)]
557    pub fn pg(&mut self) -> PG_W<CRrs> {
558        PG_W::new(self, 0)
559    }
560    ///Bit 1 - Sector Erase
561    #[inline(always)]
562    pub fn ser(&mut self) -> SER_W<CRrs> {
563        SER_W::new(self, 1)
564    }
565    ///Bit 2 - Mass Erase of sectors 0 to 11
566    #[inline(always)]
567    pub fn mer(&mut self) -> MER_W<CRrs> {
568        MER_W::new(self, 2)
569    }
570    ///Bits 3:7 - Sector number
571    #[inline(always)]
572    pub fn snb(&mut self) -> SNB_W<CRrs> {
573        SNB_W::new(self, 3)
574    }
575    ///Bits 8:9 - Program size
576    #[inline(always)]
577    pub fn psize(&mut self) -> PSIZE_W<CRrs> {
578        PSIZE_W::new(self, 8)
579    }
580    ///Bit 15 - Mass Erase of sectors 12 to 23
581    #[inline(always)]
582    pub fn mer1(&mut self) -> MER1_W<CRrs> {
583        MER1_W::new(self, 15)
584    }
585    ///Bit 16 - Start
586    #[inline(always)]
587    pub fn strt(&mut self) -> STRT_W<CRrs> {
588        STRT_W::new(self, 16)
589    }
590    ///Bit 24 - End of operation interrupt enable
591    #[inline(always)]
592    pub fn eopie(&mut self) -> EOPIE_W<CRrs> {
593        EOPIE_W::new(self, 24)
594    }
595    ///Bit 25 - Error interrupt enable
596    #[inline(always)]
597    pub fn errie(&mut self) -> ERRIE_W<CRrs> {
598        ERRIE_W::new(self, 25)
599    }
600    ///Bit 31 - Lock
601    #[inline(always)]
602    pub fn lock(&mut self) -> LOCK_W<CRrs> {
603        LOCK_W::new(self, 31)
604    }
605}
606/**Control register
607
608You can [`read`](crate::Reg::read) this register and get [`cr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
609
610See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F469.html#FLASH:CR)*/
611pub struct CRrs;
612impl crate::RegisterSpec for CRrs {
613    type Ux = u32;
614}
615///`read()` method returns [`cr::R`](R) reader structure
616impl crate::Readable for CRrs {}
617///`write(|w| ..)` method takes [`cr::W`](W) writer structure
618impl crate::Writable for CRrs {
619    type Safety = crate::Unsafe;
620}
621///`reset()` method sets CR to value 0x8000_0000
622impl crate::Resettable for CRrs {
623    const RESET_VALUE: u32 = 0x8000_0000;
624}