Skip to main content

mcxa_pac/freqme0/
ctrlstat.rs

1#[doc = "Register `CTRLSTAT` reader"]
2pub type R = crate::R<CtrlstatSpec>;
3#[doc = "Register `CTRLSTAT` writer"]
4pub type W = crate::W<CtrlstatSpec>;
5#[doc = "Field `REF_SCALE` reader - Reference Scale"]
6pub type RefScaleR = crate::FieldReader;
7#[doc = "Pulse Mode\n\nValue on reset: 0"]
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum PulseMode {
11    #[doc = "0: Frequency Measurement mode"]
12    Freq = 0,
13    #[doc = "1: Pulse Width Measurement mode"]
14    Pulse = 1,
15}
16impl From<PulseMode> for bool {
17    #[inline(always)]
18    fn from(variant: PulseMode) -> Self {
19        variant as u8 != 0
20    }
21}
22#[doc = "Field `PULSE_MODE` reader - Pulse Mode"]
23pub type PulseModeR = crate::BitReader<PulseMode>;
24impl PulseModeR {
25    #[doc = "Get enumerated values variant"]
26    #[inline(always)]
27    pub const fn variant(&self) -> PulseMode {
28        match self.bits {
29            false => PulseMode::Freq,
30            true => PulseMode::Pulse,
31        }
32    }
33    #[doc = "Frequency Measurement mode"]
34    #[inline(always)]
35    pub fn is_freq(&self) -> bool {
36        *self == PulseMode::Freq
37    }
38    #[doc = "Pulse Width Measurement mode"]
39    #[inline(always)]
40    pub fn is_pulse(&self) -> bool {
41        *self == PulseMode::Pulse
42    }
43}
44#[doc = "Pulse Polarity\n\nValue on reset: 0"]
45#[cfg_attr(feature = "defmt", derive(defmt::Format))]
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub enum PulsePol {
48    #[doc = "0: High period"]
49    High = 0,
50    #[doc = "1: Low period"]
51    Low = 1,
52}
53impl From<PulsePol> for bool {
54    #[inline(always)]
55    fn from(variant: PulsePol) -> Self {
56        variant as u8 != 0
57    }
58}
59#[doc = "Field `PULSE_POL` reader - Pulse Polarity"]
60pub type PulsePolR = crate::BitReader<PulsePol>;
61impl PulsePolR {
62    #[doc = "Get enumerated values variant"]
63    #[inline(always)]
64    pub const fn variant(&self) -> PulsePol {
65        match self.bits {
66            false => PulsePol::High,
67            true => PulsePol::Low,
68        }
69    }
70    #[doc = "High period"]
71    #[inline(always)]
72    pub fn is_high(&self) -> bool {
73        *self == PulsePol::High
74    }
75    #[doc = "Low period"]
76    #[inline(always)]
77    pub fn is_low(&self) -> bool {
78        *self == PulsePol::Low
79    }
80}
81#[doc = "Less Than Minimum Interrupt Enable\n\nValue on reset: 0"]
82#[cfg_attr(feature = "defmt", derive(defmt::Format))]
83#[derive(Clone, Copy, Debug, PartialEq, Eq)]
84pub enum LtMinIntEn {
85    #[doc = "0: Disabled"]
86    Disabled = 0,
87    #[doc = "1: Enabled"]
88    Enabled = 1,
89}
90impl From<LtMinIntEn> for bool {
91    #[inline(always)]
92    fn from(variant: LtMinIntEn) -> Self {
93        variant as u8 != 0
94    }
95}
96#[doc = "Field `LT_MIN_INT_EN` reader - Less Than Minimum Interrupt Enable"]
97pub type LtMinIntEnR = crate::BitReader<LtMinIntEn>;
98impl LtMinIntEnR {
99    #[doc = "Get enumerated values variant"]
100    #[inline(always)]
101    pub const fn variant(&self) -> LtMinIntEn {
102        match self.bits {
103            false => LtMinIntEn::Disabled,
104            true => LtMinIntEn::Enabled,
105        }
106    }
107    #[doc = "Disabled"]
108    #[inline(always)]
109    pub fn is_disabled(&self) -> bool {
110        *self == LtMinIntEn::Disabled
111    }
112    #[doc = "Enabled"]
113    #[inline(always)]
114    pub fn is_enabled(&self) -> bool {
115        *self == LtMinIntEn::Enabled
116    }
117}
118#[doc = "Greater Than Maximum Interrupt Enable\n\nValue on reset: 0"]
119#[cfg_attr(feature = "defmt", derive(defmt::Format))]
120#[derive(Clone, Copy, Debug, PartialEq, Eq)]
121pub enum GtMaxIntEn {
122    #[doc = "0: Disabled"]
123    Disabled = 0,
124    #[doc = "1: Enabled"]
125    Enabled = 1,
126}
127impl From<GtMaxIntEn> for bool {
128    #[inline(always)]
129    fn from(variant: GtMaxIntEn) -> Self {
130        variant as u8 != 0
131    }
132}
133#[doc = "Field `GT_MAX_INT_EN` reader - Greater Than Maximum Interrupt Enable"]
134pub type GtMaxIntEnR = crate::BitReader<GtMaxIntEn>;
135impl GtMaxIntEnR {
136    #[doc = "Get enumerated values variant"]
137    #[inline(always)]
138    pub const fn variant(&self) -> GtMaxIntEn {
139        match self.bits {
140            false => GtMaxIntEn::Disabled,
141            true => GtMaxIntEn::Enabled,
142        }
143    }
144    #[doc = "Disabled"]
145    #[inline(always)]
146    pub fn is_disabled(&self) -> bool {
147        *self == GtMaxIntEn::Disabled
148    }
149    #[doc = "Enabled"]
150    #[inline(always)]
151    pub fn is_enabled(&self) -> bool {
152        *self == GtMaxIntEn::Enabled
153    }
154}
155#[doc = "Result Ready Interrupt Enable\n\nValue on reset: 0"]
156#[cfg_attr(feature = "defmt", derive(defmt::Format))]
157#[derive(Clone, Copy, Debug, PartialEq, Eq)]
158pub enum ResultReadyIntEn {
159    #[doc = "0: Disabled"]
160    Disabled = 0,
161    #[doc = "1: Enabled"]
162    Enabled = 1,
163}
164impl From<ResultReadyIntEn> for bool {
165    #[inline(always)]
166    fn from(variant: ResultReadyIntEn) -> Self {
167        variant as u8 != 0
168    }
169}
170#[doc = "Field `RESULT_READY_INT_EN` reader - Result Ready Interrupt Enable"]
171pub type ResultReadyIntEnR = crate::BitReader<ResultReadyIntEn>;
172impl ResultReadyIntEnR {
173    #[doc = "Get enumerated values variant"]
174    #[inline(always)]
175    pub const fn variant(&self) -> ResultReadyIntEn {
176        match self.bits {
177            false => ResultReadyIntEn::Disabled,
178            true => ResultReadyIntEn::Enabled,
179        }
180    }
181    #[doc = "Disabled"]
182    #[inline(always)]
183    pub fn is_disabled(&self) -> bool {
184        *self == ResultReadyIntEn::Disabled
185    }
186    #[doc = "Enabled"]
187    #[inline(always)]
188    pub fn is_enabled(&self) -> bool {
189        *self == ResultReadyIntEn::Enabled
190    }
191}
192#[doc = "Less Than Minimum Results Status\n\nValue on reset: 0"]
193#[cfg_attr(feature = "defmt", derive(defmt::Format))]
194#[derive(Clone, Copy, Debug, PartialEq, Eq)]
195pub enum LtMinStat {
196    #[doc = "0: Greater than MIN\\[MIN_VALUE\\]"]
197    InRange = 0,
198    #[doc = "1: Less than MIN\\[MIN_VALUE\\]"]
199    LtMin = 1,
200}
201impl From<LtMinStat> for bool {
202    #[inline(always)]
203    fn from(variant: LtMinStat) -> Self {
204        variant as u8 != 0
205    }
206}
207#[doc = "Field `LT_MIN_STAT` reader - Less Than Minimum Results Status"]
208pub type LtMinStatR = crate::BitReader<LtMinStat>;
209impl LtMinStatR {
210    #[doc = "Get enumerated values variant"]
211    #[inline(always)]
212    pub const fn variant(&self) -> LtMinStat {
213        match self.bits {
214            false => LtMinStat::InRange,
215            true => LtMinStat::LtMin,
216        }
217    }
218    #[doc = "Greater than MIN\\[MIN_VALUE\\]"]
219    #[inline(always)]
220    pub fn is_in_range(&self) -> bool {
221        *self == LtMinStat::InRange
222    }
223    #[doc = "Less than MIN\\[MIN_VALUE\\]"]
224    #[inline(always)]
225    pub fn is_lt_min(&self) -> bool {
226        *self == LtMinStat::LtMin
227    }
228}
229#[doc = "Field `LT_MIN_STAT` writer - Less Than Minimum Results Status"]
230pub type LtMinStatW<'a, REG> = crate::BitWriter1C<'a, REG, LtMinStat>;
231impl<'a, REG> LtMinStatW<'a, REG>
232where
233    REG: crate::Writable + crate::RegisterSpec,
234{
235    #[doc = "Greater than MIN\\[MIN_VALUE\\]"]
236    #[inline(always)]
237    pub fn in_range(self) -> &'a mut crate::W<REG> {
238        self.variant(LtMinStat::InRange)
239    }
240    #[doc = "Less than MIN\\[MIN_VALUE\\]"]
241    #[inline(always)]
242    pub fn lt_min(self) -> &'a mut crate::W<REG> {
243        self.variant(LtMinStat::LtMin)
244    }
245}
246#[doc = "Greater Than Maximum Result Status\n\nValue on reset: 0"]
247#[cfg_attr(feature = "defmt", derive(defmt::Format))]
248#[derive(Clone, Copy, Debug, PartialEq, Eq)]
249pub enum GtMaxStat {
250    #[doc = "0: Less than MAX\\[MAX_VALUE\\]"]
251    InRange = 0,
252    #[doc = "1: Greater than MAX\\[MAX_VALUE\\]"]
253    GtMax = 1,
254}
255impl From<GtMaxStat> for bool {
256    #[inline(always)]
257    fn from(variant: GtMaxStat) -> Self {
258        variant as u8 != 0
259    }
260}
261#[doc = "Field `GT_MAX_STAT` reader - Greater Than Maximum Result Status"]
262pub type GtMaxStatR = crate::BitReader<GtMaxStat>;
263impl GtMaxStatR {
264    #[doc = "Get enumerated values variant"]
265    #[inline(always)]
266    pub const fn variant(&self) -> GtMaxStat {
267        match self.bits {
268            false => GtMaxStat::InRange,
269            true => GtMaxStat::GtMax,
270        }
271    }
272    #[doc = "Less than MAX\\[MAX_VALUE\\]"]
273    #[inline(always)]
274    pub fn is_in_range(&self) -> bool {
275        *self == GtMaxStat::InRange
276    }
277    #[doc = "Greater than MAX\\[MAX_VALUE\\]"]
278    #[inline(always)]
279    pub fn is_gt_max(&self) -> bool {
280        *self == GtMaxStat::GtMax
281    }
282}
283#[doc = "Field `GT_MAX_STAT` writer - Greater Than Maximum Result Status"]
284pub type GtMaxStatW<'a, REG> = crate::BitWriter1C<'a, REG, GtMaxStat>;
285impl<'a, REG> GtMaxStatW<'a, REG>
286where
287    REG: crate::Writable + crate::RegisterSpec,
288{
289    #[doc = "Less than MAX\\[MAX_VALUE\\]"]
290    #[inline(always)]
291    pub fn in_range(self) -> &'a mut crate::W<REG> {
292        self.variant(GtMaxStat::InRange)
293    }
294    #[doc = "Greater than MAX\\[MAX_VALUE\\]"]
295    #[inline(always)]
296    pub fn gt_max(self) -> &'a mut crate::W<REG> {
297        self.variant(GtMaxStat::GtMax)
298    }
299}
300#[doc = "Result Ready Status\n\nValue on reset: 0"]
301#[cfg_attr(feature = "defmt", derive(defmt::Format))]
302#[derive(Clone, Copy, Debug, PartialEq, Eq)]
303pub enum ResultReadyStat {
304    #[doc = "0: Not complete"]
305    NotComplete = 0,
306    #[doc = "1: Complete"]
307    Complete = 1,
308}
309impl From<ResultReadyStat> for bool {
310    #[inline(always)]
311    fn from(variant: ResultReadyStat) -> Self {
312        variant as u8 != 0
313    }
314}
315#[doc = "Field `RESULT_READY_STAT` reader - Result Ready Status"]
316pub type ResultReadyStatR = crate::BitReader<ResultReadyStat>;
317impl ResultReadyStatR {
318    #[doc = "Get enumerated values variant"]
319    #[inline(always)]
320    pub const fn variant(&self) -> ResultReadyStat {
321        match self.bits {
322            false => ResultReadyStat::NotComplete,
323            true => ResultReadyStat::Complete,
324        }
325    }
326    #[doc = "Not complete"]
327    #[inline(always)]
328    pub fn is_not_complete(&self) -> bool {
329        *self == ResultReadyStat::NotComplete
330    }
331    #[doc = "Complete"]
332    #[inline(always)]
333    pub fn is_complete(&self) -> bool {
334        *self == ResultReadyStat::Complete
335    }
336}
337#[doc = "Field `RESULT_READY_STAT` writer - Result Ready Status"]
338pub type ResultReadyStatW<'a, REG> = crate::BitWriter1C<'a, REG, ResultReadyStat>;
339impl<'a, REG> ResultReadyStatW<'a, REG>
340where
341    REG: crate::Writable + crate::RegisterSpec,
342{
343    #[doc = "Not complete"]
344    #[inline(always)]
345    pub fn not_complete(self) -> &'a mut crate::W<REG> {
346        self.variant(ResultReadyStat::NotComplete)
347    }
348    #[doc = "Complete"]
349    #[inline(always)]
350    pub fn complete(self) -> &'a mut crate::W<REG> {
351        self.variant(ResultReadyStat::Complete)
352    }
353}
354#[doc = "Continuous Mode Enable Status\n\nValue on reset: 0"]
355#[cfg_attr(feature = "defmt", derive(defmt::Format))]
356#[derive(Clone, Copy, Debug, PartialEq, Eq)]
357pub enum ContinuousModeEn {
358    #[doc = "0: Disabled"]
359    Disabled = 0,
360    #[doc = "1: Enabled"]
361    Enabled = 1,
362}
363impl From<ContinuousModeEn> for bool {
364    #[inline(always)]
365    fn from(variant: ContinuousModeEn) -> Self {
366        variant as u8 != 0
367    }
368}
369#[doc = "Field `CONTINUOUS_MODE_EN` reader - Continuous Mode Enable Status"]
370pub type ContinuousModeEnR = crate::BitReader<ContinuousModeEn>;
371impl ContinuousModeEnR {
372    #[doc = "Get enumerated values variant"]
373    #[inline(always)]
374    pub const fn variant(&self) -> ContinuousModeEn {
375        match self.bits {
376            false => ContinuousModeEn::Disabled,
377            true => ContinuousModeEn::Enabled,
378        }
379    }
380    #[doc = "Disabled"]
381    #[inline(always)]
382    pub fn is_disabled(&self) -> bool {
383        *self == ContinuousModeEn::Disabled
384    }
385    #[doc = "Enabled"]
386    #[inline(always)]
387    pub fn is_enabled(&self) -> bool {
388        *self == ContinuousModeEn::Enabled
389    }
390}
391#[doc = "Measurement in Progress Status\n\nValue on reset: 0"]
392#[cfg_attr(feature = "defmt", derive(defmt::Format))]
393#[derive(Clone, Copy, Debug, PartialEq, Eq)]
394pub enum MeasureInProgress {
395    #[doc = "0: Not in progress"]
396    Idle = 0,
397    #[doc = "1: In progress"]
398    Ongoing = 1,
399}
400impl From<MeasureInProgress> for bool {
401    #[inline(always)]
402    fn from(variant: MeasureInProgress) -> Self {
403        variant as u8 != 0
404    }
405}
406#[doc = "Field `MEASURE_IN_PROGRESS` reader - Measurement in Progress Status"]
407pub type MeasureInProgressR = crate::BitReader<MeasureInProgress>;
408impl MeasureInProgressR {
409    #[doc = "Get enumerated values variant"]
410    #[inline(always)]
411    pub const fn variant(&self) -> MeasureInProgress {
412        match self.bits {
413            false => MeasureInProgress::Idle,
414            true => MeasureInProgress::Ongoing,
415        }
416    }
417    #[doc = "Not in progress"]
418    #[inline(always)]
419    pub fn is_idle(&self) -> bool {
420        *self == MeasureInProgress::Idle
421    }
422    #[doc = "In progress"]
423    #[inline(always)]
424    pub fn is_ongoing(&self) -> bool {
425        *self == MeasureInProgress::Ongoing
426    }
427}
428impl R {
429    #[doc = "Bits 0:4 - Reference Scale"]
430    #[inline(always)]
431    pub fn ref_scale(&self) -> RefScaleR {
432        RefScaleR::new((self.bits & 0x1f) as u8)
433    }
434    #[doc = "Bit 8 - Pulse Mode"]
435    #[inline(always)]
436    pub fn pulse_mode(&self) -> PulseModeR {
437        PulseModeR::new(((self.bits >> 8) & 1) != 0)
438    }
439    #[doc = "Bit 9 - Pulse Polarity"]
440    #[inline(always)]
441    pub fn pulse_pol(&self) -> PulsePolR {
442        PulsePolR::new(((self.bits >> 9) & 1) != 0)
443    }
444    #[doc = "Bit 12 - Less Than Minimum Interrupt Enable"]
445    #[inline(always)]
446    pub fn lt_min_int_en(&self) -> LtMinIntEnR {
447        LtMinIntEnR::new(((self.bits >> 12) & 1) != 0)
448    }
449    #[doc = "Bit 13 - Greater Than Maximum Interrupt Enable"]
450    #[inline(always)]
451    pub fn gt_max_int_en(&self) -> GtMaxIntEnR {
452        GtMaxIntEnR::new(((self.bits >> 13) & 1) != 0)
453    }
454    #[doc = "Bit 14 - Result Ready Interrupt Enable"]
455    #[inline(always)]
456    pub fn result_ready_int_en(&self) -> ResultReadyIntEnR {
457        ResultReadyIntEnR::new(((self.bits >> 14) & 1) != 0)
458    }
459    #[doc = "Bit 24 - Less Than Minimum Results Status"]
460    #[inline(always)]
461    pub fn lt_min_stat(&self) -> LtMinStatR {
462        LtMinStatR::new(((self.bits >> 24) & 1) != 0)
463    }
464    #[doc = "Bit 25 - Greater Than Maximum Result Status"]
465    #[inline(always)]
466    pub fn gt_max_stat(&self) -> GtMaxStatR {
467        GtMaxStatR::new(((self.bits >> 25) & 1) != 0)
468    }
469    #[doc = "Bit 26 - Result Ready Status"]
470    #[inline(always)]
471    pub fn result_ready_stat(&self) -> ResultReadyStatR {
472        ResultReadyStatR::new(((self.bits >> 26) & 1) != 0)
473    }
474    #[doc = "Bit 30 - Continuous Mode Enable Status"]
475    #[inline(always)]
476    pub fn continuous_mode_en(&self) -> ContinuousModeEnR {
477        ContinuousModeEnR::new(((self.bits >> 30) & 1) != 0)
478    }
479    #[doc = "Bit 31 - Measurement in Progress Status"]
480    #[inline(always)]
481    pub fn measure_in_progress(&self) -> MeasureInProgressR {
482        MeasureInProgressR::new(((self.bits >> 31) & 1) != 0)
483    }
484}
485#[cfg(feature = "debug")]
486impl core::fmt::Debug for R {
487    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
488        f.debug_struct("CTRLSTAT")
489            .field("ref_scale", &self.ref_scale())
490            .field("pulse_mode", &self.pulse_mode())
491            .field("pulse_pol", &self.pulse_pol())
492            .field("lt_min_int_en", &self.lt_min_int_en())
493            .field("gt_max_int_en", &self.gt_max_int_en())
494            .field("result_ready_int_en", &self.result_ready_int_en())
495            .field("lt_min_stat", &self.lt_min_stat())
496            .field("gt_max_stat", &self.gt_max_stat())
497            .field("result_ready_stat", &self.result_ready_stat())
498            .field("continuous_mode_en", &self.continuous_mode_en())
499            .field("measure_in_progress", &self.measure_in_progress())
500            .finish()
501    }
502}
503impl W {
504    #[doc = "Bit 24 - Less Than Minimum Results Status"]
505    #[inline(always)]
506    pub fn lt_min_stat(&mut self) -> LtMinStatW<'_, CtrlstatSpec> {
507        LtMinStatW::new(self, 24)
508    }
509    #[doc = "Bit 25 - Greater Than Maximum Result Status"]
510    #[inline(always)]
511    pub fn gt_max_stat(&mut self) -> GtMaxStatW<'_, CtrlstatSpec> {
512        GtMaxStatW::new(self, 25)
513    }
514    #[doc = "Bit 26 - Result Ready Status"]
515    #[inline(always)]
516    pub fn result_ready_stat(&mut self) -> ResultReadyStatW<'_, CtrlstatSpec> {
517        ResultReadyStatW::new(self, 26)
518    }
519}
520#[doc = "Control Status\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrlstat::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrlstat::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
521pub struct CtrlstatSpec;
522impl crate::RegisterSpec for CtrlstatSpec {
523    type Ux = u32;
524}
525#[doc = "`read()` method returns [`ctrlstat::R`](R) reader structure"]
526impl crate::Readable for CtrlstatSpec {}
527#[doc = "`write(|w| ..)` method takes [`ctrlstat::W`](W) writer structure"]
528impl crate::Writable for CtrlstatSpec {
529    type Safety = crate::Unsafe;
530    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0x0700_0000;
531}
532#[doc = "`reset()` method sets CTRLSTAT to value 0"]
533impl crate::Resettable for CtrlstatSpec {}