Skip to main content

mcxa_pac/freqme0/
ctrl_w.rs

1#[doc = "Register `CTRL_W` writer"]
2pub type W = crate::W<CtrlWSpec>;
3#[doc = "Field `REF_SCALE` writer - Reference Clock Scaling Factor"]
4pub type RefScaleW<'a, REG> = crate::FieldWriter<'a, REG, 5>;
5#[doc = "Pulse Width Measurement Mode Select\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum PulseMode {
9    #[doc = "0: Frequency Measurement mode"]
10    FreqMeMode = 0,
11    #[doc = "1: Pulse Width Measurement mode"]
12    PulseMeMode = 1,
13}
14impl From<PulseMode> for bool {
15    #[inline(always)]
16    fn from(variant: PulseMode) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `PULSE_MODE` writer - Pulse Width Measurement Mode Select"]
21pub type PulseModeW<'a, REG> = crate::BitWriter<'a, REG, PulseMode>;
22impl<'a, REG> PulseModeW<'a, REG>
23where
24    REG: crate::Writable + crate::RegisterSpec,
25{
26    #[doc = "Frequency Measurement mode"]
27    #[inline(always)]
28    pub fn freq_me_mode(self) -> &'a mut crate::W<REG> {
29        self.variant(PulseMode::FreqMeMode)
30    }
31    #[doc = "Pulse Width Measurement mode"]
32    #[inline(always)]
33    pub fn pulse_me_mode(self) -> &'a mut crate::W<REG> {
34        self.variant(PulseMode::PulseMeMode)
35    }
36}
37#[doc = "Pulse Polarity\n\nValue on reset: 0"]
38#[cfg_attr(feature = "defmt", derive(defmt::Format))]
39#[derive(Clone, Copy, Debug, PartialEq, Eq)]
40pub enum PulsePol {
41    #[doc = "0: High period"]
42    HighPeriod = 0,
43    #[doc = "1: Low period"]
44    LowPeriod = 1,
45}
46impl From<PulsePol> for bool {
47    #[inline(always)]
48    fn from(variant: PulsePol) -> Self {
49        variant as u8 != 0
50    }
51}
52#[doc = "Field `PULSE_POL` writer - Pulse Polarity"]
53pub type PulsePolW<'a, REG> = crate::BitWriter<'a, REG, PulsePol>;
54impl<'a, REG> PulsePolW<'a, REG>
55where
56    REG: crate::Writable + crate::RegisterSpec,
57{
58    #[doc = "High period"]
59    #[inline(always)]
60    pub fn high_period(self) -> &'a mut crate::W<REG> {
61        self.variant(PulsePol::HighPeriod)
62    }
63    #[doc = "Low period"]
64    #[inline(always)]
65    pub fn low_period(self) -> &'a mut crate::W<REG> {
66        self.variant(PulsePol::LowPeriod)
67    }
68}
69#[doc = "Less Than Minimum Interrupt Enable\n\nValue on reset: 0"]
70#[cfg_attr(feature = "defmt", derive(defmt::Format))]
71#[derive(Clone, Copy, Debug, PartialEq, Eq)]
72pub enum LtMinIntEn {
73    #[doc = "0: Disable"]
74    Disable = 0,
75    #[doc = "1: Enable"]
76    Enable = 1,
77}
78impl From<LtMinIntEn> for bool {
79    #[inline(always)]
80    fn from(variant: LtMinIntEn) -> Self {
81        variant as u8 != 0
82    }
83}
84#[doc = "Field `LT_MIN_INT_EN` writer - Less Than Minimum Interrupt Enable"]
85pub type LtMinIntEnW<'a, REG> = crate::BitWriter<'a, REG, LtMinIntEn>;
86impl<'a, REG> LtMinIntEnW<'a, REG>
87where
88    REG: crate::Writable + crate::RegisterSpec,
89{
90    #[doc = "Disable"]
91    #[inline(always)]
92    pub fn disable(self) -> &'a mut crate::W<REG> {
93        self.variant(LtMinIntEn::Disable)
94    }
95    #[doc = "Enable"]
96    #[inline(always)]
97    pub fn enable(self) -> &'a mut crate::W<REG> {
98        self.variant(LtMinIntEn::Enable)
99    }
100}
101#[doc = "Greater Than Maximum Interrupt Enable\n\nValue on reset: 0"]
102#[cfg_attr(feature = "defmt", derive(defmt::Format))]
103#[derive(Clone, Copy, Debug, PartialEq, Eq)]
104pub enum GtMaxIntEn {
105    #[doc = "0: Disable"]
106    Disable = 0,
107    #[doc = "1: Enable"]
108    Enable = 1,
109}
110impl From<GtMaxIntEn> for bool {
111    #[inline(always)]
112    fn from(variant: GtMaxIntEn) -> Self {
113        variant as u8 != 0
114    }
115}
116#[doc = "Field `GT_MAX_INT_EN` writer - Greater Than Maximum Interrupt Enable"]
117pub type GtMaxIntEnW<'a, REG> = crate::BitWriter<'a, REG, GtMaxIntEn>;
118impl<'a, REG> GtMaxIntEnW<'a, REG>
119where
120    REG: crate::Writable + crate::RegisterSpec,
121{
122    #[doc = "Disable"]
123    #[inline(always)]
124    pub fn disable(self) -> &'a mut crate::W<REG> {
125        self.variant(GtMaxIntEn::Disable)
126    }
127    #[doc = "Enable"]
128    #[inline(always)]
129    pub fn enable(self) -> &'a mut crate::W<REG> {
130        self.variant(GtMaxIntEn::Enable)
131    }
132}
133#[doc = "Result Ready Interrupt Enable\n\nValue on reset: 0"]
134#[cfg_attr(feature = "defmt", derive(defmt::Format))]
135#[derive(Clone, Copy, Debug, PartialEq, Eq)]
136pub enum ResultReadyIntEn {
137    #[doc = "0: Disable"]
138    Disable = 0,
139    #[doc = "1: Enable"]
140    Enable = 1,
141}
142impl From<ResultReadyIntEn> for bool {
143    #[inline(always)]
144    fn from(variant: ResultReadyIntEn) -> Self {
145        variant as u8 != 0
146    }
147}
148#[doc = "Field `RESULT_READY_INT_EN` writer - Result Ready Interrupt Enable"]
149pub type ResultReadyIntEnW<'a, REG> = crate::BitWriter<'a, REG, ResultReadyIntEn>;
150impl<'a, REG> ResultReadyIntEnW<'a, REG>
151where
152    REG: crate::Writable + crate::RegisterSpec,
153{
154    #[doc = "Disable"]
155    #[inline(always)]
156    pub fn disable(self) -> &'a mut crate::W<REG> {
157        self.variant(ResultReadyIntEn::Disable)
158    }
159    #[doc = "Enable"]
160    #[inline(always)]
161    pub fn enable(self) -> &'a mut crate::W<REG> {
162        self.variant(ResultReadyIntEn::Enable)
163    }
164}
165#[doc = "Continuous Mode Enable\n\nValue on reset: 0"]
166#[cfg_attr(feature = "defmt", derive(defmt::Format))]
167#[derive(Clone, Copy, Debug, PartialEq, Eq)]
168pub enum ContinuousModeEn {
169    #[doc = "0: Disable"]
170    Disable = 0,
171    #[doc = "1: Enable"]
172    Enable = 1,
173}
174impl From<ContinuousModeEn> for bool {
175    #[inline(always)]
176    fn from(variant: ContinuousModeEn) -> Self {
177        variant as u8 != 0
178    }
179}
180#[doc = "Field `CONTINUOUS_MODE_EN` writer - Continuous Mode Enable"]
181pub type ContinuousModeEnW<'a, REG> = crate::BitWriter<'a, REG, ContinuousModeEn>;
182impl<'a, REG> ContinuousModeEnW<'a, REG>
183where
184    REG: crate::Writable + crate::RegisterSpec,
185{
186    #[doc = "Disable"]
187    #[inline(always)]
188    pub fn disable(self) -> &'a mut crate::W<REG> {
189        self.variant(ContinuousModeEn::Disable)
190    }
191    #[doc = "Enable"]
192    #[inline(always)]
193    pub fn enable(self) -> &'a mut crate::W<REG> {
194        self.variant(ContinuousModeEn::Enable)
195    }
196}
197#[doc = "Measurement In Progress\n\nValue on reset: 0"]
198#[cfg_attr(feature = "defmt", derive(defmt::Format))]
199#[derive(Clone, Copy, Debug, PartialEq, Eq)]
200pub enum MeasureInProgress {
201    #[doc = "0: Terminates measurement"]
202    ForceTerminate = 0,
203    #[doc = "1: Initiates measurement"]
204    InitiateAFreqmeCycle = 1,
205}
206impl From<MeasureInProgress> for bool {
207    #[inline(always)]
208    fn from(variant: MeasureInProgress) -> Self {
209        variant as u8 != 0
210    }
211}
212#[doc = "Field `MEASURE_IN_PROGRESS` writer - Measurement In Progress"]
213pub type MeasureInProgressW<'a, REG> = crate::BitWriter<'a, REG, MeasureInProgress>;
214impl<'a, REG> MeasureInProgressW<'a, REG>
215where
216    REG: crate::Writable + crate::RegisterSpec,
217{
218    #[doc = "Terminates measurement"]
219    #[inline(always)]
220    pub fn force_terminate(self) -> &'a mut crate::W<REG> {
221        self.variant(MeasureInProgress::ForceTerminate)
222    }
223    #[doc = "Initiates measurement"]
224    #[inline(always)]
225    pub fn initiate_a_freqme_cycle(self) -> &'a mut crate::W<REG> {
226        self.variant(MeasureInProgress::InitiateAFreqmeCycle)
227    }
228}
229#[cfg(feature = "debug")]
230impl core::fmt::Debug for crate::generic::Reg<CtrlWSpec> {
231    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
232        write!(f, "(not readable)")
233    }
234}
235impl W {
236    #[doc = "Bits 0:4 - Reference Clock Scaling Factor"]
237    #[inline(always)]
238    pub fn ref_scale(&mut self) -> RefScaleW<'_, CtrlWSpec> {
239        RefScaleW::new(self, 0)
240    }
241    #[doc = "Bit 8 - Pulse Width Measurement Mode Select"]
242    #[inline(always)]
243    pub fn pulse_mode(&mut self) -> PulseModeW<'_, CtrlWSpec> {
244        PulseModeW::new(self, 8)
245    }
246    #[doc = "Bit 9 - Pulse Polarity"]
247    #[inline(always)]
248    pub fn pulse_pol(&mut self) -> PulsePolW<'_, CtrlWSpec> {
249        PulsePolW::new(self, 9)
250    }
251    #[doc = "Bit 12 - Less Than Minimum Interrupt Enable"]
252    #[inline(always)]
253    pub fn lt_min_int_en(&mut self) -> LtMinIntEnW<'_, CtrlWSpec> {
254        LtMinIntEnW::new(self, 12)
255    }
256    #[doc = "Bit 13 - Greater Than Maximum Interrupt Enable"]
257    #[inline(always)]
258    pub fn gt_max_int_en(&mut self) -> GtMaxIntEnW<'_, CtrlWSpec> {
259        GtMaxIntEnW::new(self, 13)
260    }
261    #[doc = "Bit 14 - Result Ready Interrupt Enable"]
262    #[inline(always)]
263    pub fn result_ready_int_en(&mut self) -> ResultReadyIntEnW<'_, CtrlWSpec> {
264        ResultReadyIntEnW::new(self, 14)
265    }
266    #[doc = "Bit 30 - Continuous Mode Enable"]
267    #[inline(always)]
268    pub fn continuous_mode_en(&mut self) -> ContinuousModeEnW<'_, CtrlWSpec> {
269        ContinuousModeEnW::new(self, 30)
270    }
271    #[doc = "Bit 31 - Measurement In Progress"]
272    #[inline(always)]
273    pub fn measure_in_progress(&mut self) -> MeasureInProgressW<'_, CtrlWSpec> {
274        MeasureInProgressW::new(self, 31)
275    }
276}
277#[doc = "Control (in Write mode)\n\nYou can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrl_w::W`](W). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
278pub struct CtrlWSpec;
279impl crate::RegisterSpec for CtrlWSpec {
280    type Ux = u32;
281}
282#[doc = "`write(|w| ..)` method takes [`ctrl_w::W`](W) writer structure"]
283impl crate::Writable for CtrlWSpec {
284    type Safety = crate::Unsafe;
285}
286#[doc = "`reset()` method sets CTRL_W to value 0"]
287impl crate::Resettable for CtrlWSpec {}