atsamd51p/pm/
bkupcfg.rs

1#[doc = "Register `BKUPCFG` reader"]
2pub type R = crate::R<BkupcfgSpec>;
3#[doc = "Register `BKUPCFG` writer"]
4pub type W = crate::W<BkupcfgSpec>;
5#[doc = "Ram Configuration\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Bramcfgselect {
9    #[doc = "0: All the backup RAM is retained"]
10    Ret = 0,
11    #[doc = "1: Only the first 4Kbytes of the backup RAM is retained"]
12    Partial = 1,
13    #[doc = "2: All the backup RAM is turned OFF"]
14    Off = 2,
15}
16impl From<Bramcfgselect> for u8 {
17    #[inline(always)]
18    fn from(variant: Bramcfgselect) -> Self {
19        variant as _
20    }
21}
22impl crate::FieldSpec for Bramcfgselect {
23    type Ux = u8;
24}
25impl crate::IsEnum for Bramcfgselect {}
26#[doc = "Field `BRAMCFG` reader - Ram Configuration"]
27pub type BramcfgR = crate::FieldReader<Bramcfgselect>;
28impl BramcfgR {
29    #[doc = "Get enumerated values variant"]
30    #[inline(always)]
31    pub const fn variant(&self) -> Option<Bramcfgselect> {
32        match self.bits {
33            0 => Some(Bramcfgselect::Ret),
34            1 => Some(Bramcfgselect::Partial),
35            2 => Some(Bramcfgselect::Off),
36            _ => None,
37        }
38    }
39    #[doc = "All the backup RAM is retained"]
40    #[inline(always)]
41    pub fn is_ret(&self) -> bool {
42        *self == Bramcfgselect::Ret
43    }
44    #[doc = "Only the first 4Kbytes of the backup RAM is retained"]
45    #[inline(always)]
46    pub fn is_partial(&self) -> bool {
47        *self == Bramcfgselect::Partial
48    }
49    #[doc = "All the backup RAM is turned OFF"]
50    #[inline(always)]
51    pub fn is_off(&self) -> bool {
52        *self == Bramcfgselect::Off
53    }
54}
55#[doc = "Field `BRAMCFG` writer - Ram Configuration"]
56pub type BramcfgW<'a, REG> = crate::FieldWriter<'a, REG, 2, Bramcfgselect>;
57impl<'a, REG> BramcfgW<'a, REG>
58where
59    REG: crate::Writable + crate::RegisterSpec,
60    REG::Ux: From<u8>,
61{
62    #[doc = "All the backup RAM is retained"]
63    #[inline(always)]
64    pub fn ret(self) -> &'a mut crate::W<REG> {
65        self.variant(Bramcfgselect::Ret)
66    }
67    #[doc = "Only the first 4Kbytes of the backup RAM is retained"]
68    #[inline(always)]
69    pub fn partial(self) -> &'a mut crate::W<REG> {
70        self.variant(Bramcfgselect::Partial)
71    }
72    #[doc = "All the backup RAM is turned OFF"]
73    #[inline(always)]
74    pub fn off(self) -> &'a mut crate::W<REG> {
75        self.variant(Bramcfgselect::Off)
76    }
77}
78impl R {
79    #[doc = "Bits 0:1 - Ram Configuration"]
80    #[inline(always)]
81    pub fn bramcfg(&self) -> BramcfgR {
82        BramcfgR::new(self.bits & 3)
83    }
84}
85impl W {
86    #[doc = "Bits 0:1 - Ram Configuration"]
87    #[inline(always)]
88    #[must_use]
89    pub fn bramcfg(&mut self) -> BramcfgW<BkupcfgSpec> {
90        BramcfgW::new(self, 0)
91    }
92}
93#[doc = "Backup Configuration\n\nYou can [`read`](crate::Reg::read) this register and get [`bkupcfg::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`bkupcfg::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
94pub struct BkupcfgSpec;
95impl crate::RegisterSpec for BkupcfgSpec {
96    type Ux = u8;
97}
98#[doc = "`read()` method returns [`bkupcfg::R`](R) reader structure"]
99impl crate::Readable for BkupcfgSpec {}
100#[doc = "`write(|w| ..)` method takes [`bkupcfg::W`](W) writer structure"]
101impl crate::Writable for BkupcfgSpec {
102    type Safety = crate::Unsafe;
103    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
104    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
105}
106#[doc = "`reset()` method sets BKUPCFG to value 0"]
107impl crate::Resettable for BkupcfgSpec {
108    const RESET_VALUE: u8 = 0;
109}