corstone300_pac/sau/
rnr.rs

1// Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
2//
3// SPDX-License-Identifier: MIT
4
5#[doc = "Register `RNR` reader"]
6pub struct R(crate::R<RNR_SPEC>);
7impl core::ops::Deref for R {
8    type Target = crate::R<RNR_SPEC>;
9    #[inline(always)]
10    fn deref(&self) -> &Self::Target {
11        &self.0
12    }
13}
14impl From<crate::R<RNR_SPEC>> for R {
15    #[inline(always)]
16    fn from(reader: crate::R<RNR_SPEC>) -> Self {
17        R(reader)
18    }
19}
20#[doc = "Register `RNR` writer"]
21pub struct W(crate::W<RNR_SPEC>);
22impl core::ops::Deref for W {
23    type Target = crate::W<RNR_SPEC>;
24    #[inline(always)]
25    fn deref(&self) -> &Self::Target {
26        &self.0
27    }
28}
29impl core::ops::DerefMut for W {
30    #[inline(always)]
31    fn deref_mut(&mut self) -> &mut Self::Target {
32        &mut self.0
33    }
34}
35impl From<crate::W<RNR_SPEC>> for W {
36    #[inline(always)]
37    fn from(writer: crate::W<RNR_SPEC>) -> Self {
38        W(writer)
39    }
40}
41#[doc = "Field `REGION` reader - Currently selected SAU region"]
42pub type REGION_R = crate::FieldReader<u8, REGION_A>;
43#[doc = "Currently selected SAU region\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum REGION_A {
47    #[doc = "0: Select SAU Region 0"]
48    SAU_REGION_0 = 0,
49    #[doc = "1: Select SAU Region 1"]
50    SAU_REGION_1 = 1,
51    #[doc = "2: Select SAU Region 2"]
52    SAU_REGION_2 = 2,
53    #[doc = "3: Select SAU Region 3"]
54    SAU_REGION_3 = 3,
55}
56impl From<REGION_A> for u8 {
57    #[inline(always)]
58    fn from(variant: REGION_A) -> Self {
59        variant as _
60    }
61}
62impl REGION_R {
63    #[doc = "Get enumerated values variant"]
64    #[inline(always)]
65    pub fn variant(&self) -> Option<REGION_A> {
66        match self.bits {
67            0 => Some(REGION_A::SAU_REGION_0),
68            1 => Some(REGION_A::SAU_REGION_1),
69            2 => Some(REGION_A::SAU_REGION_2),
70            3 => Some(REGION_A::SAU_REGION_3),
71            _ => None,
72        }
73    }
74    #[doc = "Checks if the value of the field is `SAU_REGION_0`"]
75    #[inline(always)]
76    pub fn is_sau_region_0(&self) -> bool {
77        *self == REGION_A::SAU_REGION_0
78    }
79    #[doc = "Checks if the value of the field is `SAU_REGION_1`"]
80    #[inline(always)]
81    pub fn is_sau_region_1(&self) -> bool {
82        *self == REGION_A::SAU_REGION_1
83    }
84    #[doc = "Checks if the value of the field is `SAU_REGION_2`"]
85    #[inline(always)]
86    pub fn is_sau_region_2(&self) -> bool {
87        *self == REGION_A::SAU_REGION_2
88    }
89    #[doc = "Checks if the value of the field is `SAU_REGION_3`"]
90    #[inline(always)]
91    pub fn is_sau_region_3(&self) -> bool {
92        *self == REGION_A::SAU_REGION_3
93    }
94}
95#[doc = "Field `REGION` writer - Currently selected SAU region"]
96pub type REGION_W<'a, const O: u8> = crate::FieldWriter<'a, u32, RNR_SPEC, u8, REGION_A, 8, O>;
97impl<'a, const O: u8> REGION_W<'a, O> {
98    #[doc = "Select SAU Region 0"]
99    #[inline(always)]
100    pub fn sau_region_0(self) -> &'a mut W {
101        self.variant(REGION_A::SAU_REGION_0)
102    }
103    #[doc = "Select SAU Region 1"]
104    #[inline(always)]
105    pub fn sau_region_1(self) -> &'a mut W {
106        self.variant(REGION_A::SAU_REGION_1)
107    }
108    #[doc = "Select SAU Region 2"]
109    #[inline(always)]
110    pub fn sau_region_2(self) -> &'a mut W {
111        self.variant(REGION_A::SAU_REGION_2)
112    }
113    #[doc = "Select SAU Region 3"]
114    #[inline(always)]
115    pub fn sau_region_3(self) -> &'a mut W {
116        self.variant(REGION_A::SAU_REGION_3)
117    }
118}
119impl R {
120    #[doc = "Bits 0:7 - Currently selected SAU region"]
121    #[inline(always)]
122    pub fn region(&self) -> REGION_R {
123        REGION_R::new((self.bits & 0xff) as u8)
124    }
125}
126impl W {
127    #[doc = "Bits 0:7 - Currently selected SAU region"]
128    #[inline(always)]
129    pub fn region(&mut self) -> REGION_W<0> {
130        REGION_W::new(self)
131    }
132    #[doc = "Writes raw bits to the register."]
133    #[inline(always)]
134    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
135        self.0.bits(bits);
136        self
137    }
138}
139#[doc = "Region Number 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 [rnr](index.html) module"]
140pub struct RNR_SPEC;
141impl crate::RegisterSpec for RNR_SPEC {
142    type Ux = u32;
143}
144#[doc = "`read()` method returns [rnr::R](R) reader structure"]
145impl crate::Readable for RNR_SPEC {
146    type Reader = R;
147}
148#[doc = "`write(|w| ..)` method takes [rnr::W](W) writer structure"]
149impl crate::Writable for RNR_SPEC {
150    type Writer = W;
151}
152#[doc = "`reset()` method sets RNR to value 0"]
153impl crate::Resettable for RNR_SPEC {
154    #[inline(always)]
155    fn reset_value() -> Self::Ux {
156        0
157    }
158}