atsams70j19/efc/
eefc_wpmr.rs

1#[doc = "Register `EEFC_WPMR` reader"]
2pub struct R(crate::R<EEFC_WPMR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<EEFC_WPMR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<EEFC_WPMR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<EEFC_WPMR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `EEFC_WPMR` writer"]
17pub struct W(crate::W<EEFC_WPMR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<EEFC_WPMR_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<EEFC_WPMR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<EEFC_WPMR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `WPEN` reader - Write Protection Enable"]
38pub struct WPEN_R(crate::FieldReader<bool, bool>);
39impl WPEN_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: bool) -> Self {
42        WPEN_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for WPEN_R {
46    type Target = crate::FieldReader<bool, bool>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `WPEN` writer - Write Protection Enable"]
53pub struct WPEN_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> WPEN_W<'a> {
57    #[doc = r"Sets the field bit"]
58    #[inline(always)]
59    pub fn set_bit(self) -> &'a mut W {
60        self.bit(true)
61    }
62    #[doc = r"Clears the field bit"]
63    #[inline(always)]
64    pub fn clear_bit(self) -> &'a mut W {
65        self.bit(false)
66    }
67    #[doc = r"Writes raw bits to the field"]
68    #[inline(always)]
69    pub fn bit(self, value: bool) -> &'a mut W {
70        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
71        self.w
72    }
73}
74#[doc = "Write Protection Key\n\nValue on reset: 0"]
75#[derive(Clone, Copy, Debug, PartialEq)]
76#[repr(u32)]
77pub enum WPKEY_A {
78    #[doc = "4539971: Writing any other value in this field aborts the write operation.Always reads as 0."]
79    PASSWD = 4539971,
80}
81impl From<WPKEY_A> for u32 {
82    #[inline(always)]
83    fn from(variant: WPKEY_A) -> Self {
84        variant as _
85    }
86}
87#[doc = "Field `WPKEY` reader - Write Protection Key"]
88pub struct WPKEY_R(crate::FieldReader<u32, WPKEY_A>);
89impl WPKEY_R {
90    #[inline(always)]
91    pub(crate) fn new(bits: u32) -> Self {
92        WPKEY_R(crate::FieldReader::new(bits))
93    }
94    #[doc = r"Get enumerated values variant"]
95    #[inline(always)]
96    pub fn variant(&self) -> Option<WPKEY_A> {
97        match self.bits {
98            4539971 => Some(WPKEY_A::PASSWD),
99            _ => None,
100        }
101    }
102    #[doc = "Checks if the value of the field is `PASSWD`"]
103    #[inline(always)]
104    pub fn is_passwd(&self) -> bool {
105        **self == WPKEY_A::PASSWD
106    }
107}
108impl core::ops::Deref for WPKEY_R {
109    type Target = crate::FieldReader<u32, WPKEY_A>;
110    #[inline(always)]
111    fn deref(&self) -> &Self::Target {
112        &self.0
113    }
114}
115#[doc = "Field `WPKEY` writer - Write Protection Key"]
116pub struct WPKEY_W<'a> {
117    w: &'a mut W,
118}
119impl<'a> WPKEY_W<'a> {
120    #[doc = r"Writes `variant` to the field"]
121    #[inline(always)]
122    pub fn variant(self, variant: WPKEY_A) -> &'a mut W {
123        unsafe { self.bits(variant.into()) }
124    }
125    #[doc = "Writing any other value in this field aborts the write operation.Always reads as 0."]
126    #[inline(always)]
127    pub fn passwd(self) -> &'a mut W {
128        self.variant(WPKEY_A::PASSWD)
129    }
130    #[doc = r"Writes raw bits to the field"]
131    #[inline(always)]
132    pub unsafe fn bits(self, value: u32) -> &'a mut W {
133        self.w.bits = (self.w.bits & !(0x00ff_ffff << 8)) | ((value as u32 & 0x00ff_ffff) << 8);
134        self.w
135    }
136}
137impl R {
138    #[doc = "Bit 0 - Write Protection Enable"]
139    #[inline(always)]
140    pub fn wpen(&self) -> WPEN_R {
141        WPEN_R::new((self.bits & 0x01) != 0)
142    }
143    #[doc = "Bits 8:31 - Write Protection Key"]
144    #[inline(always)]
145    pub fn wpkey(&self) -> WPKEY_R {
146        WPKEY_R::new(((self.bits >> 8) & 0x00ff_ffff) as u32)
147    }
148}
149impl W {
150    #[doc = "Bit 0 - Write Protection Enable"]
151    #[inline(always)]
152    pub fn wpen(&mut self) -> WPEN_W {
153        WPEN_W { w: self }
154    }
155    #[doc = "Bits 8:31 - Write Protection Key"]
156    #[inline(always)]
157    pub fn wpkey(&mut self) -> WPKEY_W {
158        WPKEY_W { w: self }
159    }
160    #[doc = "Writes raw bits to the register."]
161    #[inline(always)]
162    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
163        self.0.bits(bits);
164        self
165    }
166}
167#[doc = "Write Protection Mode Register\n\nThis 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).\n\nFor information about available fields see [eefc_wpmr](index.html) module"]
168pub struct EEFC_WPMR_SPEC;
169impl crate::RegisterSpec for EEFC_WPMR_SPEC {
170    type Ux = u32;
171}
172#[doc = "`read()` method returns [eefc_wpmr::R](R) reader structure"]
173impl crate::Readable for EEFC_WPMR_SPEC {
174    type Reader = R;
175}
176#[doc = "`write(|w| ..)` method takes [eefc_wpmr::W](W) writer structure"]
177impl crate::Writable for EEFC_WPMR_SPEC {
178    type Writer = W;
179}
180#[doc = "`reset()` method sets EEFC_WPMR to value 0"]
181impl crate::Resettable for EEFC_WPMR_SPEC {
182    #[inline(always)]
183    fn reset_value() -> Self::Ux {
184        0
185    }
186}