s32k144_pac/aips/
opacrg.rs

1#[doc = "Register `OPACRG` reader"]
2pub struct R(crate::R<OPACRG_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<OPACRG_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<OPACRG_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<OPACRG_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `OPACRG` writer"]
17pub struct W(crate::W<OPACRG_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<OPACRG_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<OPACRG_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<OPACRG_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Trusted Protect\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum TP2_A {
40    #[doc = "0: Accesses from an untrusted master are allowed."]
41    _0 = 0,
42    #[doc = "1: Accesses from an untrusted master are not allowed."]
43    _1 = 1,
44}
45impl From<TP2_A> for bool {
46    #[inline(always)]
47    fn from(variant: TP2_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `TP2` reader - Trusted Protect"]
52pub struct TP2_R(crate::FieldReader<bool, TP2_A>);
53impl TP2_R {
54    #[inline(always)]
55    pub(crate) fn new(bits: bool) -> Self {
56        TP2_R(crate::FieldReader::new(bits))
57    }
58    #[doc = r"Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> TP2_A {
61        match self.bits {
62            false => TP2_A::_0,
63            true => TP2_A::_1,
64        }
65    }
66    #[doc = "Checks if the value of the field is `_0`"]
67    #[inline(always)]
68    pub fn is_0(&self) -> bool {
69        **self == TP2_A::_0
70    }
71    #[doc = "Checks if the value of the field is `_1`"]
72    #[inline(always)]
73    pub fn is_1(&self) -> bool {
74        **self == TP2_A::_1
75    }
76}
77impl core::ops::Deref for TP2_R {
78    type Target = crate::FieldReader<bool, TP2_A>;
79    #[inline(always)]
80    fn deref(&self) -> &Self::Target {
81        &self.0
82    }
83}
84#[doc = "Field `TP2` writer - Trusted Protect"]
85pub struct TP2_W<'a> {
86    w: &'a mut W,
87}
88impl<'a> TP2_W<'a> {
89    #[doc = r"Writes `variant` to the field"]
90    #[inline(always)]
91    pub fn variant(self, variant: TP2_A) -> &'a mut W {
92        self.bit(variant.into())
93    }
94    #[doc = "Accesses from an untrusted master are allowed."]
95    #[inline(always)]
96    pub fn _0(self) -> &'a mut W {
97        self.variant(TP2_A::_0)
98    }
99    #[doc = "Accesses from an untrusted master are not allowed."]
100    #[inline(always)]
101    pub fn _1(self) -> &'a mut W {
102        self.variant(TP2_A::_1)
103    }
104    #[doc = r"Sets the field bit"]
105    #[inline(always)]
106    pub fn set_bit(self) -> &'a mut W {
107        self.bit(true)
108    }
109    #[doc = r"Clears the field bit"]
110    #[inline(always)]
111    pub fn clear_bit(self) -> &'a mut W {
112        self.bit(false)
113    }
114    #[doc = r"Writes raw bits to the field"]
115    #[inline(always)]
116    pub fn bit(self, value: bool) -> &'a mut W {
117        self.w.bits = (self.w.bits & !(0x01 << 20)) | ((value as u32 & 0x01) << 20);
118        self.w
119    }
120}
121#[doc = "Write Protect\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq)]
123pub enum WP2_A {
124    #[doc = "0: This peripheral allows write accesses."]
125    _0 = 0,
126    #[doc = "1: This peripheral is write protected."]
127    _1 = 1,
128}
129impl From<WP2_A> for bool {
130    #[inline(always)]
131    fn from(variant: WP2_A) -> Self {
132        variant as u8 != 0
133    }
134}
135#[doc = "Field `WP2` reader - Write Protect"]
136pub struct WP2_R(crate::FieldReader<bool, WP2_A>);
137impl WP2_R {
138    #[inline(always)]
139    pub(crate) fn new(bits: bool) -> Self {
140        WP2_R(crate::FieldReader::new(bits))
141    }
142    #[doc = r"Get enumerated values variant"]
143    #[inline(always)]
144    pub fn variant(&self) -> WP2_A {
145        match self.bits {
146            false => WP2_A::_0,
147            true => WP2_A::_1,
148        }
149    }
150    #[doc = "Checks if the value of the field is `_0`"]
151    #[inline(always)]
152    pub fn is_0(&self) -> bool {
153        **self == WP2_A::_0
154    }
155    #[doc = "Checks if the value of the field is `_1`"]
156    #[inline(always)]
157    pub fn is_1(&self) -> bool {
158        **self == WP2_A::_1
159    }
160}
161impl core::ops::Deref for WP2_R {
162    type Target = crate::FieldReader<bool, WP2_A>;
163    #[inline(always)]
164    fn deref(&self) -> &Self::Target {
165        &self.0
166    }
167}
168#[doc = "Field `WP2` writer - Write Protect"]
169pub struct WP2_W<'a> {
170    w: &'a mut W,
171}
172impl<'a> WP2_W<'a> {
173    #[doc = r"Writes `variant` to the field"]
174    #[inline(always)]
175    pub fn variant(self, variant: WP2_A) -> &'a mut W {
176        self.bit(variant.into())
177    }
178    #[doc = "This peripheral allows write accesses."]
179    #[inline(always)]
180    pub fn _0(self) -> &'a mut W {
181        self.variant(WP2_A::_0)
182    }
183    #[doc = "This peripheral is write protected."]
184    #[inline(always)]
185    pub fn _1(self) -> &'a mut W {
186        self.variant(WP2_A::_1)
187    }
188    #[doc = r"Sets the field bit"]
189    #[inline(always)]
190    pub fn set_bit(self) -> &'a mut W {
191        self.bit(true)
192    }
193    #[doc = r"Clears the field bit"]
194    #[inline(always)]
195    pub fn clear_bit(self) -> &'a mut W {
196        self.bit(false)
197    }
198    #[doc = r"Writes raw bits to the field"]
199    #[inline(always)]
200    pub fn bit(self, value: bool) -> &'a mut W {
201        self.w.bits = (self.w.bits & !(0x01 << 21)) | ((value as u32 & 0x01) << 21);
202        self.w
203    }
204}
205#[doc = "Supervisor Protect\n\nValue on reset: 1"]
206#[derive(Clone, Copy, Debug, PartialEq)]
207pub enum SP2_A {
208    #[doc = "0: This peripheral does not require supervisor privilege level for accesses."]
209    _0 = 0,
210    #[doc = "1: This peripheral requires supervisor privilege level for accesses."]
211    _1 = 1,
212}
213impl From<SP2_A> for bool {
214    #[inline(always)]
215    fn from(variant: SP2_A) -> Self {
216        variant as u8 != 0
217    }
218}
219#[doc = "Field `SP2` reader - Supervisor Protect"]
220pub struct SP2_R(crate::FieldReader<bool, SP2_A>);
221impl SP2_R {
222    #[inline(always)]
223    pub(crate) fn new(bits: bool) -> Self {
224        SP2_R(crate::FieldReader::new(bits))
225    }
226    #[doc = r"Get enumerated values variant"]
227    #[inline(always)]
228    pub fn variant(&self) -> SP2_A {
229        match self.bits {
230            false => SP2_A::_0,
231            true => SP2_A::_1,
232        }
233    }
234    #[doc = "Checks if the value of the field is `_0`"]
235    #[inline(always)]
236    pub fn is_0(&self) -> bool {
237        **self == SP2_A::_0
238    }
239    #[doc = "Checks if the value of the field is `_1`"]
240    #[inline(always)]
241    pub fn is_1(&self) -> bool {
242        **self == SP2_A::_1
243    }
244}
245impl core::ops::Deref for SP2_R {
246    type Target = crate::FieldReader<bool, SP2_A>;
247    #[inline(always)]
248    fn deref(&self) -> &Self::Target {
249        &self.0
250    }
251}
252#[doc = "Field `SP2` writer - Supervisor Protect"]
253pub struct SP2_W<'a> {
254    w: &'a mut W,
255}
256impl<'a> SP2_W<'a> {
257    #[doc = r"Writes `variant` to the field"]
258    #[inline(always)]
259    pub fn variant(self, variant: SP2_A) -> &'a mut W {
260        self.bit(variant.into())
261    }
262    #[doc = "This peripheral does not require supervisor privilege level for accesses."]
263    #[inline(always)]
264    pub fn _0(self) -> &'a mut W {
265        self.variant(SP2_A::_0)
266    }
267    #[doc = "This peripheral requires supervisor privilege level for accesses."]
268    #[inline(always)]
269    pub fn _1(self) -> &'a mut W {
270        self.variant(SP2_A::_1)
271    }
272    #[doc = r"Sets the field bit"]
273    #[inline(always)]
274    pub fn set_bit(self) -> &'a mut W {
275        self.bit(true)
276    }
277    #[doc = r"Clears the field bit"]
278    #[inline(always)]
279    pub fn clear_bit(self) -> &'a mut W {
280        self.bit(false)
281    }
282    #[doc = r"Writes raw bits to the field"]
283    #[inline(always)]
284    pub fn bit(self, value: bool) -> &'a mut W {
285        self.w.bits = (self.w.bits & !(0x01 << 22)) | ((value as u32 & 0x01) << 22);
286        self.w
287    }
288}
289impl R {
290    #[doc = "Bit 20 - Trusted Protect"]
291    #[inline(always)]
292    pub fn tp2(&self) -> TP2_R {
293        TP2_R::new(((self.bits >> 20) & 0x01) != 0)
294    }
295    #[doc = "Bit 21 - Write Protect"]
296    #[inline(always)]
297    pub fn wp2(&self) -> WP2_R {
298        WP2_R::new(((self.bits >> 21) & 0x01) != 0)
299    }
300    #[doc = "Bit 22 - Supervisor Protect"]
301    #[inline(always)]
302    pub fn sp2(&self) -> SP2_R {
303        SP2_R::new(((self.bits >> 22) & 0x01) != 0)
304    }
305}
306impl W {
307    #[doc = "Bit 20 - Trusted Protect"]
308    #[inline(always)]
309    pub fn tp2(&mut self) -> TP2_W {
310        TP2_W { w: self }
311    }
312    #[doc = "Bit 21 - Write Protect"]
313    #[inline(always)]
314    pub fn wp2(&mut self) -> WP2_W {
315        WP2_W { w: self }
316    }
317    #[doc = "Bit 22 - Supervisor Protect"]
318    #[inline(always)]
319    pub fn sp2(&mut self) -> SP2_W {
320        SP2_W { w: self }
321    }
322    #[doc = "Writes raw bits to the register."]
323    #[inline(always)]
324    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
325        self.0.bits(bits);
326        self
327    }
328}
329#[doc = "Off-Platform Peripheral Access Control 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 [opacrg](index.html) module"]
330pub struct OPACRG_SPEC;
331impl crate::RegisterSpec for OPACRG_SPEC {
332    type Ux = u32;
333}
334#[doc = "`read()` method returns [opacrg::R](R) reader structure"]
335impl crate::Readable for OPACRG_SPEC {
336    type Reader = R;
337}
338#[doc = "`write(|w| ..)` method takes [opacrg::W](W) writer structure"]
339impl crate::Writable for OPACRG_SPEC {
340    type Writer = W;
341}
342#[doc = "`reset()` method sets OPACRG to value 0x0040_0000"]
343impl crate::Resettable for OPACRG_SPEC {
344    #[inline(always)]
345    fn reset_value() -> Self::Ux {
346        0x0040_0000
347    }
348}