atsamd51n/pm/
sleepcfg.rs

1#[doc = "Register `SLEEPCFG` reader"]
2pub type R = crate::R<SleepcfgSpec>;
3#[doc = "Register `SLEEPCFG` writer"]
4pub type W = crate::W<SleepcfgSpec>;
5#[doc = "Sleep Mode\n\nValue on reset: 2"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Sleepmodeselect {
9    #[doc = "2: CPU, AHBx, and APBx clocks are OFF"]
10    Idle = 2,
11    #[doc = "4: All Clocks are OFF"]
12    Standby = 4,
13    #[doc = "5: Backup domain is ON as well as some PDRAMs"]
14    Hibernate = 5,
15    #[doc = "6: Only Backup domain is powered ON"]
16    Backup = 6,
17    #[doc = "7: All power domains are powered OFF"]
18    Off = 7,
19}
20impl From<Sleepmodeselect> for u8 {
21    #[inline(always)]
22    fn from(variant: Sleepmodeselect) -> Self {
23        variant as _
24    }
25}
26impl crate::FieldSpec for Sleepmodeselect {
27    type Ux = u8;
28}
29impl crate::IsEnum for Sleepmodeselect {}
30#[doc = "Field `SLEEPMODE` reader - Sleep Mode"]
31pub type SleepmodeR = crate::FieldReader<Sleepmodeselect>;
32impl SleepmodeR {
33    #[doc = "Get enumerated values variant"]
34    #[inline(always)]
35    pub const fn variant(&self) -> Option<Sleepmodeselect> {
36        match self.bits {
37            2 => Some(Sleepmodeselect::Idle),
38            4 => Some(Sleepmodeselect::Standby),
39            5 => Some(Sleepmodeselect::Hibernate),
40            6 => Some(Sleepmodeselect::Backup),
41            7 => Some(Sleepmodeselect::Off),
42            _ => None,
43        }
44    }
45    #[doc = "CPU, AHBx, and APBx clocks are OFF"]
46    #[inline(always)]
47    pub fn is_idle(&self) -> bool {
48        *self == Sleepmodeselect::Idle
49    }
50    #[doc = "All Clocks are OFF"]
51    #[inline(always)]
52    pub fn is_standby(&self) -> bool {
53        *self == Sleepmodeselect::Standby
54    }
55    #[doc = "Backup domain is ON as well as some PDRAMs"]
56    #[inline(always)]
57    pub fn is_hibernate(&self) -> bool {
58        *self == Sleepmodeselect::Hibernate
59    }
60    #[doc = "Only Backup domain is powered ON"]
61    #[inline(always)]
62    pub fn is_backup(&self) -> bool {
63        *self == Sleepmodeselect::Backup
64    }
65    #[doc = "All power domains are powered OFF"]
66    #[inline(always)]
67    pub fn is_off(&self) -> bool {
68        *self == Sleepmodeselect::Off
69    }
70}
71#[doc = "Field `SLEEPMODE` writer - Sleep Mode"]
72pub type SleepmodeW<'a, REG> = crate::FieldWriter<'a, REG, 3, Sleepmodeselect>;
73impl<'a, REG> SleepmodeW<'a, REG>
74where
75    REG: crate::Writable + crate::RegisterSpec,
76    REG::Ux: From<u8>,
77{
78    #[doc = "CPU, AHBx, and APBx clocks are OFF"]
79    #[inline(always)]
80    pub fn idle(self) -> &'a mut crate::W<REG> {
81        self.variant(Sleepmodeselect::Idle)
82    }
83    #[doc = "All Clocks are OFF"]
84    #[inline(always)]
85    pub fn standby(self) -> &'a mut crate::W<REG> {
86        self.variant(Sleepmodeselect::Standby)
87    }
88    #[doc = "Backup domain is ON as well as some PDRAMs"]
89    #[inline(always)]
90    pub fn hibernate(self) -> &'a mut crate::W<REG> {
91        self.variant(Sleepmodeselect::Hibernate)
92    }
93    #[doc = "Only Backup domain is powered ON"]
94    #[inline(always)]
95    pub fn backup(self) -> &'a mut crate::W<REG> {
96        self.variant(Sleepmodeselect::Backup)
97    }
98    #[doc = "All power domains are powered OFF"]
99    #[inline(always)]
100    pub fn off(self) -> &'a mut crate::W<REG> {
101        self.variant(Sleepmodeselect::Off)
102    }
103}
104impl R {
105    #[doc = "Bits 0:2 - Sleep Mode"]
106    #[inline(always)]
107    pub fn sleepmode(&self) -> SleepmodeR {
108        SleepmodeR::new(self.bits & 7)
109    }
110}
111impl W {
112    #[doc = "Bits 0:2 - Sleep Mode"]
113    #[inline(always)]
114    #[must_use]
115    pub fn sleepmode(&mut self) -> SleepmodeW<SleepcfgSpec> {
116        SleepmodeW::new(self, 0)
117    }
118}
119#[doc = "Sleep Configuration\n\nYou can [`read`](crate::Reg::read) this register and get [`sleepcfg::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sleepcfg::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
120pub struct SleepcfgSpec;
121impl crate::RegisterSpec for SleepcfgSpec {
122    type Ux = u8;
123}
124#[doc = "`read()` method returns [`sleepcfg::R`](R) reader structure"]
125impl crate::Readable for SleepcfgSpec {}
126#[doc = "`write(|w| ..)` method takes [`sleepcfg::W`](W) writer structure"]
127impl crate::Writable for SleepcfgSpec {
128    type Safety = crate::Unsafe;
129    const ZERO_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
130    const ONE_TO_MODIFY_FIELDS_BITMAP: u8 = 0;
131}
132#[doc = "`reset()` method sets SLEEPCFG to value 0x02"]
133impl crate::Resettable for SleepcfgSpec {
134    const RESET_VALUE: u8 = 0x02;
135}