lpc55_pac/syscon/
comp_int_ctrl.rs

1#[doc = "Register `COMP_INT_CTRL` reader"]
2pub struct R(crate::R<COMP_INT_CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<COMP_INT_CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<COMP_INT_CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<COMP_INT_CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `COMP_INT_CTRL` writer"]
17pub struct W(crate::W<COMP_INT_CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<COMP_INT_CTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<COMP_INT_CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<COMP_INT_CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Analog Comparator interrupt enable control:.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum INT_ENABLE_A {
40    #[doc = "0: interrupt disable."]
41    INT_DISABLE = 0,
42    #[doc = "1: interrupt enable."]
43    INT_ENABLE = 1,
44}
45impl From<INT_ENABLE_A> for bool {
46    #[inline(always)]
47    fn from(variant: INT_ENABLE_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `INT_ENABLE` reader - Analog Comparator interrupt enable control:."]
52pub struct INT_ENABLE_R(crate::FieldReader<bool, INT_ENABLE_A>);
53impl INT_ENABLE_R {
54    #[inline(always)]
55    pub(crate) fn new(bits: bool) -> Self {
56        INT_ENABLE_R(crate::FieldReader::new(bits))
57    }
58    #[doc = r"Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> INT_ENABLE_A {
61        match self.bits {
62            false => INT_ENABLE_A::INT_DISABLE,
63            true => INT_ENABLE_A::INT_ENABLE,
64        }
65    }
66    #[doc = "Checks if the value of the field is `INT_DISABLE`"]
67    #[inline(always)]
68    pub fn is_int_disable(&self) -> bool {
69        **self == INT_ENABLE_A::INT_DISABLE
70    }
71    #[doc = "Checks if the value of the field is `INT_ENABLE`"]
72    #[inline(always)]
73    pub fn is_int_enable(&self) -> bool {
74        **self == INT_ENABLE_A::INT_ENABLE
75    }
76}
77impl core::ops::Deref for INT_ENABLE_R {
78    type Target = crate::FieldReader<bool, INT_ENABLE_A>;
79    #[inline(always)]
80    fn deref(&self) -> &Self::Target {
81        &self.0
82    }
83}
84#[doc = "Field `INT_ENABLE` writer - Analog Comparator interrupt enable control:."]
85pub struct INT_ENABLE_W<'a> {
86    w: &'a mut W,
87}
88impl<'a> INT_ENABLE_W<'a> {
89    #[doc = r"Writes `variant` to the field"]
90    #[inline(always)]
91    pub fn variant(self, variant: INT_ENABLE_A) -> &'a mut W {
92        self.bit(variant.into())
93    }
94    #[doc = "interrupt disable."]
95    #[inline(always)]
96    pub fn int_disable(self) -> &'a mut W {
97        self.variant(INT_ENABLE_A::INT_DISABLE)
98    }
99    #[doc = "interrupt enable."]
100    #[inline(always)]
101    pub fn int_enable(self) -> &'a mut W {
102        self.variant(INT_ENABLE_A::INT_ENABLE)
103    }
104    #[doc = r"Sets the field bit"]
105    #[inline(always)]
106    pub fn set_bit(self) -> &'a mut W {
107        self.bit(true)
108    }
109    #[doc = r"Clears the field bit"]
110    #[inline(always)]
111    pub fn clear_bit(self) -> &'a mut W {
112        self.bit(false)
113    }
114    #[doc = r"Writes raw bits to the field"]
115    #[inline(always)]
116    pub fn bit(self, value: bool) -> &'a mut W {
117        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
118        self.w
119    }
120}
121#[doc = "Analog Comparator interrupt clear.\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq)]
123pub enum INT_CLEAR_A {
124    #[doc = "0: No effect."]
125    NONE = 0,
126    #[doc = "1: Clear the interrupt. Self-cleared bit."]
127    CLEAR = 1,
128}
129impl From<INT_CLEAR_A> for bool {
130    #[inline(always)]
131    fn from(variant: INT_CLEAR_A) -> Self {
132        variant as u8 != 0
133    }
134}
135#[doc = "Field `INT_CLEAR` reader - Analog Comparator interrupt clear."]
136pub struct INT_CLEAR_R(crate::FieldReader<bool, INT_CLEAR_A>);
137impl INT_CLEAR_R {
138    #[inline(always)]
139    pub(crate) fn new(bits: bool) -> Self {
140        INT_CLEAR_R(crate::FieldReader::new(bits))
141    }
142    #[doc = r"Get enumerated values variant"]
143    #[inline(always)]
144    pub fn variant(&self) -> INT_CLEAR_A {
145        match self.bits {
146            false => INT_CLEAR_A::NONE,
147            true => INT_CLEAR_A::CLEAR,
148        }
149    }
150    #[doc = "Checks if the value of the field is `NONE`"]
151    #[inline(always)]
152    pub fn is_none(&self) -> bool {
153        **self == INT_CLEAR_A::NONE
154    }
155    #[doc = "Checks if the value of the field is `CLEAR`"]
156    #[inline(always)]
157    pub fn is_clear(&self) -> bool {
158        **self == INT_CLEAR_A::CLEAR
159    }
160}
161impl core::ops::Deref for INT_CLEAR_R {
162    type Target = crate::FieldReader<bool, INT_CLEAR_A>;
163    #[inline(always)]
164    fn deref(&self) -> &Self::Target {
165        &self.0
166    }
167}
168#[doc = "Field `INT_CLEAR` writer - Analog Comparator interrupt clear."]
169pub struct INT_CLEAR_W<'a> {
170    w: &'a mut W,
171}
172impl<'a> INT_CLEAR_W<'a> {
173    #[doc = r"Writes `variant` to the field"]
174    #[inline(always)]
175    pub fn variant(self, variant: INT_CLEAR_A) -> &'a mut W {
176        self.bit(variant.into())
177    }
178    #[doc = "No effect."]
179    #[inline(always)]
180    pub fn none(self) -> &'a mut W {
181        self.variant(INT_CLEAR_A::NONE)
182    }
183    #[doc = "Clear the interrupt. Self-cleared bit."]
184    #[inline(always)]
185    pub fn clear(self) -> &'a mut W {
186        self.variant(INT_CLEAR_A::CLEAR)
187    }
188    #[doc = r"Sets the field bit"]
189    #[inline(always)]
190    pub fn set_bit(self) -> &'a mut W {
191        self.bit(true)
192    }
193    #[doc = r"Clears the field bit"]
194    #[inline(always)]
195    pub fn clear_bit(self) -> &'a mut W {
196        self.bit(false)
197    }
198    #[doc = r"Writes raw bits to the field"]
199    #[inline(always)]
200    pub fn bit(self, value: bool) -> &'a mut W {
201        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
202        self.w
203    }
204}
205#[doc = "Comparator interrupt type selector:.\n\nValue on reset: 0"]
206#[derive(Clone, Copy, Debug, PartialEq)]
207#[repr(u8)]
208pub enum INT_CTRL_A {
209    #[doc = "0: The analog comparator interrupt edge sensitive is disabled."]
210    EDGE_DISABLE = 0,
211    #[doc = "1: The analog comparator interrupt level sensitive is disabled."]
212    LVL_DISABLE = 1,
213    #[doc = "2: analog comparator interrupt is rising edge sensitive."]
214    EDGE_RISING = 2,
215    #[doc = "3: Analog Comparator interrupt is high level sensitive."]
216    LVL_HIGH = 3,
217    #[doc = "4: analog comparator interrupt is falling edge sensitive."]
218    EDGE_FALLING = 4,
219    #[doc = "5: Analog Comparator interrupt is low level sensitive."]
220    LVL_LOW = 5,
221    #[doc = "6: analog comparator interrupt is rising and falling edge sensitive."]
222    EDGE_BOTH = 6,
223    #[doc = "7: The analog comparator interrupt level sensitive is disabled."]
224    LVL_DIS2 = 7,
225}
226impl From<INT_CTRL_A> for u8 {
227    #[inline(always)]
228    fn from(variant: INT_CTRL_A) -> Self {
229        variant as _
230    }
231}
232#[doc = "Field `INT_CTRL` reader - Comparator interrupt type selector:."]
233pub struct INT_CTRL_R(crate::FieldReader<u8, INT_CTRL_A>);
234impl INT_CTRL_R {
235    #[inline(always)]
236    pub(crate) fn new(bits: u8) -> Self {
237        INT_CTRL_R(crate::FieldReader::new(bits))
238    }
239    #[doc = r"Get enumerated values variant"]
240    #[inline(always)]
241    pub fn variant(&self) -> INT_CTRL_A {
242        match self.bits {
243            0 => INT_CTRL_A::EDGE_DISABLE,
244            1 => INT_CTRL_A::LVL_DISABLE,
245            2 => INT_CTRL_A::EDGE_RISING,
246            3 => INT_CTRL_A::LVL_HIGH,
247            4 => INT_CTRL_A::EDGE_FALLING,
248            5 => INT_CTRL_A::LVL_LOW,
249            6 => INT_CTRL_A::EDGE_BOTH,
250            7 => INT_CTRL_A::LVL_DIS2,
251            _ => unreachable!(),
252        }
253    }
254    #[doc = "Checks if the value of the field is `EDGE_DISABLE`"]
255    #[inline(always)]
256    pub fn is_edge_disable(&self) -> bool {
257        **self == INT_CTRL_A::EDGE_DISABLE
258    }
259    #[doc = "Checks if the value of the field is `LVL_DISABLE`"]
260    #[inline(always)]
261    pub fn is_lvl_disable(&self) -> bool {
262        **self == INT_CTRL_A::LVL_DISABLE
263    }
264    #[doc = "Checks if the value of the field is `EDGE_RISING`"]
265    #[inline(always)]
266    pub fn is_edge_rising(&self) -> bool {
267        **self == INT_CTRL_A::EDGE_RISING
268    }
269    #[doc = "Checks if the value of the field is `LVL_HIGH`"]
270    #[inline(always)]
271    pub fn is_lvl_high(&self) -> bool {
272        **self == INT_CTRL_A::LVL_HIGH
273    }
274    #[doc = "Checks if the value of the field is `EDGE_FALLING`"]
275    #[inline(always)]
276    pub fn is_edge_falling(&self) -> bool {
277        **self == INT_CTRL_A::EDGE_FALLING
278    }
279    #[doc = "Checks if the value of the field is `LVL_LOW`"]
280    #[inline(always)]
281    pub fn is_lvl_low(&self) -> bool {
282        **self == INT_CTRL_A::LVL_LOW
283    }
284    #[doc = "Checks if the value of the field is `EDGE_BOTH`"]
285    #[inline(always)]
286    pub fn is_edge_both(&self) -> bool {
287        **self == INT_CTRL_A::EDGE_BOTH
288    }
289    #[doc = "Checks if the value of the field is `LVL_DIS2`"]
290    #[inline(always)]
291    pub fn is_lvl_dis2(&self) -> bool {
292        **self == INT_CTRL_A::LVL_DIS2
293    }
294}
295impl core::ops::Deref for INT_CTRL_R {
296    type Target = crate::FieldReader<u8, INT_CTRL_A>;
297    #[inline(always)]
298    fn deref(&self) -> &Self::Target {
299        &self.0
300    }
301}
302#[doc = "Field `INT_CTRL` writer - Comparator interrupt type selector:."]
303pub struct INT_CTRL_W<'a> {
304    w: &'a mut W,
305}
306impl<'a> INT_CTRL_W<'a> {
307    #[doc = r"Writes `variant` to the field"]
308    #[inline(always)]
309    pub fn variant(self, variant: INT_CTRL_A) -> &'a mut W {
310        self.bits(variant.into())
311    }
312    #[doc = "The analog comparator interrupt edge sensitive is disabled."]
313    #[inline(always)]
314    pub fn edge_disable(self) -> &'a mut W {
315        self.variant(INT_CTRL_A::EDGE_DISABLE)
316    }
317    #[doc = "The analog comparator interrupt level sensitive is disabled."]
318    #[inline(always)]
319    pub fn lvl_disable(self) -> &'a mut W {
320        self.variant(INT_CTRL_A::LVL_DISABLE)
321    }
322    #[doc = "analog comparator interrupt is rising edge sensitive."]
323    #[inline(always)]
324    pub fn edge_rising(self) -> &'a mut W {
325        self.variant(INT_CTRL_A::EDGE_RISING)
326    }
327    #[doc = "Analog Comparator interrupt is high level sensitive."]
328    #[inline(always)]
329    pub fn lvl_high(self) -> &'a mut W {
330        self.variant(INT_CTRL_A::LVL_HIGH)
331    }
332    #[doc = "analog comparator interrupt is falling edge sensitive."]
333    #[inline(always)]
334    pub fn edge_falling(self) -> &'a mut W {
335        self.variant(INT_CTRL_A::EDGE_FALLING)
336    }
337    #[doc = "Analog Comparator interrupt is low level sensitive."]
338    #[inline(always)]
339    pub fn lvl_low(self) -> &'a mut W {
340        self.variant(INT_CTRL_A::LVL_LOW)
341    }
342    #[doc = "analog comparator interrupt is rising and falling edge sensitive."]
343    #[inline(always)]
344    pub fn edge_both(self) -> &'a mut W {
345        self.variant(INT_CTRL_A::EDGE_BOTH)
346    }
347    #[doc = "The analog comparator interrupt level sensitive is disabled."]
348    #[inline(always)]
349    pub fn lvl_dis2(self) -> &'a mut W {
350        self.variant(INT_CTRL_A::LVL_DIS2)
351    }
352    #[doc = r"Writes raw bits to the field"]
353    #[inline(always)]
354    pub fn bits(self, value: u8) -> &'a mut W {
355        self.w.bits = (self.w.bits & !(0x07 << 2)) | ((value as u32 & 0x07) << 2);
356        self.w
357    }
358}
359#[doc = "Select which Analog comparator output (filtered our un-filtered) is used for interrupt detection.\n\nValue on reset: 0"]
360#[derive(Clone, Copy, Debug, PartialEq)]
361pub enum INT_SOURCE_A {
362    #[doc = "0: Select Analog Comparator filtered output as input for interrupt detection."]
363    FILTER_INT = 0,
364    #[doc = "1: Select Analog Comparator raw output (unfiltered) as input for interrupt detection. Must be used when Analog comparator is used as wake up source in Power down mode."]
365    RAW_INT = 1,
366}
367impl From<INT_SOURCE_A> for bool {
368    #[inline(always)]
369    fn from(variant: INT_SOURCE_A) -> Self {
370        variant as u8 != 0
371    }
372}
373#[doc = "Field `INT_SOURCE` reader - Select which Analog comparator output (filtered our un-filtered) is used for interrupt detection."]
374pub struct INT_SOURCE_R(crate::FieldReader<bool, INT_SOURCE_A>);
375impl INT_SOURCE_R {
376    #[inline(always)]
377    pub(crate) fn new(bits: bool) -> Self {
378        INT_SOURCE_R(crate::FieldReader::new(bits))
379    }
380    #[doc = r"Get enumerated values variant"]
381    #[inline(always)]
382    pub fn variant(&self) -> INT_SOURCE_A {
383        match self.bits {
384            false => INT_SOURCE_A::FILTER_INT,
385            true => INT_SOURCE_A::RAW_INT,
386        }
387    }
388    #[doc = "Checks if the value of the field is `FILTER_INT`"]
389    #[inline(always)]
390    pub fn is_filter_int(&self) -> bool {
391        **self == INT_SOURCE_A::FILTER_INT
392    }
393    #[doc = "Checks if the value of the field is `RAW_INT`"]
394    #[inline(always)]
395    pub fn is_raw_int(&self) -> bool {
396        **self == INT_SOURCE_A::RAW_INT
397    }
398}
399impl core::ops::Deref for INT_SOURCE_R {
400    type Target = crate::FieldReader<bool, INT_SOURCE_A>;
401    #[inline(always)]
402    fn deref(&self) -> &Self::Target {
403        &self.0
404    }
405}
406#[doc = "Field `INT_SOURCE` writer - Select which Analog comparator output (filtered our un-filtered) is used for interrupt detection."]
407pub struct INT_SOURCE_W<'a> {
408    w: &'a mut W,
409}
410impl<'a> INT_SOURCE_W<'a> {
411    #[doc = r"Writes `variant` to the field"]
412    #[inline(always)]
413    pub fn variant(self, variant: INT_SOURCE_A) -> &'a mut W {
414        self.bit(variant.into())
415    }
416    #[doc = "Select Analog Comparator filtered output as input for interrupt detection."]
417    #[inline(always)]
418    pub fn filter_int(self) -> &'a mut W {
419        self.variant(INT_SOURCE_A::FILTER_INT)
420    }
421    #[doc = "Select Analog Comparator raw output (unfiltered) as input for interrupt detection. Must be used when Analog comparator is used as wake up source in Power down mode."]
422    #[inline(always)]
423    pub fn raw_int(self) -> &'a mut W {
424        self.variant(INT_SOURCE_A::RAW_INT)
425    }
426    #[doc = r"Sets the field bit"]
427    #[inline(always)]
428    pub fn set_bit(self) -> &'a mut W {
429        self.bit(true)
430    }
431    #[doc = r"Clears the field bit"]
432    #[inline(always)]
433    pub fn clear_bit(self) -> &'a mut W {
434        self.bit(false)
435    }
436    #[doc = r"Writes raw bits to the field"]
437    #[inline(always)]
438    pub fn bit(self, value: bool) -> &'a mut W {
439        self.w.bits = (self.w.bits & !(0x01 << 5)) | ((value as u32 & 0x01) << 5);
440        self.w
441    }
442}
443impl R {
444    #[doc = "Bit 0 - Analog Comparator interrupt enable control:."]
445    #[inline(always)]
446    pub fn int_enable(&self) -> INT_ENABLE_R {
447        INT_ENABLE_R::new((self.bits & 0x01) != 0)
448    }
449    #[doc = "Bit 1 - Analog Comparator interrupt clear."]
450    #[inline(always)]
451    pub fn int_clear(&self) -> INT_CLEAR_R {
452        INT_CLEAR_R::new(((self.bits >> 1) & 0x01) != 0)
453    }
454    #[doc = "Bits 2:4 - Comparator interrupt type selector:."]
455    #[inline(always)]
456    pub fn int_ctrl(&self) -> INT_CTRL_R {
457        INT_CTRL_R::new(((self.bits >> 2) & 0x07) as u8)
458    }
459    #[doc = "Bit 5 - Select which Analog comparator output (filtered our un-filtered) is used for interrupt detection."]
460    #[inline(always)]
461    pub fn int_source(&self) -> INT_SOURCE_R {
462        INT_SOURCE_R::new(((self.bits >> 5) & 0x01) != 0)
463    }
464}
465impl W {
466    #[doc = "Bit 0 - Analog Comparator interrupt enable control:."]
467    #[inline(always)]
468    pub fn int_enable(&mut self) -> INT_ENABLE_W {
469        INT_ENABLE_W { w: self }
470    }
471    #[doc = "Bit 1 - Analog Comparator interrupt clear."]
472    #[inline(always)]
473    pub fn int_clear(&mut self) -> INT_CLEAR_W {
474        INT_CLEAR_W { w: self }
475    }
476    #[doc = "Bits 2:4 - Comparator interrupt type selector:."]
477    #[inline(always)]
478    pub fn int_ctrl(&mut self) -> INT_CTRL_W {
479        INT_CTRL_W { w: self }
480    }
481    #[doc = "Bit 5 - Select which Analog comparator output (filtered our un-filtered) is used for interrupt detection."]
482    #[inline(always)]
483    pub fn int_source(&mut self) -> INT_SOURCE_W {
484        INT_SOURCE_W { w: self }
485    }
486    #[doc = "Writes raw bits to the register."]
487    #[inline(always)]
488    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
489        self.0.bits(bits);
490        self
491    }
492}
493#[doc = "Comparator Interrupt control\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [comp_int_ctrl](index.html) module"]
494pub struct COMP_INT_CTRL_SPEC;
495impl crate::RegisterSpec for COMP_INT_CTRL_SPEC {
496    type Ux = u32;
497}
498#[doc = "`read()` method returns [comp_int_ctrl::R](R) reader structure"]
499impl crate::Readable for COMP_INT_CTRL_SPEC {
500    type Reader = R;
501}
502#[doc = "`write(|w| ..)` method takes [comp_int_ctrl::W](W) writer structure"]
503impl crate::Writable for COMP_INT_CTRL_SPEC {
504    type Writer = W;
505}
506#[doc = "`reset()` method sets COMP_INT_CTRL to value 0"]
507impl crate::Resettable for COMP_INT_CTRL_SPEC {
508    #[inline(always)]
509    fn reset_value() -> Self::Ux {
510        0
511    }
512}