Skip to main content

mcxa_pac/syscon/
cpu0nstckcal.rs

1#[doc = "Register `CPU0NSTCKCAL` reader"]
2pub type R = crate::R<Cpu0nstckcalSpec>;
3#[doc = "Register `CPU0NSTCKCAL` writer"]
4pub type W = crate::W<Cpu0nstckcalSpec>;
5#[doc = "Field `TENMS` reader - Reload value for 10 ms (100 Hz) timing, subject to system clock skew errors. If the value reads as zero, the calibration value is not known."]
6pub type TenmsR = crate::FieldReader<u32>;
7#[doc = "Field `TENMS` writer - Reload value for 10 ms (100 Hz) timing, subject to system clock skew errors. If the value reads as zero, the calibration value is not known."]
8pub type TenmsW<'a, REG> = crate::FieldWriter<'a, REG, 24, u32>;
9#[doc = "Indicates whether the TENMS value is exact.\n\nValue on reset: 0"]
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum Skew {
13    #[doc = "0: TENMS value is exact"]
14    Exact = 0,
15    #[doc = "1: TENMS value is not exact or not given"]
16    Inexact = 1,
17}
18impl From<Skew> for bool {
19    #[inline(always)]
20    fn from(variant: Skew) -> Self {
21        variant as u8 != 0
22    }
23}
24#[doc = "Field `SKEW` reader - Indicates whether the TENMS value is exact."]
25pub type SkewR = crate::BitReader<Skew>;
26impl SkewR {
27    #[doc = "Get enumerated values variant"]
28    #[inline(always)]
29    pub const fn variant(&self) -> Skew {
30        match self.bits {
31            false => Skew::Exact,
32            true => Skew::Inexact,
33        }
34    }
35    #[doc = "TENMS value is exact"]
36    #[inline(always)]
37    pub fn is_exact(&self) -> bool {
38        *self == Skew::Exact
39    }
40    #[doc = "TENMS value is not exact or not given"]
41    #[inline(always)]
42    pub fn is_inexact(&self) -> bool {
43        *self == Skew::Inexact
44    }
45}
46#[doc = "Field `SKEW` writer - Indicates whether the TENMS value is exact."]
47pub type SkewW<'a, REG> = crate::BitWriter<'a, REG, Skew>;
48impl<'a, REG> SkewW<'a, REG>
49where
50    REG: crate::Writable + crate::RegisterSpec,
51{
52    #[doc = "TENMS value is exact"]
53    #[inline(always)]
54    pub fn exact(self) -> &'a mut crate::W<REG> {
55        self.variant(Skew::Exact)
56    }
57    #[doc = "TENMS value is not exact or not given"]
58    #[inline(always)]
59    pub fn inexact(self) -> &'a mut crate::W<REG> {
60        self.variant(Skew::Inexact)
61    }
62}
63#[doc = "Indicates whether the device provides a reference clock to the processor.\n\nValue on reset: 0"]
64#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66pub enum Noref {
67    #[doc = "0: Reference clock is provided"]
68    YesRef = 0,
69    #[doc = "1: No reference clock is provided"]
70    NoRef = 1,
71}
72impl From<Noref> for bool {
73    #[inline(always)]
74    fn from(variant: Noref) -> Self {
75        variant as u8 != 0
76    }
77}
78#[doc = "Field `NOREF` reader - Indicates whether the device provides a reference clock to the processor."]
79pub type NorefR = crate::BitReader<Noref>;
80impl NorefR {
81    #[doc = "Get enumerated values variant"]
82    #[inline(always)]
83    pub const fn variant(&self) -> Noref {
84        match self.bits {
85            false => Noref::YesRef,
86            true => Noref::NoRef,
87        }
88    }
89    #[doc = "Reference clock is provided"]
90    #[inline(always)]
91    pub fn is_yes_ref(&self) -> bool {
92        *self == Noref::YesRef
93    }
94    #[doc = "No reference clock is provided"]
95    #[inline(always)]
96    pub fn is_no_ref(&self) -> bool {
97        *self == Noref::NoRef
98    }
99}
100#[doc = "Field `NOREF` writer - Indicates whether the device provides a reference clock to the processor."]
101pub type NorefW<'a, REG> = crate::BitWriter<'a, REG, Noref>;
102impl<'a, REG> NorefW<'a, REG>
103where
104    REG: crate::Writable + crate::RegisterSpec,
105{
106    #[doc = "Reference clock is provided"]
107    #[inline(always)]
108    pub fn yes_ref(self) -> &'a mut crate::W<REG> {
109        self.variant(Noref::YesRef)
110    }
111    #[doc = "No reference clock is provided"]
112    #[inline(always)]
113    pub fn no_ref(self) -> &'a mut crate::W<REG> {
114        self.variant(Noref::NoRef)
115    }
116}
117impl R {
118    #[doc = "Bits 0:23 - Reload value for 10 ms (100 Hz) timing, subject to system clock skew errors. If the value reads as zero, the calibration value is not known."]
119    #[inline(always)]
120    pub fn tenms(&self) -> TenmsR {
121        TenmsR::new(self.bits & 0x00ff_ffff)
122    }
123    #[doc = "Bit 24 - Indicates whether the TENMS value is exact."]
124    #[inline(always)]
125    pub fn skew(&self) -> SkewR {
126        SkewR::new(((self.bits >> 24) & 1) != 0)
127    }
128    #[doc = "Bit 25 - Indicates whether the device provides a reference clock to the processor."]
129    #[inline(always)]
130    pub fn noref(&self) -> NorefR {
131        NorefR::new(((self.bits >> 25) & 1) != 0)
132    }
133}
134#[cfg(feature = "debug")]
135impl core::fmt::Debug for R {
136    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
137        f.debug_struct("CPU0NSTCKCAL")
138            .field("tenms", &self.tenms())
139            .field("skew", &self.skew())
140            .field("noref", &self.noref())
141            .finish()
142    }
143}
144impl W {
145    #[doc = "Bits 0:23 - Reload value for 10 ms (100 Hz) timing, subject to system clock skew errors. If the value reads as zero, the calibration value is not known."]
146    #[inline(always)]
147    pub fn tenms(&mut self) -> TenmsW<'_, Cpu0nstckcalSpec> {
148        TenmsW::new(self, 0)
149    }
150    #[doc = "Bit 24 - Indicates whether the TENMS value is exact."]
151    #[inline(always)]
152    pub fn skew(&mut self) -> SkewW<'_, Cpu0nstckcalSpec> {
153        SkewW::new(self, 24)
154    }
155    #[doc = "Bit 25 - Indicates whether the device provides a reference clock to the processor."]
156    #[inline(always)]
157    pub fn noref(&mut self) -> NorefW<'_, Cpu0nstckcalSpec> {
158        NorefW::new(self, 25)
159    }
160}
161#[doc = "Non-Secure CPU0 System Tick Calibration\n\nYou can [`read`](crate::Reg::read) this register and get [`cpu0nstckcal::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cpu0nstckcal::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
162pub struct Cpu0nstckcalSpec;
163impl crate::RegisterSpec for Cpu0nstckcalSpec {
164    type Ux = u32;
165}
166#[doc = "`read()` method returns [`cpu0nstckcal::R`](R) reader structure"]
167impl crate::Readable for Cpu0nstckcalSpec {}
168#[doc = "`write(|w| ..)` method takes [`cpu0nstckcal::W`](W) writer structure"]
169impl crate::Writable for Cpu0nstckcalSpec {
170    type Safety = crate::Unsafe;
171}
172#[doc = "`reset()` method sets CPU0NSTCKCAL to value 0"]
173impl crate::Resettable for Cpu0nstckcalSpec {}