Skip to main content

mcxa_pac/spc0/
pd_status0.rs

1#[doc = "Register `PD_STATUS0` reader"]
2pub type R = crate::R<PdStatus0Spec>;
3#[doc = "Register `PD_STATUS0` writer"]
4pub type W = crate::W<PdStatus0Spec>;
5#[doc = "Power Request Status Flag\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum PwrReqStatus {
9    #[doc = "0: Did not request"]
10    ReqNo = 0,
11    #[doc = "1: Requested"]
12    ReqYes = 1,
13}
14impl From<PwrReqStatus> for bool {
15    #[inline(always)]
16    fn from(variant: PwrReqStatus) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `PWR_REQ_STATUS` reader - Power Request Status Flag"]
21pub type PwrReqStatusR = crate::BitReader<PwrReqStatus>;
22impl PwrReqStatusR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> PwrReqStatus {
26        match self.bits {
27            false => PwrReqStatus::ReqNo,
28            true => PwrReqStatus::ReqYes,
29        }
30    }
31    #[doc = "Did not request"]
32    #[inline(always)]
33    pub fn is_req_no(&self) -> bool {
34        *self == PwrReqStatus::ReqNo
35    }
36    #[doc = "Requested"]
37    #[inline(always)]
38    pub fn is_req_yes(&self) -> bool {
39        *self == PwrReqStatus::ReqYes
40    }
41}
42#[doc = "Power Domain Low Power Request Flag\n\nValue on reset: 0"]
43#[cfg_attr(feature = "defmt", derive(defmt::Format))]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum PdLpReq {
46    #[doc = "0: Did not request"]
47    ReqNo = 0,
48    #[doc = "1: Requested"]
49    ReqYes = 1,
50}
51impl From<PdLpReq> for bool {
52    #[inline(always)]
53    fn from(variant: PdLpReq) -> Self {
54        variant as u8 != 0
55    }
56}
57#[doc = "Field `PD_LP_REQ` reader - Power Domain Low Power Request Flag"]
58pub type PdLpReqR = crate::BitReader<PdLpReq>;
59impl PdLpReqR {
60    #[doc = "Get enumerated values variant"]
61    #[inline(always)]
62    pub const fn variant(&self) -> PdLpReq {
63        match self.bits {
64            false => PdLpReq::ReqNo,
65            true => PdLpReq::ReqYes,
66        }
67    }
68    #[doc = "Did not request"]
69    #[inline(always)]
70    pub fn is_req_no(&self) -> bool {
71        *self == PdLpReq::ReqNo
72    }
73    #[doc = "Requested"]
74    #[inline(always)]
75    pub fn is_req_yes(&self) -> bool {
76        *self == PdLpReq::ReqYes
77    }
78}
79#[doc = "Field `PD_LP_REQ` writer - Power Domain Low Power Request Flag"]
80pub type PdLpReqW<'a, REG> = crate::BitWriter1C<'a, REG, PdLpReq>;
81impl<'a, REG> PdLpReqW<'a, REG>
82where
83    REG: crate::Writable + crate::RegisterSpec,
84{
85    #[doc = "Did not request"]
86    #[inline(always)]
87    pub fn req_no(self) -> &'a mut crate::W<REG> {
88        self.variant(PdLpReq::ReqNo)
89    }
90    #[doc = "Requested"]
91    #[inline(always)]
92    pub fn req_yes(self) -> &'a mut crate::W<REG> {
93        self.variant(PdLpReq::ReqYes)
94    }
95}
96#[doc = "Power Domain Low Power Mode Request\n\nValue on reset: 0"]
97#[cfg_attr(feature = "defmt", derive(defmt::Format))]
98#[derive(Clone, Copy, Debug, PartialEq, Eq)]
99#[repr(u8)]
100pub enum LpMode {
101    #[doc = "0: SLEEP with system clock running"]
102    Mode0 = 0,
103    #[doc = "1: DSLEEP with system clock off"]
104    Mode1 = 1,
105    #[doc = "2: PDOWN with system clock off"]
106    Mode2 = 2,
107    #[doc = "8: DPDOWN with system clock off"]
108    Mode8 = 8,
109}
110impl From<LpMode> for u8 {
111    #[inline(always)]
112    fn from(variant: LpMode) -> Self {
113        variant as _
114    }
115}
116impl crate::FieldSpec for LpMode {
117    type Ux = u8;
118}
119impl crate::IsEnum for LpMode {}
120#[doc = "Field `LP_MODE` reader - Power Domain Low Power Mode Request"]
121pub type LpModeR = crate::FieldReader<LpMode>;
122impl LpModeR {
123    #[doc = "Get enumerated values variant"]
124    #[inline(always)]
125    pub const fn variant(&self) -> Option<LpMode> {
126        match self.bits {
127            0 => Some(LpMode::Mode0),
128            1 => Some(LpMode::Mode1),
129            2 => Some(LpMode::Mode2),
130            8 => Some(LpMode::Mode8),
131            _ => None,
132        }
133    }
134    #[doc = "SLEEP with system clock running"]
135    #[inline(always)]
136    pub fn is_mode0(&self) -> bool {
137        *self == LpMode::Mode0
138    }
139    #[doc = "DSLEEP with system clock off"]
140    #[inline(always)]
141    pub fn is_mode1(&self) -> bool {
142        *self == LpMode::Mode1
143    }
144    #[doc = "PDOWN with system clock off"]
145    #[inline(always)]
146    pub fn is_mode2(&self) -> bool {
147        *self == LpMode::Mode2
148    }
149    #[doc = "DPDOWN with system clock off"]
150    #[inline(always)]
151    pub fn is_mode8(&self) -> bool {
152        *self == LpMode::Mode8
153    }
154}
155impl R {
156    #[doc = "Bit 0 - Power Request Status Flag"]
157    #[inline(always)]
158    pub fn pwr_req_status(&self) -> PwrReqStatusR {
159        PwrReqStatusR::new((self.bits & 1) != 0)
160    }
161    #[doc = "Bit 4 - Power Domain Low Power Request Flag"]
162    #[inline(always)]
163    pub fn pd_lp_req(&self) -> PdLpReqR {
164        PdLpReqR::new(((self.bits >> 4) & 1) != 0)
165    }
166    #[doc = "Bits 8:11 - Power Domain Low Power Mode Request"]
167    #[inline(always)]
168    pub fn lp_mode(&self) -> LpModeR {
169        LpModeR::new(((self.bits >> 8) & 0x0f) as u8)
170    }
171}
172#[cfg(feature = "debug")]
173impl core::fmt::Debug for R {
174    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
175        f.debug_struct("PD_STATUS0")
176            .field("pwr_req_status", &self.pwr_req_status())
177            .field("pd_lp_req", &self.pd_lp_req())
178            .field("lp_mode", &self.lp_mode())
179            .finish()
180    }
181}
182impl W {
183    #[doc = "Bit 4 - Power Domain Low Power Request Flag"]
184    #[inline(always)]
185    pub fn pd_lp_req(&mut self) -> PdLpReqW<'_, PdStatus0Spec> {
186        PdLpReqW::new(self, 4)
187    }
188}
189#[doc = "SPC Power Domain Mode Status\n\nYou can [`read`](crate::Reg::read) this register and get [`pd_status0::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`pd_status0::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
190pub struct PdStatus0Spec;
191impl crate::RegisterSpec for PdStatus0Spec {
192    type Ux = u32;
193}
194#[doc = "`read()` method returns [`pd_status0::R`](R) reader structure"]
195impl crate::Readable for PdStatus0Spec {}
196#[doc = "`write(|w| ..)` method takes [`pd_status0::W`](W) writer structure"]
197impl crate::Writable for PdStatus0Spec {
198    type Safety = crate::Unsafe;
199    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0x10;
200}
201#[doc = "`reset()` method sets PD_STATUS0 to value 0"]
202impl crate::Resettable for PdStatus0Spec {}