mcxa_pac/tdet0/
cr.rs

1#[doc = "Register `CR` reader"]
2pub type R = crate::R<CrSpec>;
3#[doc = "Register `CR` writer"]
4pub type W = crate::W<CrSpec>;
5#[doc = "Software Reset\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Swr {
9    #[doc = "0: No effect"]
10    NoEffect = 0,
11    #[doc = "1: Perform a software reset"]
12    SwReset = 1,
13}
14impl From<Swr> for bool {
15    #[inline(always)]
16    fn from(variant: Swr) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `SWR` reader - Software Reset"]
21pub type SwrR = crate::BitReader<Swr>;
22impl SwrR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Swr {
26        match self.bits {
27            false => Swr::NoEffect,
28            true => Swr::SwReset,
29        }
30    }
31    #[doc = "No effect"]
32    #[inline(always)]
33    pub fn is_no_effect(&self) -> bool {
34        *self == Swr::NoEffect
35    }
36    #[doc = "Perform a software reset"]
37    #[inline(always)]
38    pub fn is_sw_reset(&self) -> bool {
39        *self == Swr::SwReset
40    }
41}
42#[doc = "Field `SWR` writer - Software Reset"]
43pub type SwrW<'a, REG> = crate::BitWriter<'a, REG, Swr>;
44impl<'a, REG> SwrW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "No effect"]
49    #[inline(always)]
50    pub fn no_effect(self) -> &'a mut crate::W<REG> {
51        self.variant(Swr::NoEffect)
52    }
53    #[doc = "Perform a software reset"]
54    #[inline(always)]
55    pub fn sw_reset(self) -> &'a mut crate::W<REG> {
56        self.variant(Swr::SwReset)
57    }
58}
59#[doc = "Digital Tamper Enable\n\nValue on reset: 0"]
60#[cfg_attr(feature = "defmt", derive(defmt::Format))]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum Den {
63    #[doc = "0: Disables TDET clock and prescaler"]
64    Disable = 0,
65    #[doc = "1: Enables TDET clock and prescaler"]
66    Enable = 1,
67}
68impl From<Den> for bool {
69    #[inline(always)]
70    fn from(variant: Den) -> Self {
71        variant as u8 != 0
72    }
73}
74#[doc = "Field `DEN` reader - Digital Tamper Enable"]
75pub type DenR = crate::BitReader<Den>;
76impl DenR {
77    #[doc = "Get enumerated values variant"]
78    #[inline(always)]
79    pub const fn variant(&self) -> Den {
80        match self.bits {
81            false => Den::Disable,
82            true => Den::Enable,
83        }
84    }
85    #[doc = "Disables TDET clock and prescaler"]
86    #[inline(always)]
87    pub fn is_disable(&self) -> bool {
88        *self == Den::Disable
89    }
90    #[doc = "Enables TDET clock and prescaler"]
91    #[inline(always)]
92    pub fn is_enable(&self) -> bool {
93        *self == Den::Enable
94    }
95}
96#[doc = "Field `DEN` writer - Digital Tamper Enable"]
97pub type DenW<'a, REG> = crate::BitWriter<'a, REG, Den>;
98impl<'a, REG> DenW<'a, REG>
99where
100    REG: crate::Writable + crate::RegisterSpec,
101{
102    #[doc = "Disables TDET clock and prescaler"]
103    #[inline(always)]
104    pub fn disable(self) -> &'a mut crate::W<REG> {
105        self.variant(Den::Disable)
106    }
107    #[doc = "Enables TDET clock and prescaler"]
108    #[inline(always)]
109    pub fn enable(self) -> &'a mut crate::W<REG> {
110        self.variant(Den::Enable)
111    }
112}
113#[doc = "Tamper Force System Reset\n\nValue on reset: 0"]
114#[cfg_attr(feature = "defmt", derive(defmt::Format))]
115#[derive(Clone, Copy, Debug, PartialEq, Eq)]
116pub enum Tfsr {
117    #[doc = "0: Do not force chip reset"]
118    NoReset = 0,
119    #[doc = "1: Force chip reset"]
120    Reset = 1,
121}
122impl From<Tfsr> for bool {
123    #[inline(always)]
124    fn from(variant: Tfsr) -> Self {
125        variant as u8 != 0
126    }
127}
128#[doc = "Field `TFSR` reader - Tamper Force System Reset"]
129pub type TfsrR = crate::BitReader<Tfsr>;
130impl TfsrR {
131    #[doc = "Get enumerated values variant"]
132    #[inline(always)]
133    pub const fn variant(&self) -> Tfsr {
134        match self.bits {
135            false => Tfsr::NoReset,
136            true => Tfsr::Reset,
137        }
138    }
139    #[doc = "Do not force chip reset"]
140    #[inline(always)]
141    pub fn is_no_reset(&self) -> bool {
142        *self == Tfsr::NoReset
143    }
144    #[doc = "Force chip reset"]
145    #[inline(always)]
146    pub fn is_reset(&self) -> bool {
147        *self == Tfsr::Reset
148    }
149}
150#[doc = "Field `TFSR` writer - Tamper Force System Reset"]
151pub type TfsrW<'a, REG> = crate::BitWriter<'a, REG, Tfsr>;
152impl<'a, REG> TfsrW<'a, REG>
153where
154    REG: crate::Writable + crate::RegisterSpec,
155{
156    #[doc = "Do not force chip reset"]
157    #[inline(always)]
158    pub fn no_reset(self) -> &'a mut crate::W<REG> {
159        self.variant(Tfsr::NoReset)
160    }
161    #[doc = "Force chip reset"]
162    #[inline(always)]
163    pub fn reset(self) -> &'a mut crate::W<REG> {
164        self.variant(Tfsr::Reset)
165    }
166}
167#[doc = "Update Mode\n\nValue on reset: 0"]
168#[cfg_attr(feature = "defmt", derive(defmt::Format))]
169#[derive(Clone, Copy, Debug, PartialEq, Eq)]
170pub enum Um {
171    #[doc = "0: No effect"]
172    NoEffect = 0,
173    #[doc = "1: Allows the clearing of interrupts"]
174    ClearInts = 1,
175}
176impl From<Um> for bool {
177    #[inline(always)]
178    fn from(variant: Um) -> Self {
179        variant as u8 != 0
180    }
181}
182#[doc = "Field `UM` reader - Update Mode"]
183pub type UmR = crate::BitReader<Um>;
184impl UmR {
185    #[doc = "Get enumerated values variant"]
186    #[inline(always)]
187    pub const fn variant(&self) -> Um {
188        match self.bits {
189            false => Um::NoEffect,
190            true => Um::ClearInts,
191        }
192    }
193    #[doc = "No effect"]
194    #[inline(always)]
195    pub fn is_no_effect(&self) -> bool {
196        *self == Um::NoEffect
197    }
198    #[doc = "Allows the clearing of interrupts"]
199    #[inline(always)]
200    pub fn is_clear_ints(&self) -> bool {
201        *self == Um::ClearInts
202    }
203}
204#[doc = "Field `UM` writer - Update Mode"]
205pub type UmW<'a, REG> = crate::BitWriter<'a, REG, Um>;
206impl<'a, REG> UmW<'a, REG>
207where
208    REG: crate::Writable + crate::RegisterSpec,
209{
210    #[doc = "No effect"]
211    #[inline(always)]
212    pub fn no_effect(self) -> &'a mut crate::W<REG> {
213        self.variant(Um::NoEffect)
214    }
215    #[doc = "Allows the clearing of interrupts"]
216    #[inline(always)]
217    pub fn clear_ints(self) -> &'a mut crate::W<REG> {
218        self.variant(Um::ClearInts)
219    }
220}
221#[doc = "Disable Prescaler On Tamper\n\nValue on reset: 0"]
222#[cfg_attr(feature = "defmt", derive(defmt::Format))]
223#[derive(Clone, Copy, Debug, PartialEq, Eq)]
224pub enum Distam {
225    #[doc = "0: No effect"]
226    NoEffect = 0,
227    #[doc = "1: Automatically disables the prescaler after tamper detection"]
228    AutoDis = 1,
229}
230impl From<Distam> for bool {
231    #[inline(always)]
232    fn from(variant: Distam) -> Self {
233        variant as u8 != 0
234    }
235}
236#[doc = "Field `DISTAM` reader - Disable Prescaler On Tamper"]
237pub type DistamR = crate::BitReader<Distam>;
238impl DistamR {
239    #[doc = "Get enumerated values variant"]
240    #[inline(always)]
241    pub const fn variant(&self) -> Distam {
242        match self.bits {
243            false => Distam::NoEffect,
244            true => Distam::AutoDis,
245        }
246    }
247    #[doc = "No effect"]
248    #[inline(always)]
249    pub fn is_no_effect(&self) -> bool {
250        *self == Distam::NoEffect
251    }
252    #[doc = "Automatically disables the prescaler after tamper detection"]
253    #[inline(always)]
254    pub fn is_auto_dis(&self) -> bool {
255        *self == Distam::AutoDis
256    }
257}
258#[doc = "Field `DISTAM` writer - Disable Prescaler On Tamper"]
259pub type DistamW<'a, REG> = crate::BitWriter<'a, REG, Distam>;
260impl<'a, REG> DistamW<'a, REG>
261where
262    REG: crate::Writable + crate::RegisterSpec,
263{
264    #[doc = "No effect"]
265    #[inline(always)]
266    pub fn no_effect(self) -> &'a mut crate::W<REG> {
267        self.variant(Distam::NoEffect)
268    }
269    #[doc = "Automatically disables the prescaler after tamper detection"]
270    #[inline(always)]
271    pub fn auto_dis(self) -> &'a mut crate::W<REG> {
272        self.variant(Distam::AutoDis)
273    }
274}
275#[doc = "Field `DPR` reader - Digital Tamper Prescaler"]
276pub type DprR = crate::FieldReader<u16>;
277#[doc = "Field `DPR` writer - Digital Tamper Prescaler"]
278pub type DprW<'a, REG> = crate::FieldWriter<'a, REG, 15, u16>;
279impl R {
280    #[doc = "Bit 0 - Software Reset"]
281    #[inline(always)]
282    pub fn swr(&self) -> SwrR {
283        SwrR::new((self.bits & 1) != 0)
284    }
285    #[doc = "Bit 1 - Digital Tamper Enable"]
286    #[inline(always)]
287    pub fn den(&self) -> DenR {
288        DenR::new(((self.bits >> 1) & 1) != 0)
289    }
290    #[doc = "Bit 2 - Tamper Force System Reset"]
291    #[inline(always)]
292    pub fn tfsr(&self) -> TfsrR {
293        TfsrR::new(((self.bits >> 2) & 1) != 0)
294    }
295    #[doc = "Bit 3 - Update Mode"]
296    #[inline(always)]
297    pub fn um(&self) -> UmR {
298        UmR::new(((self.bits >> 3) & 1) != 0)
299    }
300    #[doc = "Bit 8 - Disable Prescaler On Tamper"]
301    #[inline(always)]
302    pub fn distam(&self) -> DistamR {
303        DistamR::new(((self.bits >> 8) & 1) != 0)
304    }
305    #[doc = "Bits 17:31 - Digital Tamper Prescaler"]
306    #[inline(always)]
307    pub fn dpr(&self) -> DprR {
308        DprR::new(((self.bits >> 17) & 0x7fff) as u16)
309    }
310}
311#[cfg(feature = "debug")]
312impl core::fmt::Debug for R {
313    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
314        f.debug_struct("CR")
315            .field("swr", &self.swr())
316            .field("den", &self.den())
317            .field("tfsr", &self.tfsr())
318            .field("um", &self.um())
319            .field("distam", &self.distam())
320            .field("dpr", &self.dpr())
321            .finish()
322    }
323}
324impl W {
325    #[doc = "Bit 0 - Software Reset"]
326    #[inline(always)]
327    pub fn swr(&mut self) -> SwrW<'_, CrSpec> {
328        SwrW::new(self, 0)
329    }
330    #[doc = "Bit 1 - Digital Tamper Enable"]
331    #[inline(always)]
332    pub fn den(&mut self) -> DenW<'_, CrSpec> {
333        DenW::new(self, 1)
334    }
335    #[doc = "Bit 2 - Tamper Force System Reset"]
336    #[inline(always)]
337    pub fn tfsr(&mut self) -> TfsrW<'_, CrSpec> {
338        TfsrW::new(self, 2)
339    }
340    #[doc = "Bit 3 - Update Mode"]
341    #[inline(always)]
342    pub fn um(&mut self) -> UmW<'_, CrSpec> {
343        UmW::new(self, 3)
344    }
345    #[doc = "Bit 8 - Disable Prescaler On Tamper"]
346    #[inline(always)]
347    pub fn distam(&mut self) -> DistamW<'_, CrSpec> {
348        DistamW::new(self, 8)
349    }
350    #[doc = "Bits 17:31 - Digital Tamper Prescaler"]
351    #[inline(always)]
352    pub fn dpr(&mut self) -> DprW<'_, CrSpec> {
353        DprW::new(self, 17)
354    }
355}
356#[doc = "Control\n\nYou can [`read`](crate::Reg::read) this register and get [`cr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
357pub struct CrSpec;
358impl crate::RegisterSpec for CrSpec {
359    type Ux = u32;
360}
361#[doc = "`read()` method returns [`cr::R`](R) reader structure"]
362impl crate::Readable for CrSpec {}
363#[doc = "`write(|w| ..)` method takes [`cr::W`](W) writer structure"]
364impl crate::Writable for CrSpec {
365    type Safety = crate::Unsafe;
366}
367#[doc = "`reset()` method sets CR to value 0"]
368impl crate::Resettable for CrSpec {}