lpc82x_pac/mrt0/channel/
stat.rs

1#[doc = "Register `STAT` reader"]
2pub struct R(crate::R<STAT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<STAT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<STAT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<STAT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `STAT` writer"]
17pub struct W(crate::W<STAT_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<STAT_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<STAT_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<STAT_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Monitors the interrupt flag.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum INTFLAG_A {
40    #[doc = "0: No pending interrupt. Writing a zero is equivalent to no operation."]
41    NO_PENDING_INTERRUPT = 0,
42    #[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."]
43    PENDING_INTERRUPT = 1,
44}
45impl From<INTFLAG_A> for bool {
46    #[inline(always)]
47    fn from(variant: INTFLAG_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `INTFLAG` reader - Monitors the interrupt flag."]
52pub struct INTFLAG_R(crate::FieldReader<bool, INTFLAG_A>);
53impl INTFLAG_R {
54    pub(crate) fn new(bits: bool) -> Self {
55        INTFLAG_R(crate::FieldReader::new(bits))
56    }
57    #[doc = r"Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> INTFLAG_A {
60        match self.bits {
61            false => INTFLAG_A::NO_PENDING_INTERRUPT,
62            true => INTFLAG_A::PENDING_INTERRUPT,
63        }
64    }
65    #[doc = "Checks if the value of the field is `NO_PENDING_INTERRUPT`"]
66    #[inline(always)]
67    pub fn is_no_pending_interrupt(&self) -> bool {
68        **self == INTFLAG_A::NO_PENDING_INTERRUPT
69    }
70    #[doc = "Checks if the value of the field is `PENDING_INTERRUPT`"]
71    #[inline(always)]
72    pub fn is_pending_interrupt(&self) -> bool {
73        **self == INTFLAG_A::PENDING_INTERRUPT
74    }
75}
76impl core::ops::Deref for INTFLAG_R {
77    type Target = crate::FieldReader<bool, INTFLAG_A>;
78    #[inline(always)]
79    fn deref(&self) -> &Self::Target {
80        &self.0
81    }
82}
83#[doc = "Field `INTFLAG` writer - Monitors the interrupt flag."]
84pub struct INTFLAG_W<'a> {
85    w: &'a mut W,
86}
87impl<'a> INTFLAG_W<'a> {
88    #[doc = r"Writes `variant` to the field"]
89    #[inline(always)]
90    pub fn variant(self, variant: INTFLAG_A) -> &'a mut W {
91        self.bit(variant.into())
92    }
93    #[doc = "No pending interrupt. Writing a zero is equivalent to no operation."]
94    #[inline(always)]
95    pub fn no_pending_interrupt(self) -> &'a mut W {
96        self.variant(INTFLAG_A::NO_PENDING_INTERRUPT)
97    }
98    #[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."]
99    #[inline(always)]
100    pub fn pending_interrupt(self) -> &'a mut W {
101        self.variant(INTFLAG_A::PENDING_INTERRUPT)
102    }
103    #[doc = r"Sets the field bit"]
104    #[inline(always)]
105    pub fn set_bit(self) -> &'a mut W {
106        self.bit(true)
107    }
108    #[doc = r"Clears the field bit"]
109    #[inline(always)]
110    pub fn clear_bit(self) -> &'a mut W {
111        self.bit(false)
112    }
113    #[doc = r"Writes raw bits to the field"]
114    #[inline(always)]
115    pub fn bit(self, value: bool) -> &'a mut W {
116        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
117        self.w
118    }
119}
120#[doc = "Indicates the state of TIMERn. This bit is read-only.\n\nValue on reset: 0"]
121#[derive(Clone, Copy, Debug, PartialEq)]
122pub enum RUN_A {
123    #[doc = "0: Idle state. TIMERn is stopped."]
124    IDLE_STATE = 0,
125    #[doc = "1: Running. TIMERn is running."]
126    RUNNING = 1,
127}
128impl From<RUN_A> for bool {
129    #[inline(always)]
130    fn from(variant: RUN_A) -> Self {
131        variant as u8 != 0
132    }
133}
134#[doc = "Field `RUN` reader - Indicates the state of TIMERn. This bit is read-only."]
135pub struct RUN_R(crate::FieldReader<bool, RUN_A>);
136impl RUN_R {
137    pub(crate) fn new(bits: bool) -> Self {
138        RUN_R(crate::FieldReader::new(bits))
139    }
140    #[doc = r"Get enumerated values variant"]
141    #[inline(always)]
142    pub fn variant(&self) -> RUN_A {
143        match self.bits {
144            false => RUN_A::IDLE_STATE,
145            true => RUN_A::RUNNING,
146        }
147    }
148    #[doc = "Checks if the value of the field is `IDLE_STATE`"]
149    #[inline(always)]
150    pub fn is_idle_state(&self) -> bool {
151        **self == RUN_A::IDLE_STATE
152    }
153    #[doc = "Checks if the value of the field is `RUNNING`"]
154    #[inline(always)]
155    pub fn is_running(&self) -> bool {
156        **self == RUN_A::RUNNING
157    }
158}
159impl core::ops::Deref for RUN_R {
160    type Target = crate::FieldReader<bool, RUN_A>;
161    #[inline(always)]
162    fn deref(&self) -> &Self::Target {
163        &self.0
164    }
165}
166#[doc = "Field `RUN` writer - Indicates the state of TIMERn. This bit is read-only."]
167pub struct RUN_W<'a> {
168    w: &'a mut W,
169}
170impl<'a> RUN_W<'a> {
171    #[doc = r"Writes `variant` to the field"]
172    #[inline(always)]
173    pub fn variant(self, variant: RUN_A) -> &'a mut W {
174        self.bit(variant.into())
175    }
176    #[doc = "Idle state. TIMERn is stopped."]
177    #[inline(always)]
178    pub fn idle_state(self) -> &'a mut W {
179        self.variant(RUN_A::IDLE_STATE)
180    }
181    #[doc = "Running. TIMERn is running."]
182    #[inline(always)]
183    pub fn running(self) -> &'a mut W {
184        self.variant(RUN_A::RUNNING)
185    }
186    #[doc = r"Sets the field bit"]
187    #[inline(always)]
188    pub fn set_bit(self) -> &'a mut W {
189        self.bit(true)
190    }
191    #[doc = r"Clears the field bit"]
192    #[inline(always)]
193    pub fn clear_bit(self) -> &'a mut W {
194        self.bit(false)
195    }
196    #[doc = r"Writes raw bits to the field"]
197    #[inline(always)]
198    pub fn bit(self, value: bool) -> &'a mut W {
199        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
200        self.w
201    }
202}
203impl R {
204    #[doc = "Bit 0 - Monitors the interrupt flag."]
205    #[inline(always)]
206    pub fn intflag(&self) -> INTFLAG_R {
207        INTFLAG_R::new((self.bits & 0x01) != 0)
208    }
209    #[doc = "Bit 1 - Indicates the state of TIMERn. This bit is read-only."]
210    #[inline(always)]
211    pub fn run(&self) -> RUN_R {
212        RUN_R::new(((self.bits >> 1) & 0x01) != 0)
213    }
214}
215impl W {
216    #[doc = "Bit 0 - Monitors the interrupt flag."]
217    #[inline(always)]
218    pub fn intflag(&mut self) -> INTFLAG_W {
219        INTFLAG_W { w: self }
220    }
221    #[doc = "Bit 1 - Indicates the state of TIMERn. This bit is read-only."]
222    #[inline(always)]
223    pub fn run(&mut self) -> RUN_W {
224        RUN_W { w: self }
225    }
226    #[doc = "Writes raw bits to the register."]
227    #[inline(always)]
228    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
229        self.0.bits(bits);
230        self
231    }
232}
233#[doc = "MRT Status register.\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 [stat](index.html) module"]
234pub struct STAT_SPEC;
235impl crate::RegisterSpec for STAT_SPEC {
236    type Ux = u32;
237}
238#[doc = "`read()` method returns [stat::R](R) reader structure"]
239impl crate::Readable for STAT_SPEC {
240    type Reader = R;
241}
242#[doc = "`write(|w| ..)` method takes [stat::W](W) writer structure"]
243impl crate::Writable for STAT_SPEC {
244    type Writer = W;
245}
246#[doc = "`reset()` method sets STAT to value 0"]
247impl crate::Resettable for STAT_SPEC {
248    #[inline(always)]
249    fn reset_value() -> Self::Ux {
250        0
251    }
252}