atsamd51n/pm/
hibcfg.rs

1#[doc = "Register `HIBCFG` reader"]
2pub type R = crate::R<HibcfgSpec>;
3#[doc = "Register `HIBCFG` writer"]
4pub type W = crate::W<HibcfgSpec>;
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 = "Backup Ram Configuration\n\nValue on reset: 0"]
79#[derive(Clone, Copy, Debug, PartialEq, Eq)]
80#[repr(u8)]
81pub enum Bramcfgselect {
82    #[doc = "0: All the backup RAM is retained"]
83    Ret = 0,
84    #[doc = "1: Only the first 4Kbytes of the backup RAM is retained"]
85    Partial = 1,
86    #[doc = "2: All the backup RAM is turned OFF"]
87    Off = 2,
88}
89impl From<Bramcfgselect> for u8 {
90    #[inline(always)]
91    fn from(variant: Bramcfgselect) -> Self {
92        variant as _
93    }
94}
95impl crate::FieldSpec for Bramcfgselect {
96    type Ux = u8;
97}
98impl crate::IsEnum for Bramcfgselect {}
99#[doc = "Field `BRAMCFG` reader - Backup Ram Configuration"]
100pub type BramcfgR = crate::FieldReader<Bramcfgselect>;
101impl BramcfgR {
102    #[doc = "Get enumerated values variant"]
103    #[inline(always)]
104    pub const fn variant(&self) -> Option<Bramcfgselect> {
105        match self.bits {
106            0 => Some(Bramcfgselect::Ret),
107            1 => Some(Bramcfgselect::Partial),
108            2 => Some(Bramcfgselect::Off),
109            _ => None,
110        }
111    }
112    #[doc = "All the backup RAM is retained"]
113    #[inline(always)]
114    pub fn is_ret(&self) -> bool {
115        *self == Bramcfgselect::Ret
116    }
117    #[doc = "Only the first 4Kbytes of the backup RAM is retained"]
118    #[inline(always)]
119    pub fn is_partial(&self) -> bool {
120        *self == Bramcfgselect::Partial
121    }
122    #[doc = "All the backup RAM is turned OFF"]
123    #[inline(always)]
124    pub fn is_off(&self) -> bool {
125        *self == Bramcfgselect::Off
126    }
127}
128#[doc = "Field `BRAMCFG` writer - Backup Ram Configuration"]
129pub type BramcfgW<'a, REG> = crate::FieldWriter<'a, REG, 2, Bramcfgselect>;
130impl<'a, REG> BramcfgW<'a, REG>
131where
132    REG: crate::Writable + crate::RegisterSpec,
133    REG::Ux: From<u8>,
134{
135    #[doc = "All the backup RAM is retained"]
136    #[inline(always)]
137    pub fn ret(self) -> &'a mut crate::W<REG> {
138        self.variant(Bramcfgselect::Ret)
139    }
140    #[doc = "Only the first 4Kbytes of the backup RAM is retained"]
141    #[inline(always)]
142    pub fn partial(self) -> &'a mut crate::W<REG> {
143        self.variant(Bramcfgselect::Partial)
144    }
145    #[doc = "All the backup RAM is turned OFF"]
146    #[inline(always)]
147    pub fn off(self) -> &'a mut crate::W<REG> {
148        self.variant(Bramcfgselect::Off)
149    }
150}
151impl R {
152    #[doc = "Bits 0:1 - Ram Configuration"]
153    #[inline(always)]
154    pub fn ramcfg(&self) -> RamcfgR {
155        RamcfgR::new(self.bits & 3)
156    }
157    #[doc = "Bits 2:3 - Backup Ram Configuration"]
158    #[inline(always)]
159    pub fn bramcfg(&self) -> BramcfgR {
160        BramcfgR::new((self.bits >> 2) & 3)
161    }
162}
163impl W {
164    #[doc = "Bits 0:1 - Ram Configuration"]
165    #[inline(always)]
166    #[must_use]
167    pub fn ramcfg(&mut self) -> RamcfgW<HibcfgSpec> {
168        RamcfgW::new(self, 0)
169    }
170    #[doc = "Bits 2:3 - Backup Ram Configuration"]
171    #[inline(always)]
172    #[must_use]
173    pub fn bramcfg(&mut self) -> BramcfgW<HibcfgSpec> {
174        BramcfgW::new(self, 2)
175    }
176}
177#[doc = "Hibernate Configuration\n\nYou can [`read`](crate::Reg::read) this register and get [`hibcfg::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`hibcfg::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
178pub struct HibcfgSpec;
179impl crate::RegisterSpec for HibcfgSpec {
180    type Ux = u8;
181}
182#[doc = "`read()` method returns [`hibcfg::R`](R) reader structure"]
183impl crate::Readable for HibcfgSpec {}
184#[doc = "`write(|w| ..)` method takes [`hibcfg::W`](W) writer structure"]
185impl crate::Writable for HibcfgSpec {
186    type Safety = crate::Unsafe;
187    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
188    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
189}
190#[doc = "`reset()` method sets HIBCFG to value 0"]
191impl crate::Resettable for HibcfgSpec {
192    const RESET_VALUE: u8 = 0;
193}