1#[doc = "Register `CKCTRL` reader"]
2pub type R = crate::R<CkctrlSpec>;
3#[doc = "Register `CKCTRL` writer"]
4pub type W = crate::W<CkctrlSpec>;
5#[doc = "Clocking Mode\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8#[repr(u8)]
9pub enum Ckmode {
10 #[doc = "0: Core clock is on"]
11 Ckmode0000 = 0,
12 #[doc = "1: Core clock is off"]
13 Ckmode0001 = 1,
14 #[doc = "15: Core, platform, and peripheral clocks are off, and core enters Low-Power mode"]
15 Ckmode1111 = 15,
16}
17impl From<Ckmode> for u8 {
18 #[inline(always)]
19 fn from(variant: Ckmode) -> Self {
20 variant as _
21 }
22}
23impl crate::FieldSpec for Ckmode {
24 type Ux = u8;
25}
26impl crate::IsEnum for Ckmode {}
27#[doc = "Field `CKMODE` reader - Clocking Mode"]
28pub type CkmodeR = crate::FieldReader<Ckmode>;
29impl CkmodeR {
30 #[doc = "Get enumerated values variant"]
31 #[inline(always)]
32 pub const fn variant(&self) -> Option<Ckmode> {
33 match self.bits {
34 0 => Some(Ckmode::Ckmode0000),
35 1 => Some(Ckmode::Ckmode0001),
36 15 => Some(Ckmode::Ckmode1111),
37 _ => None,
38 }
39 }
40 #[doc = "Core clock is on"]
41 #[inline(always)]
42 pub fn is_ckmode0000(&self) -> bool {
43 *self == Ckmode::Ckmode0000
44 }
45 #[doc = "Core clock is off"]
46 #[inline(always)]
47 pub fn is_ckmode0001(&self) -> bool {
48 *self == Ckmode::Ckmode0001
49 }
50 #[doc = "Core, platform, and peripheral clocks are off, and core enters Low-Power mode"]
51 #[inline(always)]
52 pub fn is_ckmode1111(&self) -> bool {
53 *self == Ckmode::Ckmode1111
54 }
55}
56#[doc = "Field `CKMODE` writer - Clocking Mode"]
57pub type CkmodeW<'a, REG> = crate::FieldWriter<'a, REG, 4, Ckmode>;
58impl<'a, REG> CkmodeW<'a, REG>
59where
60 REG: crate::Writable + crate::RegisterSpec,
61 REG::Ux: From<u8>,
62{
63 #[doc = "Core clock is on"]
64 #[inline(always)]
65 pub fn ckmode0000(self) -> &'a mut crate::W<REG> {
66 self.variant(Ckmode::Ckmode0000)
67 }
68 #[doc = "Core clock is off"]
69 #[inline(always)]
70 pub fn ckmode0001(self) -> &'a mut crate::W<REG> {
71 self.variant(Ckmode::Ckmode0001)
72 }
73 #[doc = "Core, platform, and peripheral clocks are off, and core enters Low-Power mode"]
74 #[inline(always)]
75 pub fn ckmode1111(self) -> &'a mut crate::W<REG> {
76 self.variant(Ckmode::Ckmode1111)
77 }
78}
79#[doc = "Lock\n\nValue on reset: 0"]
80#[cfg_attr(feature = "defmt", derive(defmt::Format))]
81#[derive(Clone, Copy, Debug, PartialEq, Eq)]
82pub enum Lock {
83 #[doc = "0: Allowed"]
84 Disabled = 0,
85 #[doc = "1: Blocked"]
86 Enabled = 1,
87}
88impl From<Lock> for bool {
89 #[inline(always)]
90 fn from(variant: Lock) -> Self {
91 variant as u8 != 0
92 }
93}
94#[doc = "Field `LOCK` reader - Lock"]
95pub type LockR = crate::BitReader<Lock>;
96impl LockR {
97 #[doc = "Get enumerated values variant"]
98 #[inline(always)]
99 pub const fn variant(&self) -> Lock {
100 match self.bits {
101 false => Lock::Disabled,
102 true => Lock::Enabled,
103 }
104 }
105 #[doc = "Allowed"]
106 #[inline(always)]
107 pub fn is_disabled(&self) -> bool {
108 *self == Lock::Disabled
109 }
110 #[doc = "Blocked"]
111 #[inline(always)]
112 pub fn is_enabled(&self) -> bool {
113 *self == Lock::Enabled
114 }
115}
116#[doc = "Field `LOCK` writer - Lock"]
117pub type LockW<'a, REG> = crate::BitWriter<'a, REG, Lock>;
118impl<'a, REG> LockW<'a, REG>
119where
120 REG: crate::Writable + crate::RegisterSpec,
121{
122 #[doc = "Allowed"]
123 #[inline(always)]
124 pub fn disabled(self) -> &'a mut crate::W<REG> {
125 self.variant(Lock::Disabled)
126 }
127 #[doc = "Blocked"]
128 #[inline(always)]
129 pub fn enabled(self) -> &'a mut crate::W<REG> {
130 self.variant(Lock::Enabled)
131 }
132}
133impl R {
134 #[doc = "Bits 0:3 - Clocking Mode"]
135 #[inline(always)]
136 pub fn ckmode(&self) -> CkmodeR {
137 CkmodeR::new((self.bits & 0x0f) as u8)
138 }
139 #[doc = "Bit 31 - Lock"]
140 #[inline(always)]
141 pub fn lock(&self) -> LockR {
142 LockR::new(((self.bits >> 31) & 1) != 0)
143 }
144}
145#[cfg(feature = "debug")]
146impl core::fmt::Debug for R {
147 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
148 f.debug_struct("CKCTRL")
149 .field("ckmode", &self.ckmode())
150 .field("lock", &self.lock())
151 .finish()
152 }
153}
154impl W {
155 #[doc = "Bits 0:3 - Clocking Mode"]
156 #[inline(always)]
157 pub fn ckmode(&mut self) -> CkmodeW<'_, CkctrlSpec> {
158 CkmodeW::new(self, 0)
159 }
160 #[doc = "Bit 31 - Lock"]
161 #[inline(always)]
162 pub fn lock(&mut self) -> LockW<'_, CkctrlSpec> {
163 LockW::new(self, 31)
164 }
165}
166#[doc = "Clock Control\n\nYou can [`read`](crate::Reg::read) this register and get [`ckctrl::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ckctrl::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
167pub struct CkctrlSpec;
168impl crate::RegisterSpec for CkctrlSpec {
169 type Ux = u32;
170}
171#[doc = "`read()` method returns [`ckctrl::R`](R) reader structure"]
172impl crate::Readable for CkctrlSpec {}
173#[doc = "`write(|w| ..)` method takes [`ckctrl::W`](W) writer structure"]
174impl crate::Writable for CkctrlSpec {
175 type Safety = crate::Unsafe;
176}
177#[doc = "`reset()` method sets CKCTRL to value 0"]
178impl crate::Resettable for CkctrlSpec {}