Skip to main content

lpc54606_pac/mrt0/channel/
stat.rs

1#[doc = "Reader of register STAT"]
2pub type R = crate::R<u32, super::STAT>;
3#[doc = "Writer for register STAT"]
4pub type W = crate::W<u32, super::STAT>;
5#[doc = "Register STAT `reset()`'s with value 0"]
6impl crate::ResetValue for super::STAT {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Monitors the interrupt flag.\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum INTFLAG_A {
16    #[doc = "0: No pending interrupt. Writing a zero is equivalent to no operation."]
17    NO_PENDING_INTERRUPT = 0,
18    #[doc = "1: Pending interrupt. The interrupt is pending because TIMERn has reached the end of the time interval. If the INTEN bit in the CONTROLn is also set to 1, the interrupt for timer channel n and the global interrupt are raised. Writing a 1 to this bit clears the interrupt request."]
19    PENDING_INTERRUPT = 1,
20}
21impl From<INTFLAG_A> for bool {
22    #[inline(always)]
23    fn from(variant: INTFLAG_A) -> Self {
24        variant as u8 != 0
25    }
26}
27#[doc = "Reader of field `INTFLAG`"]
28pub type INTFLAG_R = crate::R<bool, INTFLAG_A>;
29impl INTFLAG_R {
30    #[doc = r"Get enumerated values variant"]
31    #[inline(always)]
32    pub fn variant(&self) -> INTFLAG_A {
33        match self.bits {
34            false => INTFLAG_A::NO_PENDING_INTERRUPT,
35            true => INTFLAG_A::PENDING_INTERRUPT,
36        }
37    }
38    #[doc = "Checks if the value of the field is `NO_PENDING_INTERRUPT`"]
39    #[inline(always)]
40    pub fn is_no_pending_interrupt(&self) -> bool {
41        *self == INTFLAG_A::NO_PENDING_INTERRUPT
42    }
43    #[doc = "Checks if the value of the field is `PENDING_INTERRUPT`"]
44    #[inline(always)]
45    pub fn is_pending_interrupt(&self) -> bool {
46        *self == INTFLAG_A::PENDING_INTERRUPT
47    }
48}
49#[doc = "Write proxy for field `INTFLAG`"]
50pub struct INTFLAG_W<'a> {
51    w: &'a mut W,
52}
53impl<'a> INTFLAG_W<'a> {
54    #[doc = r"Writes `variant` to the field"]
55    #[inline(always)]
56    pub fn variant(self, variant: INTFLAG_A) -> &'a mut W {
57        {
58            self.bit(variant.into())
59        }
60    }
61    #[doc = "No pending interrupt. Writing a zero is equivalent to no operation."]
62    #[inline(always)]
63    pub fn no_pending_interrupt(self) -> &'a mut W {
64        self.variant(INTFLAG_A::NO_PENDING_INTERRUPT)
65    }
66    #[doc = "Pending interrupt. The interrupt is pending because TIMERn has reached the end of the time interval. If the INTEN bit in the CONTROLn is also set to 1, the interrupt for timer channel n and the global interrupt are raised. Writing a 1 to this bit clears the interrupt request."]
67    #[inline(always)]
68    pub fn pending_interrupt(self) -> &'a mut W {
69        self.variant(INTFLAG_A::PENDING_INTERRUPT)
70    }
71    #[doc = r"Sets the field bit"]
72    #[inline(always)]
73    pub fn set_bit(self) -> &'a mut W {
74        self.bit(true)
75    }
76    #[doc = r"Clears the field bit"]
77    #[inline(always)]
78    pub fn clear_bit(self) -> &'a mut W {
79        self.bit(false)
80    }
81    #[doc = r"Writes raw bits to the field"]
82    #[inline(always)]
83    pub fn bit(self, value: bool) -> &'a mut W {
84        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
85        self.w
86    }
87}
88#[doc = "Indicates the state of TIMERn. This bit is read-only.\n\nValue on reset: 0"]
89#[derive(Clone, Copy, Debug, PartialEq)]
90pub enum RUN_A {
91    #[doc = "0: Idle state. TIMERn is stopped."]
92    IDLE_STATE = 0,
93    #[doc = "1: Running. TIMERn is running."]
94    RUNNING = 1,
95}
96impl From<RUN_A> for bool {
97    #[inline(always)]
98    fn from(variant: RUN_A) -> Self {
99        variant as u8 != 0
100    }
101}
102#[doc = "Reader of field `RUN`"]
103pub type RUN_R = crate::R<bool, RUN_A>;
104impl RUN_R {
105    #[doc = r"Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> RUN_A {
108        match self.bits {
109            false => RUN_A::IDLE_STATE,
110            true => RUN_A::RUNNING,
111        }
112    }
113    #[doc = "Checks if the value of the field is `IDLE_STATE`"]
114    #[inline(always)]
115    pub fn is_idle_state(&self) -> bool {
116        *self == RUN_A::IDLE_STATE
117    }
118    #[doc = "Checks if the value of the field is `RUNNING`"]
119    #[inline(always)]
120    pub fn is_running(&self) -> bool {
121        *self == RUN_A::RUNNING
122    }
123}
124#[doc = "Write proxy for field `RUN`"]
125pub struct RUN_W<'a> {
126    w: &'a mut W,
127}
128impl<'a> RUN_W<'a> {
129    #[doc = r"Writes `variant` to the field"]
130    #[inline(always)]
131    pub fn variant(self, variant: RUN_A) -> &'a mut W {
132        {
133            self.bit(variant.into())
134        }
135    }
136    #[doc = "Idle state. TIMERn is stopped."]
137    #[inline(always)]
138    pub fn idle_state(self) -> &'a mut W {
139        self.variant(RUN_A::IDLE_STATE)
140    }
141    #[doc = "Running. TIMERn is running."]
142    #[inline(always)]
143    pub fn running(self) -> &'a mut W {
144        self.variant(RUN_A::RUNNING)
145    }
146    #[doc = r"Sets the field bit"]
147    #[inline(always)]
148    pub fn set_bit(self) -> &'a mut W {
149        self.bit(true)
150    }
151    #[doc = r"Clears the field bit"]
152    #[inline(always)]
153    pub fn clear_bit(self) -> &'a mut W {
154        self.bit(false)
155    }
156    #[doc = r"Writes raw bits to the field"]
157    #[inline(always)]
158    pub fn bit(self, value: bool) -> &'a mut W {
159        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
160        self.w
161    }
162}
163#[doc = "Channel In Use flag. Operating details depend on the MULTITASK bit in the MODCFG register, and affects the use of IDLE_CH. See Idle channel register for details of the two operating modes.\n\nValue on reset: 0"]
164#[derive(Clone, Copy, Debug, PartialEq)]
165pub enum INUSE_A {
166    #[doc = "0: This channel is not in use."]
167    NO = 0,
168    #[doc = "1: This channel is in use."]
169    YES = 1,
170}
171impl From<INUSE_A> for bool {
172    #[inline(always)]
173    fn from(variant: INUSE_A) -> Self {
174        variant as u8 != 0
175    }
176}
177#[doc = "Reader of field `INUSE`"]
178pub type INUSE_R = crate::R<bool, INUSE_A>;
179impl INUSE_R {
180    #[doc = r"Get enumerated values variant"]
181    #[inline(always)]
182    pub fn variant(&self) -> INUSE_A {
183        match self.bits {
184            false => INUSE_A::NO,
185            true => INUSE_A::YES,
186        }
187    }
188    #[doc = "Checks if the value of the field is `NO`"]
189    #[inline(always)]
190    pub fn is_no(&self) -> bool {
191        *self == INUSE_A::NO
192    }
193    #[doc = "Checks if the value of the field is `YES`"]
194    #[inline(always)]
195    pub fn is_yes(&self) -> bool {
196        *self == INUSE_A::YES
197    }
198}
199#[doc = "Write proxy for field `INUSE`"]
200pub struct INUSE_W<'a> {
201    w: &'a mut W,
202}
203impl<'a> INUSE_W<'a> {
204    #[doc = r"Writes `variant` to the field"]
205    #[inline(always)]
206    pub fn variant(self, variant: INUSE_A) -> &'a mut W {
207        {
208            self.bit(variant.into())
209        }
210    }
211    #[doc = "This channel is not in use."]
212    #[inline(always)]
213    pub fn no(self) -> &'a mut W {
214        self.variant(INUSE_A::NO)
215    }
216    #[doc = "This channel is in use."]
217    #[inline(always)]
218    pub fn yes(self) -> &'a mut W {
219        self.variant(INUSE_A::YES)
220    }
221    #[doc = r"Sets the field bit"]
222    #[inline(always)]
223    pub fn set_bit(self) -> &'a mut W {
224        self.bit(true)
225    }
226    #[doc = r"Clears the field bit"]
227    #[inline(always)]
228    pub fn clear_bit(self) -> &'a mut W {
229        self.bit(false)
230    }
231    #[doc = r"Writes raw bits to the field"]
232    #[inline(always)]
233    pub fn bit(self, value: bool) -> &'a mut W {
234        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
235        self.w
236    }
237}
238impl R {
239    #[doc = "Bit 0 - Monitors the interrupt flag."]
240    #[inline(always)]
241    pub fn intflag(&self) -> INTFLAG_R {
242        INTFLAG_R::new((self.bits & 0x01) != 0)
243    }
244    #[doc = "Bit 1 - Indicates the state of TIMERn. This bit is read-only."]
245    #[inline(always)]
246    pub fn run(&self) -> RUN_R {
247        RUN_R::new(((self.bits >> 1) & 0x01) != 0)
248    }
249    #[doc = "Bit 2 - Channel In Use flag. Operating details depend on the MULTITASK bit in the MODCFG register, and affects the use of IDLE_CH. See Idle channel register for details of the two operating modes."]
250    #[inline(always)]
251    pub fn inuse(&self) -> INUSE_R {
252        INUSE_R::new(((self.bits >> 2) & 0x01) != 0)
253    }
254}
255impl W {
256    #[doc = "Bit 0 - Monitors the interrupt flag."]
257    #[inline(always)]
258    pub fn intflag(&mut self) -> INTFLAG_W {
259        INTFLAG_W { w: self }
260    }
261    #[doc = "Bit 1 - Indicates the state of TIMERn. This bit is read-only."]
262    #[inline(always)]
263    pub fn run(&mut self) -> RUN_W {
264        RUN_W { w: self }
265    }
266    #[doc = "Bit 2 - Channel In Use flag. Operating details depend on the MULTITASK bit in the MODCFG register, and affects the use of IDLE_CH. See Idle channel register for details of the two operating modes."]
267    #[inline(always)]
268    pub fn inuse(&mut self) -> INUSE_W {
269        INUSE_W { w: self }
270    }
271}