atsamd11c/pm/
sleep.rs
1#[doc = "Register `SLEEP` reader"]
2pub type R = crate::R<SleepSpec>;
3#[doc = "Register `SLEEP` writer"]
4pub type W = crate::W<SleepSpec>;
5#[doc = "Idle Mode Configuration\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Idleselect {
9 #[doc = "0: The CPU clock domain is stopped"]
10 Cpu = 0,
11 #[doc = "1: The CPU and AHB clock domains are stopped"]
12 Ahb = 1,
13 #[doc = "2: The CPU, AHB and APB clock domains are stopped"]
14 Apb = 2,
15}
16impl From<Idleselect> for u8 {
17 #[inline(always)]
18 fn from(variant: Idleselect) -> Self {
19 variant as _
20 }
21}
22impl crate::FieldSpec for Idleselect {
23 type Ux = u8;
24}
25impl crate::IsEnum for Idleselect {}
26#[doc = "Field `IDLE` reader - Idle Mode Configuration"]
27pub type IdleR = crate::FieldReader<Idleselect>;
28impl IdleR {
29 #[doc = "Get enumerated values variant"]
30 #[inline(always)]
31 pub const fn variant(&self) -> Option<Idleselect> {
32 match self.bits {
33 0 => Some(Idleselect::Cpu),
34 1 => Some(Idleselect::Ahb),
35 2 => Some(Idleselect::Apb),
36 _ => None,
37 }
38 }
39 #[doc = "The CPU clock domain is stopped"]
40 #[inline(always)]
41 pub fn is_cpu(&self) -> bool {
42 *self == Idleselect::Cpu
43 }
44 #[doc = "The CPU and AHB clock domains are stopped"]
45 #[inline(always)]
46 pub fn is_ahb(&self) -> bool {
47 *self == Idleselect::Ahb
48 }
49 #[doc = "The CPU, AHB and APB clock domains are stopped"]
50 #[inline(always)]
51 pub fn is_apb(&self) -> bool {
52 *self == Idleselect::Apb
53 }
54}
55#[doc = "Field `IDLE` writer - Idle Mode Configuration"]
56pub type IdleW<'a, REG> = crate::FieldWriter<'a, REG, 2, Idleselect>;
57impl<'a, REG> IdleW<'a, REG>
58where
59 REG: crate::Writable + crate::RegisterSpec,
60 REG::Ux: From<u8>,
61{
62 #[doc = "The CPU clock domain is stopped"]
63 #[inline(always)]
64 pub fn cpu(self) -> &'a mut crate::W<REG> {
65 self.variant(Idleselect::Cpu)
66 }
67 #[doc = "The CPU and AHB clock domains are stopped"]
68 #[inline(always)]
69 pub fn ahb(self) -> &'a mut crate::W<REG> {
70 self.variant(Idleselect::Ahb)
71 }
72 #[doc = "The CPU, AHB and APB clock domains are stopped"]
73 #[inline(always)]
74 pub fn apb(self) -> &'a mut crate::W<REG> {
75 self.variant(Idleselect::Apb)
76 }
77}
78impl R {
79 #[doc = "Bits 0:1 - Idle Mode Configuration"]
80 #[inline(always)]
81 pub fn idle(&self) -> IdleR {
82 IdleR::new(self.bits & 3)
83 }
84}
85impl W {
86 #[doc = "Bits 0:1 - Idle Mode Configuration"]
87 #[inline(always)]
88 #[must_use]
89 pub fn idle(&mut self) -> IdleW<SleepSpec> {
90 IdleW::new(self, 0)
91 }
92}
93#[doc = "Sleep Mode\n\nYou can [`read`](crate::Reg::read) this register and get [`sleep::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sleep::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
94pub struct SleepSpec;
95impl crate::RegisterSpec for SleepSpec {
96 type Ux = u8;
97}
98#[doc = "`read()` method returns [`sleep::R`](R) reader structure"]
99impl crate::Readable for SleepSpec {}
100#[doc = "`write(|w| ..)` method takes [`sleep::W`](W) writer structure"]
101impl crate::Writable for SleepSpec {
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 SLEEP to value 0"]
107impl crate::Resettable for SleepSpec {
108 const RESET_VALUE: u8 = 0;
109}