atsamd51p/pm/
stdbycfg.rs

1#[doc = "Register `STDBYCFG` reader"]
2pub type R = crate::R<StdbycfgSpec>;
3#[doc = "Register `STDBYCFG` writer"]
4pub type W = crate::W<StdbycfgSpec>;
5#[doc = "Ram Configuration\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Ramcfgselect {
9    #[doc = "0: All the system RAM is retained"]
10    Ret = 0,
11    #[doc = "1: Only the first 32Kbytes of the system RAM is retained"]
12    Partial = 1,
13    #[doc = "2: All the system RAM is turned OFF"]
14    Off = 2,
15}
16impl From<Ramcfgselect> for u8 {
17    #[inline(always)]
18    fn from(variant: Ramcfgselect) -> Self {
19        variant as _
20    }
21}
22impl crate::FieldSpec for Ramcfgselect {
23    type Ux = u8;
24}
25impl crate::IsEnum for Ramcfgselect {}
26#[doc = "Field `RAMCFG` reader - Ram Configuration"]
27pub type RamcfgR = crate::FieldReader<Ramcfgselect>;
28impl RamcfgR {
29    #[doc = "Get enumerated values variant"]
30    #[inline(always)]
31    pub const fn variant(&self) -> Option<Ramcfgselect> {
32        match self.bits {
33            0 => Some(Ramcfgselect::Ret),
34            1 => Some(Ramcfgselect::Partial),
35            2 => Some(Ramcfgselect::Off),
36            _ => None,
37        }
38    }
39    #[doc = "All the system RAM is retained"]
40    #[inline(always)]
41    pub fn is_ret(&self) -> bool {
42        *self == Ramcfgselect::Ret
43    }
44    #[doc = "Only the first 32Kbytes of the system RAM is retained"]
45    #[inline(always)]
46    pub fn is_partial(&self) -> bool {
47        *self == Ramcfgselect::Partial
48    }
49    #[doc = "All the system RAM is turned OFF"]
50    #[inline(always)]
51    pub fn is_off(&self) -> bool {
52        *self == Ramcfgselect::Off
53    }
54}
55#[doc = "Field `RAMCFG` writer - Ram Configuration"]
56pub type RamcfgW<'a, REG> = crate::FieldWriter<'a, REG, 2, Ramcfgselect>;
57impl<'a, REG> RamcfgW<'a, REG>
58where
59    REG: crate::Writable + crate::RegisterSpec,
60    REG::Ux: From<u8>,
61{
62    #[doc = "All the system RAM is retained"]
63    #[inline(always)]
64    pub fn ret(self) -> &'a mut crate::W<REG> {
65        self.variant(Ramcfgselect::Ret)
66    }
67    #[doc = "Only the first 32Kbytes of the system RAM is retained"]
68    #[inline(always)]
69    pub fn partial(self) -> &'a mut crate::W<REG> {
70        self.variant(Ramcfgselect::Partial)
71    }
72    #[doc = "All the system RAM is turned OFF"]
73    #[inline(always)]
74    pub fn off(self) -> &'a mut crate::W<REG> {
75        self.variant(Ramcfgselect::Off)
76    }
77}
78#[doc = "Fast Wakeup\n\nValue on reset: 0"]
79#[derive(Clone, Copy, Debug, PartialEq, Eq)]
80#[repr(u8)]
81pub enum Fastwkupselect {
82    #[doc = "0: Fast Wakeup is disabled"]
83    No = 0,
84    #[doc = "1: Fast Wakeup is enabled on NVM"]
85    Nvm = 1,
86    #[doc = "2: Fast Wakeup is enabled on the main voltage regulator (MAINVREG)"]
87    Mainvreg = 2,
88    #[doc = "3: Fast Wakeup is enabled on both NVM and MAINVREG"]
89    Both = 3,
90}
91impl From<Fastwkupselect> for u8 {
92    #[inline(always)]
93    fn from(variant: Fastwkupselect) -> Self {
94        variant as _
95    }
96}
97impl crate::FieldSpec for Fastwkupselect {
98    type Ux = u8;
99}
100impl crate::IsEnum for Fastwkupselect {}
101#[doc = "Field `FASTWKUP` reader - Fast Wakeup"]
102pub type FastwkupR = crate::FieldReader<Fastwkupselect>;
103impl FastwkupR {
104    #[doc = "Get enumerated values variant"]
105    #[inline(always)]
106    pub const fn variant(&self) -> Fastwkupselect {
107        match self.bits {
108            0 => Fastwkupselect::No,
109            1 => Fastwkupselect::Nvm,
110            2 => Fastwkupselect::Mainvreg,
111            3 => Fastwkupselect::Both,
112            _ => unreachable!(),
113        }
114    }
115    #[doc = "Fast Wakeup is disabled"]
116    #[inline(always)]
117    pub fn is_no(&self) -> bool {
118        *self == Fastwkupselect::No
119    }
120    #[doc = "Fast Wakeup is enabled on NVM"]
121    #[inline(always)]
122    pub fn is_nvm(&self) -> bool {
123        *self == Fastwkupselect::Nvm
124    }
125    #[doc = "Fast Wakeup is enabled on the main voltage regulator (MAINVREG)"]
126    #[inline(always)]
127    pub fn is_mainvreg(&self) -> bool {
128        *self == Fastwkupselect::Mainvreg
129    }
130    #[doc = "Fast Wakeup is enabled on both NVM and MAINVREG"]
131    #[inline(always)]
132    pub fn is_both(&self) -> bool {
133        *self == Fastwkupselect::Both
134    }
135}
136#[doc = "Field `FASTWKUP` writer - Fast Wakeup"]
137pub type FastwkupW<'a, REG> = crate::FieldWriter<'a, REG, 2, Fastwkupselect, crate::Safe>;
138impl<'a, REG> FastwkupW<'a, REG>
139where
140    REG: crate::Writable + crate::RegisterSpec,
141    REG::Ux: From<u8>,
142{
143    #[doc = "Fast Wakeup is disabled"]
144    #[inline(always)]
145    pub fn no(self) -> &'a mut crate::W<REG> {
146        self.variant(Fastwkupselect::No)
147    }
148    #[doc = "Fast Wakeup is enabled on NVM"]
149    #[inline(always)]
150    pub fn nvm(self) -> &'a mut crate::W<REG> {
151        self.variant(Fastwkupselect::Nvm)
152    }
153    #[doc = "Fast Wakeup is enabled on the main voltage regulator (MAINVREG)"]
154    #[inline(always)]
155    pub fn mainvreg(self) -> &'a mut crate::W<REG> {
156        self.variant(Fastwkupselect::Mainvreg)
157    }
158    #[doc = "Fast Wakeup is enabled on both NVM and MAINVREG"]
159    #[inline(always)]
160    pub fn both(self) -> &'a mut crate::W<REG> {
161        self.variant(Fastwkupselect::Both)
162    }
163}
164impl R {
165    #[doc = "Bits 0:1 - Ram Configuration"]
166    #[inline(always)]
167    pub fn ramcfg(&self) -> RamcfgR {
168        RamcfgR::new(self.bits & 3)
169    }
170    #[doc = "Bits 4:5 - Fast Wakeup"]
171    #[inline(always)]
172    pub fn fastwkup(&self) -> FastwkupR {
173        FastwkupR::new((self.bits >> 4) & 3)
174    }
175}
176impl W {
177    #[doc = "Bits 0:1 - Ram Configuration"]
178    #[inline(always)]
179    #[must_use]
180    pub fn ramcfg(&mut self) -> RamcfgW<StdbycfgSpec> {
181        RamcfgW::new(self, 0)
182    }
183    #[doc = "Bits 4:5 - Fast Wakeup"]
184    #[inline(always)]
185    #[must_use]
186    pub fn fastwkup(&mut self) -> FastwkupW<StdbycfgSpec> {
187        FastwkupW::new(self, 4)
188    }
189}
190#[doc = "Standby Configuration\n\nYou can [`read`](crate::Reg::read) this register and get [`stdbycfg::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`stdbycfg::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
191pub struct StdbycfgSpec;
192impl crate::RegisterSpec for StdbycfgSpec {
193    type Ux = u8;
194}
195#[doc = "`read()` method returns [`stdbycfg::R`](R) reader structure"]
196impl crate::Readable for StdbycfgSpec {}
197#[doc = "`write(|w| ..)` method takes [`stdbycfg::W`](W) writer structure"]
198impl crate::Writable for StdbycfgSpec {
199    type Safety = crate::Unsafe;
200    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
201    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
202}
203#[doc = "`reset()` method sets STDBYCFG to value 0"]
204impl crate::Resettable for StdbycfgSpec {
205    const RESET_VALUE: u8 = 0;
206}