mcxa_pac/cmc/
pmctrlmain.rs1#[doc = "Register `PMCTRLMAIN` reader"]
2pub type R = crate::R<PmctrlmainSpec>;
3#[doc = "Register `PMCTRLMAIN` writer"]
4pub type W = crate::W<PmctrlmainSpec>;
5#[doc = "Low-Power 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 Lpmode {
10 #[doc = "0: Active/Sleep"]
11 Lpmode0000 = 0,
12 #[doc = "1: Deep Sleep"]
13 Lpmode0001 = 1,
14 #[doc = "3: Power Down"]
15 Lpmode0011 = 3,
16 #[doc = "15: Deep-Power Down"]
17 Lpmode1111 = 15,
18}
19impl From<Lpmode> for u8 {
20 #[inline(always)]
21 fn from(variant: Lpmode) -> Self {
22 variant as _
23 }
24}
25impl crate::FieldSpec for Lpmode {
26 type Ux = u8;
27}
28impl crate::IsEnum for Lpmode {}
29#[doc = "Field `LPMODE` reader - Low-Power Mode"]
30pub type LpmodeR = crate::FieldReader<Lpmode>;
31impl LpmodeR {
32 #[doc = "Get enumerated values variant"]
33 #[inline(always)]
34 pub const fn variant(&self) -> Option<Lpmode> {
35 match self.bits {
36 0 => Some(Lpmode::Lpmode0000),
37 1 => Some(Lpmode::Lpmode0001),
38 3 => Some(Lpmode::Lpmode0011),
39 15 => Some(Lpmode::Lpmode1111),
40 _ => None,
41 }
42 }
43 #[doc = "Active/Sleep"]
44 #[inline(always)]
45 pub fn is_lpmode0000(&self) -> bool {
46 *self == Lpmode::Lpmode0000
47 }
48 #[doc = "Deep Sleep"]
49 #[inline(always)]
50 pub fn is_lpmode0001(&self) -> bool {
51 *self == Lpmode::Lpmode0001
52 }
53 #[doc = "Power Down"]
54 #[inline(always)]
55 pub fn is_lpmode0011(&self) -> bool {
56 *self == Lpmode::Lpmode0011
57 }
58 #[doc = "Deep-Power Down"]
59 #[inline(always)]
60 pub fn is_lpmode1111(&self) -> bool {
61 *self == Lpmode::Lpmode1111
62 }
63}
64#[doc = "Field `LPMODE` writer - Low-Power Mode"]
65pub type LpmodeW<'a, REG> = crate::FieldWriter<'a, REG, 4, Lpmode>;
66impl<'a, REG> LpmodeW<'a, REG>
67where
68 REG: crate::Writable + crate::RegisterSpec,
69 REG::Ux: From<u8>,
70{
71 #[doc = "Active/Sleep"]
72 #[inline(always)]
73 pub fn lpmode0000(self) -> &'a mut crate::W<REG> {
74 self.variant(Lpmode::Lpmode0000)
75 }
76 #[doc = "Deep Sleep"]
77 #[inline(always)]
78 pub fn lpmode0001(self) -> &'a mut crate::W<REG> {
79 self.variant(Lpmode::Lpmode0001)
80 }
81 #[doc = "Power Down"]
82 #[inline(always)]
83 pub fn lpmode0011(self) -> &'a mut crate::W<REG> {
84 self.variant(Lpmode::Lpmode0011)
85 }
86 #[doc = "Deep-Power Down"]
87 #[inline(always)]
88 pub fn lpmode1111(self) -> &'a mut crate::W<REG> {
89 self.variant(Lpmode::Lpmode1111)
90 }
91}
92impl R {
93 #[doc = "Bits 0:3 - Low-Power Mode"]
94 #[inline(always)]
95 pub fn lpmode(&self) -> LpmodeR {
96 LpmodeR::new((self.bits & 0x0f) as u8)
97 }
98}
99#[cfg(feature = "debug")]
100impl core::fmt::Debug for R {
101 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
102 f.debug_struct("PMCTRLMAIN").field("lpmode", &self.lpmode()).finish()
103 }
104}
105impl W {
106 #[doc = "Bits 0:3 - Low-Power Mode"]
107 #[inline(always)]
108 pub fn lpmode(&mut self) -> LpmodeW<'_, PmctrlmainSpec> {
109 LpmodeW::new(self, 0)
110 }
111}
112#[doc = "Power Mode Control\n\nYou can [`read`](crate::Reg::read) this register and get [`pmctrlmain::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`pmctrlmain::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
113pub struct PmctrlmainSpec;
114impl crate::RegisterSpec for PmctrlmainSpec {
115 type Ux = u32;
116}
117#[doc = "`read()` method returns [`pmctrlmain::R`](R) reader structure"]
118impl crate::Readable for PmctrlmainSpec {}
119#[doc = "`write(|w| ..)` method takes [`pmctrlmain::W`](W) writer structure"]
120impl crate::Writable for PmctrlmainSpec {
121 type Safety = crate::Unsafe;
122}
123#[doc = "`reset()` method sets PMCTRLMAIN to value 0"]
124impl crate::Resettable for PmctrlmainSpec {}