lpc55_pac/ahb_secure_ctrl/
sec_ctrl_flash_rom_slave_rule.rs

1#[doc = "Register `SEC_CTRL_FLASH_ROM_SLAVE_RULE` reader"]
2pub struct R(crate::R<SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `SEC_CTRL_FLASH_ROM_SLAVE_RULE` writer"]
17pub struct W(crate::W<SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<SEC_CTRL_FLASH_ROM_SLAVE_RULE_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<SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Security access rules for the whole FLASH : 0x0000_0000 - 0x0009_FFFF\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum FLASH_RULE_A {
41    #[doc = "0: Non-secure and Non-priviledge user access allowed."]
42    ENUM_NS_NP = 0,
43    #[doc = "1: Non-secure and Privilege access allowed."]
44    ENUM_NS_P = 1,
45    #[doc = "2: Secure and Non-priviledge user access allowed."]
46    ENUM_S_NP = 2,
47    #[doc = "3: Secure and Priviledge user access allowed."]
48    ENUM_S_P = 3,
49}
50impl From<FLASH_RULE_A> for u8 {
51    #[inline(always)]
52    fn from(variant: FLASH_RULE_A) -> Self {
53        variant as _
54    }
55}
56#[doc = "Field `FLASH_RULE` reader - Security access rules for the whole FLASH : 0x0000_0000 - 0x0009_FFFF"]
57pub struct FLASH_RULE_R(crate::FieldReader<u8, FLASH_RULE_A>);
58impl FLASH_RULE_R {
59    #[inline(always)]
60    pub(crate) fn new(bits: u8) -> Self {
61        FLASH_RULE_R(crate::FieldReader::new(bits))
62    }
63    #[doc = r"Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> FLASH_RULE_A {
66        match self.bits {
67            0 => FLASH_RULE_A::ENUM_NS_NP,
68            1 => FLASH_RULE_A::ENUM_NS_P,
69            2 => FLASH_RULE_A::ENUM_S_NP,
70            3 => FLASH_RULE_A::ENUM_S_P,
71            _ => unreachable!(),
72        }
73    }
74    #[doc = "Checks if the value of the field is `ENUM_NS_NP`"]
75    #[inline(always)]
76    pub fn is_enum_ns_np(&self) -> bool {
77        **self == FLASH_RULE_A::ENUM_NS_NP
78    }
79    #[doc = "Checks if the value of the field is `ENUM_NS_P`"]
80    #[inline(always)]
81    pub fn is_enum_ns_p(&self) -> bool {
82        **self == FLASH_RULE_A::ENUM_NS_P
83    }
84    #[doc = "Checks if the value of the field is `ENUM_S_NP`"]
85    #[inline(always)]
86    pub fn is_enum_s_np(&self) -> bool {
87        **self == FLASH_RULE_A::ENUM_S_NP
88    }
89    #[doc = "Checks if the value of the field is `ENUM_S_P`"]
90    #[inline(always)]
91    pub fn is_enum_s_p(&self) -> bool {
92        **self == FLASH_RULE_A::ENUM_S_P
93    }
94}
95impl core::ops::Deref for FLASH_RULE_R {
96    type Target = crate::FieldReader<u8, FLASH_RULE_A>;
97    #[inline(always)]
98    fn deref(&self) -> &Self::Target {
99        &self.0
100    }
101}
102#[doc = "Field `FLASH_RULE` writer - Security access rules for the whole FLASH : 0x0000_0000 - 0x0009_FFFF"]
103pub struct FLASH_RULE_W<'a> {
104    w: &'a mut W,
105}
106impl<'a> FLASH_RULE_W<'a> {
107    #[doc = r"Writes `variant` to the field"]
108    #[inline(always)]
109    pub fn variant(self, variant: FLASH_RULE_A) -> &'a mut W {
110        self.bits(variant.into())
111    }
112    #[doc = "Non-secure and Non-priviledge user access allowed."]
113    #[inline(always)]
114    pub fn enum_ns_np(self) -> &'a mut W {
115        self.variant(FLASH_RULE_A::ENUM_NS_NP)
116    }
117    #[doc = "Non-secure and Privilege access allowed."]
118    #[inline(always)]
119    pub fn enum_ns_p(self) -> &'a mut W {
120        self.variant(FLASH_RULE_A::ENUM_NS_P)
121    }
122    #[doc = "Secure and Non-priviledge user access allowed."]
123    #[inline(always)]
124    pub fn enum_s_np(self) -> &'a mut W {
125        self.variant(FLASH_RULE_A::ENUM_S_NP)
126    }
127    #[doc = "Secure and Priviledge user access allowed."]
128    #[inline(always)]
129    pub fn enum_s_p(self) -> &'a mut W {
130        self.variant(FLASH_RULE_A::ENUM_S_P)
131    }
132    #[doc = r"Writes raw bits to the field"]
133    #[inline(always)]
134    pub fn bits(self, value: u8) -> &'a mut W {
135        self.w.bits = (self.w.bits & !0x03) | (value as u32 & 0x03);
136        self.w
137    }
138}
139#[doc = "Security access rules for the whole ROM : 0x0300_0000 - 0x0301_FFFF\n\nValue on reset: 0"]
140#[derive(Clone, Copy, Debug, PartialEq)]
141#[repr(u8)]
142pub enum ROM_RULE_A {
143    #[doc = "0: Non-secure and Non-priviledge user access allowed."]
144    ENUM_NS_NP = 0,
145    #[doc = "1: Non-secure and Privilege access allowed."]
146    ENUM_NS_P = 1,
147    #[doc = "2: Secure and Non-priviledge user access allowed."]
148    ENUM_S_NP = 2,
149    #[doc = "3: Secure and Priviledge user access allowed."]
150    ENUM_S_P = 3,
151}
152impl From<ROM_RULE_A> for u8 {
153    #[inline(always)]
154    fn from(variant: ROM_RULE_A) -> Self {
155        variant as _
156    }
157}
158#[doc = "Field `ROM_RULE` reader - Security access rules for the whole ROM : 0x0300_0000 - 0x0301_FFFF"]
159pub struct ROM_RULE_R(crate::FieldReader<u8, ROM_RULE_A>);
160impl ROM_RULE_R {
161    #[inline(always)]
162    pub(crate) fn new(bits: u8) -> Self {
163        ROM_RULE_R(crate::FieldReader::new(bits))
164    }
165    #[doc = r"Get enumerated values variant"]
166    #[inline(always)]
167    pub fn variant(&self) -> ROM_RULE_A {
168        match self.bits {
169            0 => ROM_RULE_A::ENUM_NS_NP,
170            1 => ROM_RULE_A::ENUM_NS_P,
171            2 => ROM_RULE_A::ENUM_S_NP,
172            3 => ROM_RULE_A::ENUM_S_P,
173            _ => unreachable!(),
174        }
175    }
176    #[doc = "Checks if the value of the field is `ENUM_NS_NP`"]
177    #[inline(always)]
178    pub fn is_enum_ns_np(&self) -> bool {
179        **self == ROM_RULE_A::ENUM_NS_NP
180    }
181    #[doc = "Checks if the value of the field is `ENUM_NS_P`"]
182    #[inline(always)]
183    pub fn is_enum_ns_p(&self) -> bool {
184        **self == ROM_RULE_A::ENUM_NS_P
185    }
186    #[doc = "Checks if the value of the field is `ENUM_S_NP`"]
187    #[inline(always)]
188    pub fn is_enum_s_np(&self) -> bool {
189        **self == ROM_RULE_A::ENUM_S_NP
190    }
191    #[doc = "Checks if the value of the field is `ENUM_S_P`"]
192    #[inline(always)]
193    pub fn is_enum_s_p(&self) -> bool {
194        **self == ROM_RULE_A::ENUM_S_P
195    }
196}
197impl core::ops::Deref for ROM_RULE_R {
198    type Target = crate::FieldReader<u8, ROM_RULE_A>;
199    #[inline(always)]
200    fn deref(&self) -> &Self::Target {
201        &self.0
202    }
203}
204#[doc = "Field `ROM_RULE` writer - Security access rules for the whole ROM : 0x0300_0000 - 0x0301_FFFF"]
205pub struct ROM_RULE_W<'a> {
206    w: &'a mut W,
207}
208impl<'a> ROM_RULE_W<'a> {
209    #[doc = r"Writes `variant` to the field"]
210    #[inline(always)]
211    pub fn variant(self, variant: ROM_RULE_A) -> &'a mut W {
212        self.bits(variant.into())
213    }
214    #[doc = "Non-secure and Non-priviledge user access allowed."]
215    #[inline(always)]
216    pub fn enum_ns_np(self) -> &'a mut W {
217        self.variant(ROM_RULE_A::ENUM_NS_NP)
218    }
219    #[doc = "Non-secure and Privilege access allowed."]
220    #[inline(always)]
221    pub fn enum_ns_p(self) -> &'a mut W {
222        self.variant(ROM_RULE_A::ENUM_NS_P)
223    }
224    #[doc = "Secure and Non-priviledge user access allowed."]
225    #[inline(always)]
226    pub fn enum_s_np(self) -> &'a mut W {
227        self.variant(ROM_RULE_A::ENUM_S_NP)
228    }
229    #[doc = "Secure and Priviledge user access allowed."]
230    #[inline(always)]
231    pub fn enum_s_p(self) -> &'a mut W {
232        self.variant(ROM_RULE_A::ENUM_S_P)
233    }
234    #[doc = r"Writes raw bits to the field"]
235    #[inline(always)]
236    pub fn bits(self, value: u8) -> &'a mut W {
237        self.w.bits = (self.w.bits & !(0x03 << 4)) | ((value as u32 & 0x03) << 4);
238        self.w
239    }
240}
241impl R {
242    #[doc = "Bits 0:1 - Security access rules for the whole FLASH : 0x0000_0000 - 0x0009_FFFF"]
243    #[inline(always)]
244    pub fn flash_rule(&self) -> FLASH_RULE_R {
245        FLASH_RULE_R::new((self.bits & 0x03) as u8)
246    }
247    #[doc = "Bits 4:5 - Security access rules for the whole ROM : 0x0300_0000 - 0x0301_FFFF"]
248    #[inline(always)]
249    pub fn rom_rule(&self) -> ROM_RULE_R {
250        ROM_RULE_R::new(((self.bits >> 4) & 0x03) as u8)
251    }
252}
253impl W {
254    #[doc = "Bits 0:1 - Security access rules for the whole FLASH : 0x0000_0000 - 0x0009_FFFF"]
255    #[inline(always)]
256    pub fn flash_rule(&mut self) -> FLASH_RULE_W {
257        FLASH_RULE_W { w: self }
258    }
259    #[doc = "Bits 4:5 - Security access rules for the whole ROM : 0x0300_0000 - 0x0301_FFFF"]
260    #[inline(always)]
261    pub fn rom_rule(&mut self) -> ROM_RULE_W {
262        ROM_RULE_W { w: self }
263    }
264    #[doc = "Writes raw bits to the register."]
265    #[inline(always)]
266    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
267        self.0.bits(bits);
268        self
269    }
270}
271#[doc = "Security access rules for Flash and ROM slaves.\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 [sec_ctrl_flash_rom_slave_rule](index.html) module"]
272pub struct SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC;
273impl crate::RegisterSpec for SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC {
274    type Ux = u32;
275}
276#[doc = "`read()` method returns [sec_ctrl_flash_rom_slave_rule::R](R) reader structure"]
277impl crate::Readable for SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC {
278    type Reader = R;
279}
280#[doc = "`write(|w| ..)` method takes [sec_ctrl_flash_rom_slave_rule::W](W) writer structure"]
281impl crate::Writable for SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC {
282    type Writer = W;
283}
284#[doc = "`reset()` method sets SEC_CTRL_FLASH_ROM_SLAVE_RULE to value 0"]
285impl crate::Resettable for SEC_CTRL_FLASH_ROM_SLAVE_RULE_SPEC {
286    #[inline(always)]
287    fn reset_value() -> Self::Ux {
288        0
289    }
290}