atsamd51g/system_control/
cpacr.rs

1#[doc = "Register `CPACR` reader"]
2pub type R = crate::R<CpacrSpec>;
3#[doc = "Register `CPACR` writer"]
4pub type W = crate::W<CpacrSpec>;
5#[doc = "Access privileges for coprocessor 10\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Cp10select {
9    #[doc = "0: Access denied"]
10    Denied = 0,
11    #[doc = "1: Privileged access only"]
12    Priv = 1,
13    #[doc = "3: Full access"]
14    Full = 3,
15}
16impl From<Cp10select> for u8 {
17    #[inline(always)]
18    fn from(variant: Cp10select) -> Self {
19        variant as _
20    }
21}
22impl crate::FieldSpec for Cp10select {
23    type Ux = u8;
24}
25impl crate::IsEnum for Cp10select {}
26#[doc = "Field `CP10` reader - Access privileges for coprocessor 10"]
27pub type Cp10R = crate::FieldReader<Cp10select>;
28impl Cp10R {
29    #[doc = "Get enumerated values variant"]
30    #[inline(always)]
31    pub const fn variant(&self) -> Option<Cp10select> {
32        match self.bits {
33            0 => Some(Cp10select::Denied),
34            1 => Some(Cp10select::Priv),
35            3 => Some(Cp10select::Full),
36            _ => None,
37        }
38    }
39    #[doc = "Access denied"]
40    #[inline(always)]
41    pub fn is_denied(&self) -> bool {
42        *self == Cp10select::Denied
43    }
44    #[doc = "Privileged access only"]
45    #[inline(always)]
46    pub fn is_priv(&self) -> bool {
47        *self == Cp10select::Priv
48    }
49    #[doc = "Full access"]
50    #[inline(always)]
51    pub fn is_full(&self) -> bool {
52        *self == Cp10select::Full
53    }
54}
55#[doc = "Field `CP10` writer - Access privileges for coprocessor 10"]
56pub type Cp10W<'a, REG> = crate::FieldWriter<'a, REG, 2, Cp10select>;
57impl<'a, REG> Cp10W<'a, REG>
58where
59    REG: crate::Writable + crate::RegisterSpec,
60    REG::Ux: From<u8>,
61{
62    #[doc = "Access denied"]
63    #[inline(always)]
64    pub fn denied(self) -> &'a mut crate::W<REG> {
65        self.variant(Cp10select::Denied)
66    }
67    #[doc = "Privileged access only"]
68    #[inline(always)]
69    pub fn priv_(self) -> &'a mut crate::W<REG> {
70        self.variant(Cp10select::Priv)
71    }
72    #[doc = "Full access"]
73    #[inline(always)]
74    pub fn full(self) -> &'a mut crate::W<REG> {
75        self.variant(Cp10select::Full)
76    }
77}
78#[doc = "Access privileges for coprocessor 11\n\nValue on reset: 0"]
79#[derive(Clone, Copy, Debug, PartialEq, Eq)]
80#[repr(u8)]
81pub enum Cp11select {
82    #[doc = "0: Access denied"]
83    Denied = 0,
84    #[doc = "1: Privileged access only"]
85    Priv = 1,
86    #[doc = "3: Full access"]
87    Full = 3,
88}
89impl From<Cp11select> for u8 {
90    #[inline(always)]
91    fn from(variant: Cp11select) -> Self {
92        variant as _
93    }
94}
95impl crate::FieldSpec for Cp11select {
96    type Ux = u8;
97}
98impl crate::IsEnum for Cp11select {}
99#[doc = "Field `CP11` reader - Access privileges for coprocessor 11"]
100pub type Cp11R = crate::FieldReader<Cp11select>;
101impl Cp11R {
102    #[doc = "Get enumerated values variant"]
103    #[inline(always)]
104    pub const fn variant(&self) -> Option<Cp11select> {
105        match self.bits {
106            0 => Some(Cp11select::Denied),
107            1 => Some(Cp11select::Priv),
108            3 => Some(Cp11select::Full),
109            _ => None,
110        }
111    }
112    #[doc = "Access denied"]
113    #[inline(always)]
114    pub fn is_denied(&self) -> bool {
115        *self == Cp11select::Denied
116    }
117    #[doc = "Privileged access only"]
118    #[inline(always)]
119    pub fn is_priv(&self) -> bool {
120        *self == Cp11select::Priv
121    }
122    #[doc = "Full access"]
123    #[inline(always)]
124    pub fn is_full(&self) -> bool {
125        *self == Cp11select::Full
126    }
127}
128#[doc = "Field `CP11` writer - Access privileges for coprocessor 11"]
129pub type Cp11W<'a, REG> = crate::FieldWriter<'a, REG, 2, Cp11select>;
130impl<'a, REG> Cp11W<'a, REG>
131where
132    REG: crate::Writable + crate::RegisterSpec,
133    REG::Ux: From<u8>,
134{
135    #[doc = "Access denied"]
136    #[inline(always)]
137    pub fn denied(self) -> &'a mut crate::W<REG> {
138        self.variant(Cp11select::Denied)
139    }
140    #[doc = "Privileged access only"]
141    #[inline(always)]
142    pub fn priv_(self) -> &'a mut crate::W<REG> {
143        self.variant(Cp11select::Priv)
144    }
145    #[doc = "Full access"]
146    #[inline(always)]
147    pub fn full(self) -> &'a mut crate::W<REG> {
148        self.variant(Cp11select::Full)
149    }
150}
151impl R {
152    #[doc = "Bits 20:21 - Access privileges for coprocessor 10"]
153    #[inline(always)]
154    pub fn cp10(&self) -> Cp10R {
155        Cp10R::new(((self.bits >> 20) & 3) as u8)
156    }
157    #[doc = "Bits 22:23 - Access privileges for coprocessor 11"]
158    #[inline(always)]
159    pub fn cp11(&self) -> Cp11R {
160        Cp11R::new(((self.bits >> 22) & 3) as u8)
161    }
162}
163impl W {
164    #[doc = "Bits 20:21 - Access privileges for coprocessor 10"]
165    #[inline(always)]
166    #[must_use]
167    pub fn cp10(&mut self) -> Cp10W<CpacrSpec> {
168        Cp10W::new(self, 20)
169    }
170    #[doc = "Bits 22:23 - Access privileges for coprocessor 11"]
171    #[inline(always)]
172    #[must_use]
173    pub fn cp11(&mut self) -> Cp11W<CpacrSpec> {
174        Cp11W::new(self, 22)
175    }
176}
177#[doc = "Coprocessor Access Control Register\n\nYou can [`read`](crate::Reg::read) this register and get [`cpacr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cpacr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
178pub struct CpacrSpec;
179impl crate::RegisterSpec for CpacrSpec {
180    type Ux = u32;
181}
182#[doc = "`read()` method returns [`cpacr::R`](R) reader structure"]
183impl crate::Readable for CpacrSpec {}
184#[doc = "`write(|w| ..)` method takes [`cpacr::W`](W) writer structure"]
185impl crate::Writable for CpacrSpec {
186    type Safety = crate::Unsafe;
187    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
188    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
189}
190#[doc = "`reset()` method sets CPACR to value 0"]
191impl crate::Resettable for CpacrSpec {
192    const RESET_VALUE: u32 = 0;
193}