Skip to main content

mcxa_pac/spc0/
sc.rs

1#[doc = "Register `SC` reader"]
2pub type R = crate::R<ScSpec>;
3#[doc = "Register `SC` writer"]
4pub type W = crate::W<ScSpec>;
5#[doc = "SPC Busy Status Flag\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Busy {
9    #[doc = "0: Not busy"]
10    BusyNo = 0,
11    #[doc = "1: Busy"]
12    BusyYes = 1,
13}
14impl From<Busy> for bool {
15    #[inline(always)]
16    fn from(variant: Busy) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `BUSY` reader - SPC Busy Status Flag"]
21pub type BusyR = crate::BitReader<Busy>;
22impl BusyR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Busy {
26        match self.bits {
27            false => Busy::BusyNo,
28            true => Busy::BusyYes,
29        }
30    }
31    #[doc = "Not busy"]
32    #[inline(always)]
33    pub fn is_busy_no(&self) -> bool {
34        *self == Busy::BusyNo
35    }
36    #[doc = "Busy"]
37    #[inline(always)]
38    pub fn is_busy_yes(&self) -> bool {
39        *self == Busy::BusyYes
40    }
41}
42#[doc = "SPC Power Mode Configuration Status Flag\n\nValue on reset: 0"]
43#[cfg_attr(feature = "defmt", derive(defmt::Format))]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum SpcLpReq {
46    #[doc = "0: SPC is in Active mode; the ACTIVE_CFG register has control"]
47    Active = 0,
48    #[doc = "1: All power domains requested low-power mode; SPC entered a low-power state; power-mode configuration based on the LP_CFG register"]
49    LowPower = 1,
50}
51impl From<SpcLpReq> for bool {
52    #[inline(always)]
53    fn from(variant: SpcLpReq) -> Self {
54        variant as u8 != 0
55    }
56}
57#[doc = "Field `SPC_LP_REQ` reader - SPC Power Mode Configuration Status Flag"]
58pub type SpcLpReqR = crate::BitReader<SpcLpReq>;
59impl SpcLpReqR {
60    #[doc = "Get enumerated values variant"]
61    #[inline(always)]
62    pub const fn variant(&self) -> SpcLpReq {
63        match self.bits {
64            false => SpcLpReq::Active,
65            true => SpcLpReq::LowPower,
66        }
67    }
68    #[doc = "SPC is in Active mode; the ACTIVE_CFG register has control"]
69    #[inline(always)]
70    pub fn is_active(&self) -> bool {
71        *self == SpcLpReq::Active
72    }
73    #[doc = "All power domains requested low-power mode; SPC entered a low-power state; power-mode configuration based on the LP_CFG register"]
74    #[inline(always)]
75    pub fn is_low_power(&self) -> bool {
76        *self == SpcLpReq::LowPower
77    }
78}
79#[doc = "Field `SPC_LP_REQ` writer - SPC Power Mode Configuration Status Flag"]
80pub type SpcLpReqW<'a, REG> = crate::BitWriter1C<'a, REG, SpcLpReq>;
81impl<'a, REG> SpcLpReqW<'a, REG>
82where
83    REG: crate::Writable + crate::RegisterSpec,
84{
85    #[doc = "SPC is in Active mode; the ACTIVE_CFG register has control"]
86    #[inline(always)]
87    pub fn active(self) -> &'a mut crate::W<REG> {
88        self.variant(SpcLpReq::Active)
89    }
90    #[doc = "All power domains requested low-power mode; SPC entered a low-power state; power-mode configuration based on the LP_CFG register"]
91    #[inline(always)]
92    pub fn low_power(self) -> &'a mut crate::W<REG> {
93        self.variant(SpcLpReq::LowPower)
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 SpcLpMode {
101    #[doc = "0: Sleep mode 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<SpcLpMode> for u8 {
111    #[inline(always)]
112    fn from(variant: SpcLpMode) -> Self {
113        variant as _
114    }
115}
116impl crate::FieldSpec for SpcLpMode {
117    type Ux = u8;
118}
119impl crate::IsEnum for SpcLpMode {}
120#[doc = "Field `SPC_LP_MODE` reader - Power Domain Low-Power Mode Request"]
121pub type SpcLpModeR = crate::FieldReader<SpcLpMode>;
122impl SpcLpModeR {
123    #[doc = "Get enumerated values variant"]
124    #[inline(always)]
125    pub const fn variant(&self) -> Option<SpcLpMode> {
126        match self.bits {
127            0 => Some(SpcLpMode::Mode0),
128            1 => Some(SpcLpMode::Mode1),
129            2 => Some(SpcLpMode::Mode2),
130            8 => Some(SpcLpMode::Mode8),
131            _ => None,
132        }
133    }
134    #[doc = "Sleep mode with system clock running"]
135    #[inline(always)]
136    pub fn is_mode0(&self) -> bool {
137        *self == SpcLpMode::Mode0
138    }
139    #[doc = "DSLEEP with system clock off"]
140    #[inline(always)]
141    pub fn is_mode1(&self) -> bool {
142        *self == SpcLpMode::Mode1
143    }
144    #[doc = "PDOWN with system clock off"]
145    #[inline(always)]
146    pub fn is_mode2(&self) -> bool {
147        *self == SpcLpMode::Mode2
148    }
149    #[doc = "DPDOWN with system clock off"]
150    #[inline(always)]
151    pub fn is_mode8(&self) -> bool {
152        *self == SpcLpMode::Mode8
153    }
154}
155#[doc = "Field `ISO_CLR` reader - Isolation Clear Flags"]
156pub type IsoClrR = crate::BitReader;
157#[doc = "Field `ISO_CLR` writer - Isolation Clear Flags"]
158pub type IsoClrW<'a, REG> = crate::BitWriter1C<'a, REG>;
159impl R {
160    #[doc = "Bit 0 - SPC Busy Status Flag"]
161    #[inline(always)]
162    pub fn busy(&self) -> BusyR {
163        BusyR::new((self.bits & 1) != 0)
164    }
165    #[doc = "Bit 1 - SPC Power Mode Configuration Status Flag"]
166    #[inline(always)]
167    pub fn spc_lp_req(&self) -> SpcLpReqR {
168        SpcLpReqR::new(((self.bits >> 1) & 1) != 0)
169    }
170    #[doc = "Bits 4:7 - Power Domain Low-Power Mode Request"]
171    #[inline(always)]
172    pub fn spc_lp_mode(&self) -> SpcLpModeR {
173        SpcLpModeR::new(((self.bits >> 4) & 0x0f) as u8)
174    }
175    #[doc = "Bit 16 - Isolation Clear Flags"]
176    #[inline(always)]
177    pub fn iso_clr(&self) -> IsoClrR {
178        IsoClrR::new(((self.bits >> 16) & 1) != 0)
179    }
180}
181#[cfg(feature = "debug")]
182impl core::fmt::Debug for R {
183    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
184        f.debug_struct("SC")
185            .field("busy", &self.busy())
186            .field("spc_lp_req", &self.spc_lp_req())
187            .field("spc_lp_mode", &self.spc_lp_mode())
188            .field("iso_clr", &self.iso_clr())
189            .finish()
190    }
191}
192impl W {
193    #[doc = "Bit 1 - SPC Power Mode Configuration Status Flag"]
194    #[inline(always)]
195    pub fn spc_lp_req(&mut self) -> SpcLpReqW<'_, ScSpec> {
196        SpcLpReqW::new(self, 1)
197    }
198    #[doc = "Bit 16 - Isolation Clear Flags"]
199    #[inline(always)]
200    pub fn iso_clr(&mut self) -> IsoClrW<'_, ScSpec> {
201        IsoClrW::new(self, 16)
202    }
203}
204#[doc = "Status Control\n\nYou can [`read`](crate::Reg::read) this register and get [`sc::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`sc::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
205pub struct ScSpec;
206impl crate::RegisterSpec for ScSpec {
207    type Ux = u32;
208}
209#[doc = "`read()` method returns [`sc::R`](R) reader structure"]
210impl crate::Readable for ScSpec {}
211#[doc = "`write(|w| ..)` method takes [`sc::W`](W) writer structure"]
212impl crate::Writable for ScSpec {
213    type Safety = crate::Unsafe;
214    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0x0001_0002;
215}
216#[doc = "`reset()` method sets SC to value 0"]
217impl crate::Resettable for ScSpec {}