nrf5340_app_pac/spu_s/extdomain/
perm.rs

1#[doc = "Register `PERM` reader"]
2pub struct R(crate::R<PERM_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PERM_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PERM_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PERM_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PERM` writer"]
17pub struct W(crate::W<PERM_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PERM_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<PERM_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PERM_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `SECUREMAPPING` reader - Define configuration capabilities for TrustZone Cortex-M secure attribute"]
38pub type SECUREMAPPING_R = crate::FieldReader<u8, SECUREMAPPING_A>;
39#[doc = "Define configuration capabilities for TrustZone Cortex-M secure attribute\n\nValue on reset: 2"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41#[repr(u8)]
42pub enum SECUREMAPPING_A {
43    #[doc = "0: The bus access from this external domain always have the non-secure attribute set"]
44    NON_SECURE = 0,
45    #[doc = "1: The bus access from this external domain always have the secure attribute set"]
46    SECURE = 1,
47    #[doc = "2: Non-secure or secure attribute for bus access from this domain is defined by the EXTDOMAIN\\[n\\].PERM register"]
48    USER_SELECTABLE = 2,
49}
50impl From<SECUREMAPPING_A> for u8 {
51    #[inline(always)]
52    fn from(variant: SECUREMAPPING_A) -> Self {
53        variant as _
54    }
55}
56impl SECUREMAPPING_R {
57    #[doc = "Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> Option<SECUREMAPPING_A> {
60        match self.bits {
61            0 => Some(SECUREMAPPING_A::NON_SECURE),
62            1 => Some(SECUREMAPPING_A::SECURE),
63            2 => Some(SECUREMAPPING_A::USER_SELECTABLE),
64            _ => None,
65        }
66    }
67    #[doc = "Checks if the value of the field is `NON_SECURE`"]
68    #[inline(always)]
69    pub fn is_non_secure(&self) -> bool {
70        *self == SECUREMAPPING_A::NON_SECURE
71    }
72    #[doc = "Checks if the value of the field is `SECURE`"]
73    #[inline(always)]
74    pub fn is_secure(&self) -> bool {
75        *self == SECUREMAPPING_A::SECURE
76    }
77    #[doc = "Checks if the value of the field is `USER_SELECTABLE`"]
78    #[inline(always)]
79    pub fn is_user_selectable(&self) -> bool {
80        *self == SECUREMAPPING_A::USER_SELECTABLE
81    }
82}
83#[doc = "Field `SECATTR` reader - Peripheral security mapping"]
84pub type SECATTR_R = crate::BitReader<SECATTR_A>;
85#[doc = "Peripheral security mapping\n\nValue on reset: 0"]
86#[derive(Clone, Copy, Debug, PartialEq)]
87pub enum SECATTR_A {
88    #[doc = "0: Bus accesses from this domain have the non-secure attribute set"]
89    NON_SECURE = 0,
90    #[doc = "1: Bus accesses from this domain have secure attribute set"]
91    SECURE = 1,
92}
93impl From<SECATTR_A> for bool {
94    #[inline(always)]
95    fn from(variant: SECATTR_A) -> Self {
96        variant as u8 != 0
97    }
98}
99impl SECATTR_R {
100    #[doc = "Get enumerated values variant"]
101    #[inline(always)]
102    pub fn variant(&self) -> SECATTR_A {
103        match self.bits {
104            false => SECATTR_A::NON_SECURE,
105            true => SECATTR_A::SECURE,
106        }
107    }
108    #[doc = "Checks if the value of the field is `NON_SECURE`"]
109    #[inline(always)]
110    pub fn is_non_secure(&self) -> bool {
111        *self == SECATTR_A::NON_SECURE
112    }
113    #[doc = "Checks if the value of the field is `SECURE`"]
114    #[inline(always)]
115    pub fn is_secure(&self) -> bool {
116        *self == SECATTR_A::SECURE
117    }
118}
119#[doc = "Field `SECATTR` writer - Peripheral security mapping"]
120pub type SECATTR_W<'a, const O: u8> = crate::BitWriter<'a, u32, PERM_SPEC, SECATTR_A, O>;
121impl<'a, const O: u8> SECATTR_W<'a, O> {
122    #[doc = "Bus accesses from this domain have the non-secure attribute set"]
123    #[inline(always)]
124    pub fn non_secure(self) -> &'a mut W {
125        self.variant(SECATTR_A::NON_SECURE)
126    }
127    #[doc = "Bus accesses from this domain have secure attribute set"]
128    #[inline(always)]
129    pub fn secure(self) -> &'a mut W {
130        self.variant(SECATTR_A::SECURE)
131    }
132}
133#[doc = "Field `LOCK` reader - "]
134pub type LOCK_R = crate::BitReader<LOCK_A>;
135#[doc = "\n\nValue on reset: 0"]
136#[derive(Clone, Copy, Debug, PartialEq)]
137pub enum LOCK_A {
138    #[doc = "0: This register can be updated"]
139    UNLOCKED = 0,
140    #[doc = "1: The content of this register can't be changed until the next reset"]
141    LOCKED = 1,
142}
143impl From<LOCK_A> for bool {
144    #[inline(always)]
145    fn from(variant: LOCK_A) -> Self {
146        variant as u8 != 0
147    }
148}
149impl LOCK_R {
150    #[doc = "Get enumerated values variant"]
151    #[inline(always)]
152    pub fn variant(&self) -> LOCK_A {
153        match self.bits {
154            false => LOCK_A::UNLOCKED,
155            true => LOCK_A::LOCKED,
156        }
157    }
158    #[doc = "Checks if the value of the field is `UNLOCKED`"]
159    #[inline(always)]
160    pub fn is_unlocked(&self) -> bool {
161        *self == LOCK_A::UNLOCKED
162    }
163    #[doc = "Checks if the value of the field is `LOCKED`"]
164    #[inline(always)]
165    pub fn is_locked(&self) -> bool {
166        *self == LOCK_A::LOCKED
167    }
168}
169#[doc = "Field `LOCK` writer - "]
170pub type LOCK_W<'a, const O: u8> = crate::BitWriter<'a, u32, PERM_SPEC, LOCK_A, O>;
171impl<'a, const O: u8> LOCK_W<'a, O> {
172    #[doc = "This register can be updated"]
173    #[inline(always)]
174    pub fn unlocked(self) -> &'a mut W {
175        self.variant(LOCK_A::UNLOCKED)
176    }
177    #[doc = "The content of this register can't be changed until the next reset"]
178    #[inline(always)]
179    pub fn locked(self) -> &'a mut W {
180        self.variant(LOCK_A::LOCKED)
181    }
182}
183impl R {
184    #[doc = "Bits 0:1 - Define configuration capabilities for TrustZone Cortex-M secure attribute"]
185    #[inline(always)]
186    pub fn securemapping(&self) -> SECUREMAPPING_R {
187        SECUREMAPPING_R::new((self.bits & 3) as u8)
188    }
189    #[doc = "Bit 4 - Peripheral security mapping"]
190    #[inline(always)]
191    pub fn secattr(&self) -> SECATTR_R {
192        SECATTR_R::new(((self.bits >> 4) & 1) != 0)
193    }
194    #[doc = "Bit 8"]
195    #[inline(always)]
196    pub fn lock(&self) -> LOCK_R {
197        LOCK_R::new(((self.bits >> 8) & 1) != 0)
198    }
199}
200impl W {
201    #[doc = "Bit 4 - Peripheral security mapping"]
202    #[inline(always)]
203    pub fn secattr(&mut self) -> SECATTR_W<4> {
204        SECATTR_W::new(self)
205    }
206    #[doc = "Bit 8"]
207    #[inline(always)]
208    pub fn lock(&mut self) -> LOCK_W<8> {
209        LOCK_W::new(self)
210    }
211    #[doc = "Writes raw bits to the register."]
212    #[inline(always)]
213    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
214        self.0.bits(bits);
215        self
216    }
217}
218#[doc = "Description cluster: Access for bus access generated from the external domain n List capabilities of the external domain n\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 [perm](index.html) module"]
219pub struct PERM_SPEC;
220impl crate::RegisterSpec for PERM_SPEC {
221    type Ux = u32;
222}
223#[doc = "`read()` method returns [perm::R](R) reader structure"]
224impl crate::Readable for PERM_SPEC {
225    type Reader = R;
226}
227#[doc = "`write(|w| ..)` method takes [perm::W](W) writer structure"]
228impl crate::Writable for PERM_SPEC {
229    type Writer = W;
230}
231#[doc = "`reset()` method sets PERM to value 0x02"]
232impl crate::Resettable for PERM_SPEC {
233    #[inline(always)]
234    fn reset_value() -> Self::Ux {
235        0x02
236    }
237}