stm32f4_staging/stm32f413/flash/
optcr.rs

1///Register `OPTCR` reader
2pub type R = crate::R<OPTCRrs>;
3///Register `OPTCR` writer
4pub type W = crate::W<OPTCRrs>;
5/**Option lock
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum OPTLOCKR {
11    ///0: The write and erase operations in the Option bytes area are disabled
12    Unlocked = 0,
13    ///1: The write and erase operations in the Option bytes area are enabled
14    Locked = 1,
15}
16impl From<OPTLOCKR> for bool {
17    #[inline(always)]
18    fn from(variant: OPTLOCKR) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `OPTLOCK` reader - Option lock
23pub type OPTLOCK_R = crate::BitReader<OPTLOCKR>;
24impl OPTLOCK_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> OPTLOCKR {
28        match self.bits {
29            false => OPTLOCKR::Unlocked,
30            true => OPTLOCKR::Locked,
31        }
32    }
33    ///The write and erase operations in the Option bytes area are disabled
34    #[inline(always)]
35    pub fn is_unlocked(&self) -> bool {
36        *self == OPTLOCKR::Unlocked
37    }
38    ///The write and erase operations in the Option bytes area are enabled
39    #[inline(always)]
40    pub fn is_locked(&self) -> bool {
41        *self == OPTLOCKR::Locked
42    }
43}
44/**Option lock
45
46Value on reset: 0*/
47#[cfg_attr(feature = "defmt", derive(defmt::Format))]
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49pub enum OPTLOCKW {
50    ///1: Lock the FLASH_OPTCR register
51    Set = 1,
52}
53impl From<OPTLOCKW> for bool {
54    #[inline(always)]
55    fn from(variant: OPTLOCKW) -> Self {
56        variant as u8 != 0
57    }
58}
59///Field `OPTLOCK` writer - Option lock
60pub type OPTLOCK_W<'a, REG> = crate::BitWriter<'a, REG, OPTLOCKW>;
61impl<'a, REG> OPTLOCK_W<'a, REG>
62where
63    REG: crate::Writable + crate::RegisterSpec,
64{
65    ///Lock the FLASH_OPTCR register
66    #[inline(always)]
67    pub fn set_(self) -> &'a mut crate::W<REG> {
68        self.variant(OPTLOCKW::Set)
69    }
70}
71/**Option start
72
73Value on reset: 0*/
74#[cfg_attr(feature = "defmt", derive(defmt::Format))]
75#[derive(Clone, Copy, Debug, PartialEq, Eq)]
76pub enum OPTSTRTR {
77    ///0: Cleared when BSY bit is cleared in SR
78    Complete = 0,
79    ///1: Options modification requested
80    Requested = 1,
81}
82impl From<OPTSTRTR> for bool {
83    #[inline(always)]
84    fn from(variant: OPTSTRTR) -> Self {
85        variant as u8 != 0
86    }
87}
88///Field `OPTSTRT` reader - Option start
89pub type OPTSTRT_R = crate::BitReader<OPTSTRTR>;
90impl OPTSTRT_R {
91    ///Get enumerated values variant
92    #[inline(always)]
93    pub const fn variant(&self) -> OPTSTRTR {
94        match self.bits {
95            false => OPTSTRTR::Complete,
96            true => OPTSTRTR::Requested,
97        }
98    }
99    ///Cleared when BSY bit is cleared in SR
100    #[inline(always)]
101    pub fn is_complete(&self) -> bool {
102        *self == OPTSTRTR::Complete
103    }
104    ///Options modification requested
105    #[inline(always)]
106    pub fn is_requested(&self) -> bool {
107        *self == OPTSTRTR::Requested
108    }
109}
110/**Option start
111
112Value on reset: 0*/
113#[cfg_attr(feature = "defmt", derive(defmt::Format))]
114#[derive(Clone, Copy, Debug, PartialEq, Eq)]
115pub enum OPTSTRTW {
116    ///1: This bit triggers an options operation when set
117    Set = 1,
118}
119impl From<OPTSTRTW> for bool {
120    #[inline(always)]
121    fn from(variant: OPTSTRTW) -> Self {
122        variant as u8 != 0
123    }
124}
125///Field `OPTSTRT` writer - Option start
126pub type OPTSTRT_W<'a, REG> = crate::BitWriter<'a, REG, OPTSTRTW>;
127impl<'a, REG> OPTSTRT_W<'a, REG>
128where
129    REG: crate::Writable + crate::RegisterSpec,
130{
131    ///This bit triggers an options operation when set
132    #[inline(always)]
133    pub fn set_(self) -> &'a mut crate::W<REG> {
134        self.variant(OPTSTRTW::Set)
135    }
136}
137/**BOR reset Level
138
139Value on reset: 1*/
140#[cfg_attr(feature = "defmt", derive(defmt::Format))]
141#[derive(Clone, Copy, Debug, PartialEq, Eq)]
142#[repr(u8)]
143pub enum BOR_LEV {
144    ///0: Reset threshold level for POR/PDR (around 1.7V)
145    BorOff = 0,
146    ///1: Reset threshold level for VBOR1 (around 2.2 V)
147    BorLevel1 = 1,
148    ///2: Reset threshold level for VBOR2 (around 2.5 V)
149    BorLevel2 = 2,
150    ///3: Reset threshold level for VBOR3 (around 2.8 V)
151    BorLevel3 = 3,
152}
153impl From<BOR_LEV> for u8 {
154    #[inline(always)]
155    fn from(variant: BOR_LEV) -> Self {
156        variant as _
157    }
158}
159impl crate::FieldSpec for BOR_LEV {
160    type Ux = u8;
161}
162impl crate::IsEnum for BOR_LEV {}
163///Field `BOR_LEV` reader - BOR reset Level
164pub type BOR_LEV_R = crate::FieldReader<BOR_LEV>;
165impl BOR_LEV_R {
166    ///Get enumerated values variant
167    #[inline(always)]
168    pub const fn variant(&self) -> BOR_LEV {
169        match self.bits {
170            0 => BOR_LEV::BorOff,
171            1 => BOR_LEV::BorLevel1,
172            2 => BOR_LEV::BorLevel2,
173            3 => BOR_LEV::BorLevel3,
174            _ => unreachable!(),
175        }
176    }
177    ///Reset threshold level for POR/PDR (around 1.7V)
178    #[inline(always)]
179    pub fn is_bor_off(&self) -> bool {
180        *self == BOR_LEV::BorOff
181    }
182    ///Reset threshold level for VBOR1 (around 2.2 V)
183    #[inline(always)]
184    pub fn is_bor_level1(&self) -> bool {
185        *self == BOR_LEV::BorLevel1
186    }
187    ///Reset threshold level for VBOR2 (around 2.5 V)
188    #[inline(always)]
189    pub fn is_bor_level2(&self) -> bool {
190        *self == BOR_LEV::BorLevel2
191    }
192    ///Reset threshold level for VBOR3 (around 2.8 V)
193    #[inline(always)]
194    pub fn is_bor_level3(&self) -> bool {
195        *self == BOR_LEV::BorLevel3
196    }
197}
198///Field `BOR_LEV` writer - BOR reset Level
199pub type BOR_LEV_W<'a, REG> = crate::FieldWriter<'a, REG, 2, BOR_LEV, crate::Safe>;
200impl<'a, REG> BOR_LEV_W<'a, REG>
201where
202    REG: crate::Writable + crate::RegisterSpec,
203    REG::Ux: From<u8>,
204{
205    ///Reset threshold level for POR/PDR (around 1.7V)
206    #[inline(always)]
207    pub fn bor_off(self) -> &'a mut crate::W<REG> {
208        self.variant(BOR_LEV::BorOff)
209    }
210    ///Reset threshold level for VBOR1 (around 2.2 V)
211    #[inline(always)]
212    pub fn bor_level1(self) -> &'a mut crate::W<REG> {
213        self.variant(BOR_LEV::BorLevel1)
214    }
215    ///Reset threshold level for VBOR2 (around 2.5 V)
216    #[inline(always)]
217    pub fn bor_level2(self) -> &'a mut crate::W<REG> {
218        self.variant(BOR_LEV::BorLevel2)
219    }
220    ///Reset threshold level for VBOR3 (around 2.8 V)
221    #[inline(always)]
222    pub fn bor_level3(self) -> &'a mut crate::W<REG> {
223        self.variant(BOR_LEV::BorLevel3)
224    }
225}
226/**WDG_SW User option bytes
227
228Value on reset: 0*/
229#[cfg_attr(feature = "defmt", derive(defmt::Format))]
230#[derive(Clone, Copy, Debug, PartialEq, Eq)]
231pub enum WDG_SW {
232    ///0: Hardware watchdog
233    Hardware = 0,
234    ///1: Software watchdog
235    Software = 1,
236}
237impl From<WDG_SW> for bool {
238    #[inline(always)]
239    fn from(variant: WDG_SW) -> Self {
240        variant as u8 != 0
241    }
242}
243///Field `WDG_SW` reader - WDG_SW User option bytes
244pub type WDG_SW_R = crate::BitReader<WDG_SW>;
245impl WDG_SW_R {
246    ///Get enumerated values variant
247    #[inline(always)]
248    pub const fn variant(&self) -> WDG_SW {
249        match self.bits {
250            false => WDG_SW::Hardware,
251            true => WDG_SW::Software,
252        }
253    }
254    ///Hardware watchdog
255    #[inline(always)]
256    pub fn is_hardware(&self) -> bool {
257        *self == WDG_SW::Hardware
258    }
259    ///Software watchdog
260    #[inline(always)]
261    pub fn is_software(&self) -> bool {
262        *self == WDG_SW::Software
263    }
264}
265///Field `WDG_SW` writer - WDG_SW User option bytes
266pub type WDG_SW_W<'a, REG> = crate::BitWriter<'a, REG, WDG_SW>;
267impl<'a, REG> WDG_SW_W<'a, REG>
268where
269    REG: crate::Writable + crate::RegisterSpec,
270{
271    ///Hardware watchdog
272    #[inline(always)]
273    pub fn hardware(self) -> &'a mut crate::W<REG> {
274        self.variant(WDG_SW::Hardware)
275    }
276    ///Software watchdog
277    #[inline(always)]
278    pub fn software(self) -> &'a mut crate::W<REG> {
279        self.variant(WDG_SW::Software)
280    }
281}
282/**nRST_STOP User option bytes
283
284Value on reset: 0*/
285#[cfg_attr(feature = "defmt", derive(defmt::Format))]
286#[derive(Clone, Copy, Debug, PartialEq, Eq)]
287pub enum N_RST_STOP {
288    ///0: Reset generated when entering Stop mode
289    Reset = 0,
290    ///1: No reset generated
291    NoReset = 1,
292}
293impl From<N_RST_STOP> for bool {
294    #[inline(always)]
295    fn from(variant: N_RST_STOP) -> Self {
296        variant as u8 != 0
297    }
298}
299///Field `nRST_STOP` reader - nRST_STOP User option bytes
300pub type N_RST_STOP_R = crate::BitReader<N_RST_STOP>;
301impl N_RST_STOP_R {
302    ///Get enumerated values variant
303    #[inline(always)]
304    pub const fn variant(&self) -> N_RST_STOP {
305        match self.bits {
306            false => N_RST_STOP::Reset,
307            true => N_RST_STOP::NoReset,
308        }
309    }
310    ///Reset generated when entering Stop mode
311    #[inline(always)]
312    pub fn is_reset(&self) -> bool {
313        *self == N_RST_STOP::Reset
314    }
315    ///No reset generated
316    #[inline(always)]
317    pub fn is_no_reset(&self) -> bool {
318        *self == N_RST_STOP::NoReset
319    }
320}
321///Field `nRST_STOP` writer - nRST_STOP User option bytes
322pub type N_RST_STOP_W<'a, REG> = crate::BitWriter<'a, REG, N_RST_STOP>;
323impl<'a, REG> N_RST_STOP_W<'a, REG>
324where
325    REG: crate::Writable + crate::RegisterSpec,
326{
327    ///Reset generated when entering Stop mode
328    #[inline(always)]
329    pub fn reset(self) -> &'a mut crate::W<REG> {
330        self.variant(N_RST_STOP::Reset)
331    }
332    ///No reset generated
333    #[inline(always)]
334    pub fn no_reset(self) -> &'a mut crate::W<REG> {
335        self.variant(N_RST_STOP::NoReset)
336    }
337}
338/**nRST_STDBY User option bytes
339
340Value on reset: 0*/
341#[cfg_attr(feature = "defmt", derive(defmt::Format))]
342#[derive(Clone, Copy, Debug, PartialEq, Eq)]
343pub enum N_RST_STDBY {
344    ///0: Reset generated when entering Standby mode
345    Reset = 0,
346    ///1: No reset generated
347    NoReset = 1,
348}
349impl From<N_RST_STDBY> for bool {
350    #[inline(always)]
351    fn from(variant: N_RST_STDBY) -> Self {
352        variant as u8 != 0
353    }
354}
355///Field `nRST_STDBY` reader - nRST_STDBY User option bytes
356pub type N_RST_STDBY_R = crate::BitReader<N_RST_STDBY>;
357impl N_RST_STDBY_R {
358    ///Get enumerated values variant
359    #[inline(always)]
360    pub const fn variant(&self) -> N_RST_STDBY {
361        match self.bits {
362            false => N_RST_STDBY::Reset,
363            true => N_RST_STDBY::NoReset,
364        }
365    }
366    ///Reset generated when entering Standby mode
367    #[inline(always)]
368    pub fn is_reset(&self) -> bool {
369        *self == N_RST_STDBY::Reset
370    }
371    ///No reset generated
372    #[inline(always)]
373    pub fn is_no_reset(&self) -> bool {
374        *self == N_RST_STDBY::NoReset
375    }
376}
377///Field `nRST_STDBY` writer - nRST_STDBY User option bytes
378pub type N_RST_STDBY_W<'a, REG> = crate::BitWriter<'a, REG, N_RST_STDBY>;
379impl<'a, REG> N_RST_STDBY_W<'a, REG>
380where
381    REG: crate::Writable + crate::RegisterSpec,
382{
383    ///Reset generated when entering Standby mode
384    #[inline(always)]
385    pub fn reset(self) -> &'a mut crate::W<REG> {
386        self.variant(N_RST_STDBY::Reset)
387    }
388    ///No reset generated
389    #[inline(always)]
390    pub fn no_reset(self) -> &'a mut crate::W<REG> {
391        self.variant(N_RST_STDBY::NoReset)
392    }
393}
394/**Read protect
395
396Value on reset: 0*/
397#[cfg_attr(feature = "defmt", derive(defmt::Format))]
398#[derive(Clone, Copy, Debug, PartialEq, Eq)]
399#[repr(u8)]
400pub enum RDP {
401    ///170: Read protection not active
402    Level0 = 170,
403    ///204: Chip read protection active
404    Level2 = 204,
405    ///0: Read protection of memories active
406    Level1 = 0,
407}
408impl From<RDP> for u8 {
409    #[inline(always)]
410    fn from(variant: RDP) -> Self {
411        variant as _
412    }
413}
414impl crate::FieldSpec for RDP {
415    type Ux = u8;
416}
417impl crate::IsEnum for RDP {}
418///Field `RDP` reader - Read protect
419pub type RDP_R = crate::FieldReader<RDP>;
420impl RDP_R {
421    ///Get enumerated values variant
422    #[inline(always)]
423    pub const fn variant(&self) -> RDP {
424        match self.bits {
425            170 => RDP::Level0,
426            204 => RDP::Level2,
427            _ => RDP::Level1,
428        }
429    }
430    ///Read protection not active
431    #[inline(always)]
432    pub fn is_level0(&self) -> bool {
433        *self == RDP::Level0
434    }
435    ///Chip read protection active
436    #[inline(always)]
437    pub fn is_level2(&self) -> bool {
438        *self == RDP::Level2
439    }
440    ///Read protection of memories active
441    #[inline(always)]
442    pub fn is_level1(&self) -> bool {
443        matches!(self.variant(), RDP::Level1)
444    }
445}
446///Field `RDP` writer - Read protect
447pub type RDP_W<'a, REG> = crate::FieldWriter<'a, REG, 8, RDP, crate::Safe>;
448impl<'a, REG> RDP_W<'a, REG>
449where
450    REG: crate::Writable + crate::RegisterSpec,
451    REG::Ux: From<u8>,
452{
453    ///Read protection not active
454    #[inline(always)]
455    pub fn level0(self) -> &'a mut crate::W<REG> {
456        self.variant(RDP::Level0)
457    }
458    ///Chip read protection active
459    #[inline(always)]
460    pub fn level2(self) -> &'a mut crate::W<REG> {
461        self.variant(RDP::Level2)
462    }
463    ///Read protection of memories active
464    #[inline(always)]
465    pub fn level1(self) -> &'a mut crate::W<REG> {
466        self.variant(RDP::Level1)
467    }
468}
469/**Not write protect
470
471Value on reset: 0*/
472#[cfg_attr(feature = "defmt", derive(defmt::Format))]
473#[derive(Clone, Copy, Debug, PartialEq, Eq)]
474pub enum N_WRP0 {
475    ///0: Write protection active on sector %s
476    Active = 0,
477    ///1: Write protection inactive on sector %s
478    Inactive = 1,
479}
480impl From<N_WRP0> for bool {
481    #[inline(always)]
482    fn from(variant: N_WRP0) -> Self {
483        variant as u8 != 0
484    }
485}
486///Field `nWRP(0-11)` reader - Not write protect
487pub type N_WRP_R = crate::BitReader<N_WRP0>;
488impl N_WRP_R {
489    ///Get enumerated values variant
490    #[inline(always)]
491    pub const fn variant(&self) -> N_WRP0 {
492        match self.bits {
493            false => N_WRP0::Active,
494            true => N_WRP0::Inactive,
495        }
496    }
497    ///Write protection active on sector %s
498    #[inline(always)]
499    pub fn is_active(&self) -> bool {
500        *self == N_WRP0::Active
501    }
502    ///Write protection inactive on sector %s
503    #[inline(always)]
504    pub fn is_inactive(&self) -> bool {
505        *self == N_WRP0::Inactive
506    }
507}
508///Field `nWRP(0-11)` writer - Not write protect
509pub type N_WRP_W<'a, REG> = crate::BitWriter<'a, REG, N_WRP0>;
510impl<'a, REG> N_WRP_W<'a, REG>
511where
512    REG: crate::Writable + crate::RegisterSpec,
513{
514    ///Write protection active on sector %s
515    #[inline(always)]
516    pub fn active(self) -> &'a mut crate::W<REG> {
517        self.variant(N_WRP0::Active)
518    }
519    ///Write protection inactive on sector %s
520    #[inline(always)]
521    pub fn inactive(self) -> &'a mut crate::W<REG> {
522        self.variant(N_WRP0::Inactive)
523    }
524}
525/**Selection of Protection Mode of nWPR bits
526
527Value on reset: 0*/
528#[cfg_attr(feature = "defmt", derive(defmt::Format))]
529#[derive(Clone, Copy, Debug, PartialEq, Eq)]
530pub enum SPRMOD {
531    ///0: nWPRi bits used for Write protection on sector i
532    Disabled = 0,
533    ///1: nWPRi bits used for PCROP protection on sector i
534    Enabled = 1,
535}
536impl From<SPRMOD> for bool {
537    #[inline(always)]
538    fn from(variant: SPRMOD) -> Self {
539        variant as u8 != 0
540    }
541}
542///Field `SPRMOD` reader - Selection of Protection Mode of nWPR bits
543pub type SPRMOD_R = crate::BitReader<SPRMOD>;
544impl SPRMOD_R {
545    ///Get enumerated values variant
546    #[inline(always)]
547    pub const fn variant(&self) -> SPRMOD {
548        match self.bits {
549            false => SPRMOD::Disabled,
550            true => SPRMOD::Enabled,
551        }
552    }
553    ///nWPRi bits used for Write protection on sector i
554    #[inline(always)]
555    pub fn is_disabled(&self) -> bool {
556        *self == SPRMOD::Disabled
557    }
558    ///nWPRi bits used for PCROP protection on sector i
559    #[inline(always)]
560    pub fn is_enabled(&self) -> bool {
561        *self == SPRMOD::Enabled
562    }
563}
564///Field `SPRMOD` writer - Selection of Protection Mode of nWPR bits
565pub type SPRMOD_W<'a, REG> = crate::BitWriter<'a, REG, SPRMOD>;
566impl<'a, REG> SPRMOD_W<'a, REG>
567where
568    REG: crate::Writable + crate::RegisterSpec,
569{
570    ///nWPRi bits used for Write protection on sector i
571    #[inline(always)]
572    pub fn disabled(self) -> &'a mut crate::W<REG> {
573        self.variant(SPRMOD::Disabled)
574    }
575    ///nWPRi bits used for PCROP protection on sector i
576    #[inline(always)]
577    pub fn enabled(self) -> &'a mut crate::W<REG> {
578        self.variant(SPRMOD::Enabled)
579    }
580}
581impl R {
582    ///Bit 0 - Option lock
583    #[inline(always)]
584    pub fn optlock(&self) -> OPTLOCK_R {
585        OPTLOCK_R::new((self.bits & 1) != 0)
586    }
587    ///Bit 1 - Option start
588    #[inline(always)]
589    pub fn optstrt(&self) -> OPTSTRT_R {
590        OPTSTRT_R::new(((self.bits >> 1) & 1) != 0)
591    }
592    ///Bits 2:3 - BOR reset Level
593    #[inline(always)]
594    pub fn bor_lev(&self) -> BOR_LEV_R {
595        BOR_LEV_R::new(((self.bits >> 2) & 3) as u8)
596    }
597    ///Bit 5 - WDG_SW User option bytes
598    #[inline(always)]
599    pub fn wdg_sw(&self) -> WDG_SW_R {
600        WDG_SW_R::new(((self.bits >> 5) & 1) != 0)
601    }
602    ///Bit 6 - nRST_STOP User option bytes
603    #[inline(always)]
604    pub fn n_rst_stop(&self) -> N_RST_STOP_R {
605        N_RST_STOP_R::new(((self.bits >> 6) & 1) != 0)
606    }
607    ///Bit 7 - nRST_STDBY User option bytes
608    #[inline(always)]
609    pub fn n_rst_stdby(&self) -> N_RST_STDBY_R {
610        N_RST_STDBY_R::new(((self.bits >> 7) & 1) != 0)
611    }
612    ///Bits 8:15 - Read protect
613    #[inline(always)]
614    pub fn rdp(&self) -> RDP_R {
615        RDP_R::new(((self.bits >> 8) & 0xff) as u8)
616    }
617    ///Not write protect
618    ///
619    ///<div class="warning">`n` is number of field in register. `n == 0` corresponds to `nWRP0` field.</div>
620    #[inline(always)]
621    pub fn n_wrp(&self, n: u8) -> N_WRP_R {
622        #[allow(clippy::no_effect)]
623        [(); 12][n as usize];
624        N_WRP_R::new(((self.bits >> (n + 16)) & 1) != 0)
625    }
626    ///Iterator for array of:
627    ///Not write protect
628    #[inline(always)]
629    pub fn n_wrp_iter(&self) -> impl Iterator<Item = N_WRP_R> + '_ {
630        (0..12).map(move |n| N_WRP_R::new(((self.bits >> (n + 16)) & 1) != 0))
631    }
632    ///Bit 16 - Not write protect
633    #[inline(always)]
634    pub fn n_wrp0(&self) -> N_WRP_R {
635        N_WRP_R::new(((self.bits >> 16) & 1) != 0)
636    }
637    ///Bit 17 - Not write protect
638    #[inline(always)]
639    pub fn n_wrp1(&self) -> N_WRP_R {
640        N_WRP_R::new(((self.bits >> 17) & 1) != 0)
641    }
642    ///Bit 18 - Not write protect
643    #[inline(always)]
644    pub fn n_wrp2(&self) -> N_WRP_R {
645        N_WRP_R::new(((self.bits >> 18) & 1) != 0)
646    }
647    ///Bit 19 - Not write protect
648    #[inline(always)]
649    pub fn n_wrp3(&self) -> N_WRP_R {
650        N_WRP_R::new(((self.bits >> 19) & 1) != 0)
651    }
652    ///Bit 20 - Not write protect
653    #[inline(always)]
654    pub fn n_wrp4(&self) -> N_WRP_R {
655        N_WRP_R::new(((self.bits >> 20) & 1) != 0)
656    }
657    ///Bit 21 - Not write protect
658    #[inline(always)]
659    pub fn n_wrp5(&self) -> N_WRP_R {
660        N_WRP_R::new(((self.bits >> 21) & 1) != 0)
661    }
662    ///Bit 22 - Not write protect
663    #[inline(always)]
664    pub fn n_wrp6(&self) -> N_WRP_R {
665        N_WRP_R::new(((self.bits >> 22) & 1) != 0)
666    }
667    ///Bit 23 - Not write protect
668    #[inline(always)]
669    pub fn n_wrp7(&self) -> N_WRP_R {
670        N_WRP_R::new(((self.bits >> 23) & 1) != 0)
671    }
672    ///Bit 24 - Not write protect
673    #[inline(always)]
674    pub fn n_wrp8(&self) -> N_WRP_R {
675        N_WRP_R::new(((self.bits >> 24) & 1) != 0)
676    }
677    ///Bit 25 - Not write protect
678    #[inline(always)]
679    pub fn n_wrp9(&self) -> N_WRP_R {
680        N_WRP_R::new(((self.bits >> 25) & 1) != 0)
681    }
682    ///Bit 26 - Not write protect
683    #[inline(always)]
684    pub fn n_wrp10(&self) -> N_WRP_R {
685        N_WRP_R::new(((self.bits >> 26) & 1) != 0)
686    }
687    ///Bit 27 - Not write protect
688    #[inline(always)]
689    pub fn n_wrp11(&self) -> N_WRP_R {
690        N_WRP_R::new(((self.bits >> 27) & 1) != 0)
691    }
692    ///Bit 31 - Selection of Protection Mode of nWPR bits
693    #[inline(always)]
694    pub fn sprmod(&self) -> SPRMOD_R {
695        SPRMOD_R::new(((self.bits >> 31) & 1) != 0)
696    }
697}
698impl core::fmt::Debug for R {
699    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
700        f.debug_struct("OPTCR")
701            .field("optlock", &self.optlock())
702            .field("optstrt", &self.optstrt())
703            .field("bor_lev", &self.bor_lev())
704            .field("wdg_sw", &self.wdg_sw())
705            .field("n_rst_stop", &self.n_rst_stop())
706            .field("n_rst_stdby", &self.n_rst_stdby())
707            .field("rdp", &self.rdp())
708            .field("sprmod", &self.sprmod())
709            .field("n_wrp0", &self.n_wrp0())
710            .field("n_wrp1", &self.n_wrp1())
711            .field("n_wrp2", &self.n_wrp2())
712            .field("n_wrp3", &self.n_wrp3())
713            .field("n_wrp4", &self.n_wrp4())
714            .field("n_wrp5", &self.n_wrp5())
715            .field("n_wrp6", &self.n_wrp6())
716            .field("n_wrp7", &self.n_wrp7())
717            .field("n_wrp8", &self.n_wrp8())
718            .field("n_wrp9", &self.n_wrp9())
719            .field("n_wrp10", &self.n_wrp10())
720            .field("n_wrp11", &self.n_wrp11())
721            .finish()
722    }
723}
724impl W {
725    ///Bit 0 - Option lock
726    #[inline(always)]
727    pub fn optlock(&mut self) -> OPTLOCK_W<OPTCRrs> {
728        OPTLOCK_W::new(self, 0)
729    }
730    ///Bit 1 - Option start
731    #[inline(always)]
732    pub fn optstrt(&mut self) -> OPTSTRT_W<OPTCRrs> {
733        OPTSTRT_W::new(self, 1)
734    }
735    ///Bits 2:3 - BOR reset Level
736    #[inline(always)]
737    pub fn bor_lev(&mut self) -> BOR_LEV_W<OPTCRrs> {
738        BOR_LEV_W::new(self, 2)
739    }
740    ///Bit 5 - WDG_SW User option bytes
741    #[inline(always)]
742    pub fn wdg_sw(&mut self) -> WDG_SW_W<OPTCRrs> {
743        WDG_SW_W::new(self, 5)
744    }
745    ///Bit 6 - nRST_STOP User option bytes
746    #[inline(always)]
747    pub fn n_rst_stop(&mut self) -> N_RST_STOP_W<OPTCRrs> {
748        N_RST_STOP_W::new(self, 6)
749    }
750    ///Bit 7 - nRST_STDBY User option bytes
751    #[inline(always)]
752    pub fn n_rst_stdby(&mut self) -> N_RST_STDBY_W<OPTCRrs> {
753        N_RST_STDBY_W::new(self, 7)
754    }
755    ///Bits 8:15 - Read protect
756    #[inline(always)]
757    pub fn rdp(&mut self) -> RDP_W<OPTCRrs> {
758        RDP_W::new(self, 8)
759    }
760    ///Not write protect
761    ///
762    ///<div class="warning">`n` is number of field in register. `n == 0` corresponds to `nWRP0` field.</div>
763    #[inline(always)]
764    pub fn n_wrp(&mut self, n: u8) -> N_WRP_W<OPTCRrs> {
765        #[allow(clippy::no_effect)]
766        [(); 12][n as usize];
767        N_WRP_W::new(self, n + 16)
768    }
769    ///Bit 16 - Not write protect
770    #[inline(always)]
771    pub fn n_wrp0(&mut self) -> N_WRP_W<OPTCRrs> {
772        N_WRP_W::new(self, 16)
773    }
774    ///Bit 17 - Not write protect
775    #[inline(always)]
776    pub fn n_wrp1(&mut self) -> N_WRP_W<OPTCRrs> {
777        N_WRP_W::new(self, 17)
778    }
779    ///Bit 18 - Not write protect
780    #[inline(always)]
781    pub fn n_wrp2(&mut self) -> N_WRP_W<OPTCRrs> {
782        N_WRP_W::new(self, 18)
783    }
784    ///Bit 19 - Not write protect
785    #[inline(always)]
786    pub fn n_wrp3(&mut self) -> N_WRP_W<OPTCRrs> {
787        N_WRP_W::new(self, 19)
788    }
789    ///Bit 20 - Not write protect
790    #[inline(always)]
791    pub fn n_wrp4(&mut self) -> N_WRP_W<OPTCRrs> {
792        N_WRP_W::new(self, 20)
793    }
794    ///Bit 21 - Not write protect
795    #[inline(always)]
796    pub fn n_wrp5(&mut self) -> N_WRP_W<OPTCRrs> {
797        N_WRP_W::new(self, 21)
798    }
799    ///Bit 22 - Not write protect
800    #[inline(always)]
801    pub fn n_wrp6(&mut self) -> N_WRP_W<OPTCRrs> {
802        N_WRP_W::new(self, 22)
803    }
804    ///Bit 23 - Not write protect
805    #[inline(always)]
806    pub fn n_wrp7(&mut self) -> N_WRP_W<OPTCRrs> {
807        N_WRP_W::new(self, 23)
808    }
809    ///Bit 24 - Not write protect
810    #[inline(always)]
811    pub fn n_wrp8(&mut self) -> N_WRP_W<OPTCRrs> {
812        N_WRP_W::new(self, 24)
813    }
814    ///Bit 25 - Not write protect
815    #[inline(always)]
816    pub fn n_wrp9(&mut self) -> N_WRP_W<OPTCRrs> {
817        N_WRP_W::new(self, 25)
818    }
819    ///Bit 26 - Not write protect
820    #[inline(always)]
821    pub fn n_wrp10(&mut self) -> N_WRP_W<OPTCRrs> {
822        N_WRP_W::new(self, 26)
823    }
824    ///Bit 27 - Not write protect
825    #[inline(always)]
826    pub fn n_wrp11(&mut self) -> N_WRP_W<OPTCRrs> {
827        N_WRP_W::new(self, 27)
828    }
829    ///Bit 31 - Selection of Protection Mode of nWPR bits
830    #[inline(always)]
831    pub fn sprmod(&mut self) -> SPRMOD_W<OPTCRrs> {
832        SPRMOD_W::new(self, 31)
833    }
834}
835/**Flash option control register
836
837You can [`read`](crate::Reg::read) this register and get [`optcr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`optcr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
838
839See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F413.html#FLASH:OPTCR)*/
840pub struct OPTCRrs;
841impl crate::RegisterSpec for OPTCRrs {
842    type Ux = u32;
843}
844///`read()` method returns [`optcr::R`](R) reader structure
845impl crate::Readable for OPTCRrs {}
846///`write(|w| ..)` method takes [`optcr::W`](W) writer structure
847impl crate::Writable for OPTCRrs {
848    type Safety = crate::Unsafe;
849}
850///`reset()` method sets OPTCR to value 0x14
851impl crate::Resettable for OPTCRrs {
852    const RESET_VALUE: u32 = 0x14;
853}