atsamd51p/pcc/
wpmr.rs
1#[doc = "Register `WPMR` reader"]
2pub type R = crate::R<WpmrSpec>;
3#[doc = "Register `WPMR` writer"]
4pub type W = crate::W<WpmrSpec>;
5#[doc = "Field `WPEN` reader - Write Protection Enable"]
6pub type WpenR = crate::BitReader;
7#[doc = "Field `WPEN` writer - Write Protection Enable"]
8pub type WpenW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Write Protection Key\n\nValue on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u32)]
12pub enum Wpkeyselect {
13 #[doc = "5260099: Write Protection Key"]
14 Passwd = 5260099,
15}
16impl From<Wpkeyselect> for u32 {
17 #[inline(always)]
18 fn from(variant: Wpkeyselect) -> Self {
19 variant as _
20 }
21}
22impl crate::FieldSpec for Wpkeyselect {
23 type Ux = u32;
24}
25impl crate::IsEnum for Wpkeyselect {}
26#[doc = "Field `WPKEY` reader - Write Protection Key"]
27pub type WpkeyR = crate::FieldReader<Wpkeyselect>;
28impl WpkeyR {
29 #[doc = "Get enumerated values variant"]
30 #[inline(always)]
31 pub const fn variant(&self) -> Option<Wpkeyselect> {
32 match self.bits {
33 5260099 => Some(Wpkeyselect::Passwd),
34 _ => None,
35 }
36 }
37 #[doc = "Write Protection Key"]
38 #[inline(always)]
39 pub fn is_passwd(&self) -> bool {
40 *self == Wpkeyselect::Passwd
41 }
42}
43#[doc = "Field `WPKEY` writer - Write Protection Key"]
44pub type WpkeyW<'a, REG> = crate::FieldWriter<'a, REG, 24, Wpkeyselect>;
45impl<'a, REG> WpkeyW<'a, REG>
46where
47 REG: crate::Writable + crate::RegisterSpec,
48 REG::Ux: From<u32>,
49{
50 #[doc = "Write Protection Key"]
51 #[inline(always)]
52 pub fn passwd(self) -> &'a mut crate::W<REG> {
53 self.variant(Wpkeyselect::Passwd)
54 }
55}
56impl R {
57 #[doc = "Bit 0 - Write Protection Enable"]
58 #[inline(always)]
59 pub fn wpen(&self) -> WpenR {
60 WpenR::new((self.bits & 1) != 0)
61 }
62 #[doc = "Bits 8:31 - Write Protection Key"]
63 #[inline(always)]
64 pub fn wpkey(&self) -> WpkeyR {
65 WpkeyR::new((self.bits >> 8) & 0x00ff_ffff)
66 }
67}
68impl W {
69 #[doc = "Bit 0 - Write Protection Enable"]
70 #[inline(always)]
71 #[must_use]
72 pub fn wpen(&mut self) -> WpenW<WpmrSpec> {
73 WpenW::new(self, 0)
74 }
75 #[doc = "Bits 8:31 - Write Protection Key"]
76 #[inline(always)]
77 #[must_use]
78 pub fn wpkey(&mut self) -> WpkeyW<WpmrSpec> {
79 WpkeyW::new(self, 8)
80 }
81}
82#[doc = "Write Protection Mode Register\n\nYou can [`read`](crate::Reg::read) this register and get [`wpmr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`wpmr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
83pub struct WpmrSpec;
84impl crate::RegisterSpec for WpmrSpec {
85 type Ux = u32;
86}
87#[doc = "`read()` method returns [`wpmr::R`](R) reader structure"]
88impl crate::Readable for WpmrSpec {}
89#[doc = "`write(|w| ..)` method takes [`wpmr::W`](W) writer structure"]
90impl crate::Writable for WpmrSpec {
91 type Safety = crate::Unsafe;
92 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
93 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
94}
95#[doc = "`reset()` method sets WPMR to value 0"]
96impl crate::Resettable for WpmrSpec {
97 const RESET_VALUE: u32 = 0;
98}