stm32f4_staging/stm32f413/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
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 all user 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
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 all user sectors
120    #[inline(always)]
121    pub fn is_mass_erase(&self) -> bool {
122        *self == MER::MassErase
123    }
124}
125///Field `MER` writer - Mass Erase
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 all user 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, 4>;
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/**Start
231
232Value on reset: 0*/
233#[cfg_attr(feature = "defmt", derive(defmt::Format))]
234#[derive(Clone, Copy, Debug, PartialEq, Eq)]
235pub enum STRT {
236    ///1: Trigger an erase operation
237    Start = 1,
238}
239impl From<STRT> for bool {
240    #[inline(always)]
241    fn from(variant: STRT) -> Self {
242        variant as u8 != 0
243    }
244}
245///Field `STRT` reader - Start
246pub type STRT_R = crate::BitReader<STRT>;
247impl STRT_R {
248    ///Get enumerated values variant
249    #[inline(always)]
250    pub const fn variant(&self) -> Option<STRT> {
251        match self.bits {
252            true => Some(STRT::Start),
253            _ => None,
254        }
255    }
256    ///Trigger an erase operation
257    #[inline(always)]
258    pub fn is_start(&self) -> bool {
259        *self == STRT::Start
260    }
261}
262///Field `STRT` writer - Start
263pub type STRT_W<'a, REG> = crate::BitWriter<'a, REG, STRT>;
264impl<'a, REG> STRT_W<'a, REG>
265where
266    REG: crate::Writable + crate::RegisterSpec,
267{
268    ///Trigger an erase operation
269    #[inline(always)]
270    pub fn start(self) -> &'a mut crate::W<REG> {
271        self.variant(STRT::Start)
272    }
273}
274/**End of operation interrupt enable
275
276Value on reset: 0*/
277#[cfg_attr(feature = "defmt", derive(defmt::Format))]
278#[derive(Clone, Copy, Debug, PartialEq, Eq)]
279pub enum EOPIE {
280    ///0: End of operation interrupt disabled
281    Disabled = 0,
282    ///1: End of operation interrupt enabled
283    Enabled = 1,
284}
285impl From<EOPIE> for bool {
286    #[inline(always)]
287    fn from(variant: EOPIE) -> Self {
288        variant as u8 != 0
289    }
290}
291///Field `EOPIE` reader - End of operation interrupt enable
292pub type EOPIE_R = crate::BitReader<EOPIE>;
293impl EOPIE_R {
294    ///Get enumerated values variant
295    #[inline(always)]
296    pub const fn variant(&self) -> EOPIE {
297        match self.bits {
298            false => EOPIE::Disabled,
299            true => EOPIE::Enabled,
300        }
301    }
302    ///End of operation interrupt disabled
303    #[inline(always)]
304    pub fn is_disabled(&self) -> bool {
305        *self == EOPIE::Disabled
306    }
307    ///End of operation interrupt enabled
308    #[inline(always)]
309    pub fn is_enabled(&self) -> bool {
310        *self == EOPIE::Enabled
311    }
312}
313///Field `EOPIE` writer - End of operation interrupt enable
314pub type EOPIE_W<'a, REG> = crate::BitWriter<'a, REG, EOPIE>;
315impl<'a, REG> EOPIE_W<'a, REG>
316where
317    REG: crate::Writable + crate::RegisterSpec,
318{
319    ///End of operation interrupt disabled
320    #[inline(always)]
321    pub fn disabled(self) -> &'a mut crate::W<REG> {
322        self.variant(EOPIE::Disabled)
323    }
324    ///End of operation interrupt enabled
325    #[inline(always)]
326    pub fn enabled(self) -> &'a mut crate::W<REG> {
327        self.variant(EOPIE::Enabled)
328    }
329}
330/**Error interrupt enable
331
332Value on reset: 0*/
333#[cfg_attr(feature = "defmt", derive(defmt::Format))]
334#[derive(Clone, Copy, Debug, PartialEq, Eq)]
335pub enum ERRIE {
336    ///0: Error interrupt generation disabled
337    Disabled = 0,
338    ///1: Error interrupt generation enabled
339    Enabled = 1,
340}
341impl From<ERRIE> for bool {
342    #[inline(always)]
343    fn from(variant: ERRIE) -> Self {
344        variant as u8 != 0
345    }
346}
347///Field `ERRIE` reader - Error interrupt enable
348pub type ERRIE_R = crate::BitReader<ERRIE>;
349impl ERRIE_R {
350    ///Get enumerated values variant
351    #[inline(always)]
352    pub const fn variant(&self) -> ERRIE {
353        match self.bits {
354            false => ERRIE::Disabled,
355            true => ERRIE::Enabled,
356        }
357    }
358    ///Error interrupt generation disabled
359    #[inline(always)]
360    pub fn is_disabled(&self) -> bool {
361        *self == ERRIE::Disabled
362    }
363    ///Error interrupt generation enabled
364    #[inline(always)]
365    pub fn is_enabled(&self) -> bool {
366        *self == ERRIE::Enabled
367    }
368}
369///Field `ERRIE` writer - Error interrupt enable
370pub type ERRIE_W<'a, REG> = crate::BitWriter<'a, REG, ERRIE>;
371impl<'a, REG> ERRIE_W<'a, REG>
372where
373    REG: crate::Writable + crate::RegisterSpec,
374{
375    ///Error interrupt generation disabled
376    #[inline(always)]
377    pub fn disabled(self) -> &'a mut crate::W<REG> {
378        self.variant(ERRIE::Disabled)
379    }
380    ///Error interrupt generation enabled
381    #[inline(always)]
382    pub fn enabled(self) -> &'a mut crate::W<REG> {
383        self.variant(ERRIE::Enabled)
384    }
385}
386/**Lock
387
388Value on reset: 1*/
389#[cfg_attr(feature = "defmt", derive(defmt::Format))]
390#[derive(Clone, Copy, Debug, PartialEq, Eq)]
391pub enum LOCK {
392    ///0: FLASH_CR register is unlocked
393    Unlocked = 0,
394    ///1: FLASH_CR register is locked
395    Locked = 1,
396}
397impl From<LOCK> for bool {
398    #[inline(always)]
399    fn from(variant: LOCK) -> Self {
400        variant as u8 != 0
401    }
402}
403///Field `LOCK` reader - Lock
404pub type LOCK_R = crate::BitReader<LOCK>;
405impl LOCK_R {
406    ///Get enumerated values variant
407    #[inline(always)]
408    pub const fn variant(&self) -> LOCK {
409        match self.bits {
410            false => LOCK::Unlocked,
411            true => LOCK::Locked,
412        }
413    }
414    ///FLASH_CR register is unlocked
415    #[inline(always)]
416    pub fn is_unlocked(&self) -> bool {
417        *self == LOCK::Unlocked
418    }
419    ///FLASH_CR register is locked
420    #[inline(always)]
421    pub fn is_locked(&self) -> bool {
422        *self == LOCK::Locked
423    }
424}
425///Field `LOCK` writer - Lock
426pub type LOCK_W<'a, REG> = crate::BitWriter<'a, REG, LOCK>;
427impl<'a, REG> LOCK_W<'a, REG>
428where
429    REG: crate::Writable + crate::RegisterSpec,
430{
431    ///FLASH_CR register is unlocked
432    #[inline(always)]
433    pub fn unlocked(self) -> &'a mut crate::W<REG> {
434        self.variant(LOCK::Unlocked)
435    }
436    ///FLASH_CR register is locked
437    #[inline(always)]
438    pub fn locked(self) -> &'a mut crate::W<REG> {
439        self.variant(LOCK::Locked)
440    }
441}
442impl R {
443    ///Bit 0 - Programming
444    #[inline(always)]
445    pub fn pg(&self) -> PG_R {
446        PG_R::new((self.bits & 1) != 0)
447    }
448    ///Bit 1 - Sector Erase
449    #[inline(always)]
450    pub fn ser(&self) -> SER_R {
451        SER_R::new(((self.bits >> 1) & 1) != 0)
452    }
453    ///Bit 2 - Mass Erase
454    #[inline(always)]
455    pub fn mer(&self) -> MER_R {
456        MER_R::new(((self.bits >> 2) & 1) != 0)
457    }
458    ///Bits 3:6 - Sector number
459    #[inline(always)]
460    pub fn snb(&self) -> SNB_R {
461        SNB_R::new(((self.bits >> 3) & 0x0f) as u8)
462    }
463    ///Bits 8:9 - Program size
464    #[inline(always)]
465    pub fn psize(&self) -> PSIZE_R {
466        PSIZE_R::new(((self.bits >> 8) & 3) as u8)
467    }
468    ///Bit 16 - Start
469    #[inline(always)]
470    pub fn strt(&self) -> STRT_R {
471        STRT_R::new(((self.bits >> 16) & 1) != 0)
472    }
473    ///Bit 24 - End of operation interrupt enable
474    #[inline(always)]
475    pub fn eopie(&self) -> EOPIE_R {
476        EOPIE_R::new(((self.bits >> 24) & 1) != 0)
477    }
478    ///Bit 25 - Error interrupt enable
479    #[inline(always)]
480    pub fn errie(&self) -> ERRIE_R {
481        ERRIE_R::new(((self.bits >> 25) & 1) != 0)
482    }
483    ///Bit 31 - Lock
484    #[inline(always)]
485    pub fn lock(&self) -> LOCK_R {
486        LOCK_R::new(((self.bits >> 31) & 1) != 0)
487    }
488}
489impl core::fmt::Debug for R {
490    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
491        f.debug_struct("CR")
492            .field("pg", &self.pg())
493            .field("ser", &self.ser())
494            .field("mer", &self.mer())
495            .field("snb", &self.snb())
496            .field("psize", &self.psize())
497            .field("strt", &self.strt())
498            .field("eopie", &self.eopie())
499            .field("errie", &self.errie())
500            .field("lock", &self.lock())
501            .finish()
502    }
503}
504impl W {
505    ///Bit 0 - Programming
506    #[inline(always)]
507    pub fn pg(&mut self) -> PG_W<CRrs> {
508        PG_W::new(self, 0)
509    }
510    ///Bit 1 - Sector Erase
511    #[inline(always)]
512    pub fn ser(&mut self) -> SER_W<CRrs> {
513        SER_W::new(self, 1)
514    }
515    ///Bit 2 - Mass Erase
516    #[inline(always)]
517    pub fn mer(&mut self) -> MER_W<CRrs> {
518        MER_W::new(self, 2)
519    }
520    ///Bits 3:6 - Sector number
521    #[inline(always)]
522    pub fn snb(&mut self) -> SNB_W<CRrs> {
523        SNB_W::new(self, 3)
524    }
525    ///Bits 8:9 - Program size
526    #[inline(always)]
527    pub fn psize(&mut self) -> PSIZE_W<CRrs> {
528        PSIZE_W::new(self, 8)
529    }
530    ///Bit 16 - Start
531    #[inline(always)]
532    pub fn strt(&mut self) -> STRT_W<CRrs> {
533        STRT_W::new(self, 16)
534    }
535    ///Bit 24 - End of operation interrupt enable
536    #[inline(always)]
537    pub fn eopie(&mut self) -> EOPIE_W<CRrs> {
538        EOPIE_W::new(self, 24)
539    }
540    ///Bit 25 - Error interrupt enable
541    #[inline(always)]
542    pub fn errie(&mut self) -> ERRIE_W<CRrs> {
543        ERRIE_W::new(self, 25)
544    }
545    ///Bit 31 - Lock
546    #[inline(always)]
547    pub fn lock(&mut self) -> LOCK_W<CRrs> {
548        LOCK_W::new(self, 31)
549    }
550}
551/**Control register
552
553You 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).
554
555See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F413.html#FLASH:CR)*/
556pub struct CRrs;
557impl crate::RegisterSpec for CRrs {
558    type Ux = u32;
559}
560///`read()` method returns [`cr::R`](R) reader structure
561impl crate::Readable for CRrs {}
562///`write(|w| ..)` method takes [`cr::W`](W) writer structure
563impl crate::Writable for CRrs {
564    type Safety = crate::Unsafe;
565}
566///`reset()` method sets CR to value 0x8000_0000
567impl crate::Resettable for CRrs {
568    const RESET_VALUE: u32 = 0x8000_0000;
569}