atsamd51n/supc/
bbps.rs

1#[doc = "Register `BBPS` reader"]
2pub type R = crate::R<BbpsSpec>;
3#[doc = "Register `BBPS` writer"]
4pub type W = crate::W<BbpsSpec>;
5#[doc = "Battery Backup Configuration\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum Confselect {
8    #[doc = "0: The power switch is handled by the BOD33"]
9    Bod33 = 0,
10    #[doc = "1: In Backup Domain, the backup domain is always supplied by battery backup power"]
11    Forced = 1,
12}
13impl From<Confselect> for bool {
14    #[inline(always)]
15    fn from(variant: Confselect) -> Self {
16        variant as u8 != 0
17    }
18}
19#[doc = "Field `CONF` reader - Battery Backup Configuration"]
20pub type ConfR = crate::BitReader<Confselect>;
21impl ConfR {
22    #[doc = "Get enumerated values variant"]
23    #[inline(always)]
24    pub const fn variant(&self) -> Confselect {
25        match self.bits {
26            false => Confselect::Bod33,
27            true => Confselect::Forced,
28        }
29    }
30    #[doc = "The power switch is handled by the BOD33"]
31    #[inline(always)]
32    pub fn is_bod33(&self) -> bool {
33        *self == Confselect::Bod33
34    }
35    #[doc = "In Backup Domain, the backup domain is always supplied by battery backup power"]
36    #[inline(always)]
37    pub fn is_forced(&self) -> bool {
38        *self == Confselect::Forced
39    }
40}
41#[doc = "Field `CONF` writer - Battery Backup Configuration"]
42pub type ConfW<'a, REG> = crate::BitWriter<'a, REG, Confselect>;
43impl<'a, REG> ConfW<'a, REG>
44where
45    REG: crate::Writable + crate::RegisterSpec,
46{
47    #[doc = "The power switch is handled by the BOD33"]
48    #[inline(always)]
49    pub fn bod33(self) -> &'a mut crate::W<REG> {
50        self.variant(Confselect::Bod33)
51    }
52    #[doc = "In Backup Domain, the backup domain is always supplied by battery backup power"]
53    #[inline(always)]
54    pub fn forced(self) -> &'a mut crate::W<REG> {
55        self.variant(Confselect::Forced)
56    }
57}
58#[doc = "Field `WAKEEN` reader - Wake Enable"]
59pub type WakeenR = crate::BitReader;
60#[doc = "Field `WAKEEN` writer - Wake Enable"]
61pub type WakeenW<'a, REG> = crate::BitWriter<'a, REG>;
62impl R {
63    #[doc = "Bit 0 - Battery Backup Configuration"]
64    #[inline(always)]
65    pub fn conf(&self) -> ConfR {
66        ConfR::new((self.bits & 1) != 0)
67    }
68    #[doc = "Bit 2 - Wake Enable"]
69    #[inline(always)]
70    pub fn wakeen(&self) -> WakeenR {
71        WakeenR::new(((self.bits >> 2) & 1) != 0)
72    }
73}
74impl W {
75    #[doc = "Bit 0 - Battery Backup Configuration"]
76    #[inline(always)]
77    #[must_use]
78    pub fn conf(&mut self) -> ConfW<BbpsSpec> {
79        ConfW::new(self, 0)
80    }
81    #[doc = "Bit 2 - Wake Enable"]
82    #[inline(always)]
83    #[must_use]
84    pub fn wakeen(&mut self) -> WakeenW<BbpsSpec> {
85        WakeenW::new(self, 2)
86    }
87}
88#[doc = "Battery Backup Power Switch\n\nYou can [`read`](crate::Reg::read) this register and get [`bbps::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`bbps::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
89pub struct BbpsSpec;
90impl crate::RegisterSpec for BbpsSpec {
91    type Ux = u32;
92}
93#[doc = "`read()` method returns [`bbps::R`](R) reader structure"]
94impl crate::Readable for BbpsSpec {}
95#[doc = "`write(|w| ..)` method takes [`bbps::W`](W) writer structure"]
96impl crate::Writable for BbpsSpec {
97    type Safety = crate::Unsafe;
98    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
99    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
100}
101#[doc = "`reset()` method sets BBPS to value 0"]
102impl crate::Resettable for BbpsSpec {
103    const RESET_VALUE: u32 = 0;
104}