lpc82x_pac/mrt0/channel/
ctrl.rs

1#[doc = "Register `CTRL` reader"]
2pub struct R(crate::R<CTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRL` writer"]
17pub struct W(crate::W<CTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<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<CTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Enable the TIMERn interrupt.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum INTEN_A {
40    #[doc = "0: Disabled. TIMERn interrupt is disabled."]
41    DISABLED = 0,
42    #[doc = "1: Enabled. TIMERn interrupt is enabled."]
43    ENABLED = 1,
44}
45impl From<INTEN_A> for bool {
46    #[inline(always)]
47    fn from(variant: INTEN_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `INTEN` reader - Enable the TIMERn interrupt."]
52pub struct INTEN_R(crate::FieldReader<bool, INTEN_A>);
53impl INTEN_R {
54    pub(crate) fn new(bits: bool) -> Self {
55        INTEN_R(crate::FieldReader::new(bits))
56    }
57    #[doc = r"Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> INTEN_A {
60        match self.bits {
61            false => INTEN_A::DISABLED,
62            true => INTEN_A::ENABLED,
63        }
64    }
65    #[doc = "Checks if the value of the field is `DISABLED`"]
66    #[inline(always)]
67    pub fn is_disabled(&self) -> bool {
68        **self == INTEN_A::DISABLED
69    }
70    #[doc = "Checks if the value of the field is `ENABLED`"]
71    #[inline(always)]
72    pub fn is_enabled(&self) -> bool {
73        **self == INTEN_A::ENABLED
74    }
75}
76impl core::ops::Deref for INTEN_R {
77    type Target = crate::FieldReader<bool, INTEN_A>;
78    #[inline(always)]
79    fn deref(&self) -> &Self::Target {
80        &self.0
81    }
82}
83#[doc = "Field `INTEN` writer - Enable the TIMERn interrupt."]
84pub struct INTEN_W<'a> {
85    w: &'a mut W,
86}
87impl<'a> INTEN_W<'a> {
88    #[doc = r"Writes `variant` to the field"]
89    #[inline(always)]
90    pub fn variant(self, variant: INTEN_A) -> &'a mut W {
91        self.bit(variant.into())
92    }
93    #[doc = "Disabled. TIMERn interrupt is disabled."]
94    #[inline(always)]
95    pub fn disabled(self) -> &'a mut W {
96        self.variant(INTEN_A::DISABLED)
97    }
98    #[doc = "Enabled. TIMERn interrupt is enabled."]
99    #[inline(always)]
100    pub fn enabled(self) -> &'a mut W {
101        self.variant(INTEN_A::ENABLED)
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 = "Selects timer mode.\n\nValue on reset: 0"]
121#[derive(Clone, Copy, Debug, PartialEq)]
122#[repr(u8)]
123pub enum MODE_A {
124    #[doc = "0: Repeat interrupt mode."]
125    REPEAT_INTERRUPT_MODE = 0,
126    #[doc = "1: One-shot interrupt mode."]
127    ONE_SHOT_INTERRUPT_MODE = 1,
128    #[doc = "2: One-shot stall mode."]
129    ONE_SHOT_STALL_MODE = 2,
130}
131impl From<MODE_A> for u8 {
132    #[inline(always)]
133    fn from(variant: MODE_A) -> Self {
134        variant as _
135    }
136}
137#[doc = "Field `MODE` reader - Selects timer mode."]
138pub struct MODE_R(crate::FieldReader<u8, MODE_A>);
139impl MODE_R {
140    pub(crate) fn new(bits: u8) -> Self {
141        MODE_R(crate::FieldReader::new(bits))
142    }
143    #[doc = r"Get enumerated values variant"]
144    #[inline(always)]
145    pub fn variant(&self) -> Option<MODE_A> {
146        match self.bits {
147            0 => Some(MODE_A::REPEAT_INTERRUPT_MODE),
148            1 => Some(MODE_A::ONE_SHOT_INTERRUPT_MODE),
149            2 => Some(MODE_A::ONE_SHOT_STALL_MODE),
150            _ => None,
151        }
152    }
153    #[doc = "Checks if the value of the field is `REPEAT_INTERRUPT_MODE`"]
154    #[inline(always)]
155    pub fn is_repeat_interrupt_mode(&self) -> bool {
156        **self == MODE_A::REPEAT_INTERRUPT_MODE
157    }
158    #[doc = "Checks if the value of the field is `ONE_SHOT_INTERRUPT_MODE`"]
159    #[inline(always)]
160    pub fn is_one_shot_interrupt_mode(&self) -> bool {
161        **self == MODE_A::ONE_SHOT_INTERRUPT_MODE
162    }
163    #[doc = "Checks if the value of the field is `ONE_SHOT_STALL_MODE`"]
164    #[inline(always)]
165    pub fn is_one_shot_stall_mode(&self) -> bool {
166        **self == MODE_A::ONE_SHOT_STALL_MODE
167    }
168}
169impl core::ops::Deref for MODE_R {
170    type Target = crate::FieldReader<u8, MODE_A>;
171    #[inline(always)]
172    fn deref(&self) -> &Self::Target {
173        &self.0
174    }
175}
176#[doc = "Field `MODE` writer - Selects timer mode."]
177pub struct MODE_W<'a> {
178    w: &'a mut W,
179}
180impl<'a> MODE_W<'a> {
181    #[doc = r"Writes `variant` to the field"]
182    #[inline(always)]
183    pub fn variant(self, variant: MODE_A) -> &'a mut W {
184        unsafe { self.bits(variant.into()) }
185    }
186    #[doc = "Repeat interrupt mode."]
187    #[inline(always)]
188    pub fn repeat_interrupt_mode(self) -> &'a mut W {
189        self.variant(MODE_A::REPEAT_INTERRUPT_MODE)
190    }
191    #[doc = "One-shot interrupt mode."]
192    #[inline(always)]
193    pub fn one_shot_interrupt_mode(self) -> &'a mut W {
194        self.variant(MODE_A::ONE_SHOT_INTERRUPT_MODE)
195    }
196    #[doc = "One-shot stall mode."]
197    #[inline(always)]
198    pub fn one_shot_stall_mode(self) -> &'a mut W {
199        self.variant(MODE_A::ONE_SHOT_STALL_MODE)
200    }
201    #[doc = r"Writes raw bits to the field"]
202    #[inline(always)]
203    pub unsafe fn bits(self, value: u8) -> &'a mut W {
204        self.w.bits = (self.w.bits & !(0x03 << 1)) | ((value as u32 & 0x03) << 1);
205        self.w
206    }
207}
208impl R {
209    #[doc = "Bit 0 - Enable the TIMERn interrupt."]
210    #[inline(always)]
211    pub fn inten(&self) -> INTEN_R {
212        INTEN_R::new((self.bits & 0x01) != 0)
213    }
214    #[doc = "Bits 1:2 - Selects timer mode."]
215    #[inline(always)]
216    pub fn mode(&self) -> MODE_R {
217        MODE_R::new(((self.bits >> 1) & 0x03) as u8)
218    }
219}
220impl W {
221    #[doc = "Bit 0 - Enable the TIMERn interrupt."]
222    #[inline(always)]
223    pub fn inten(&mut self) -> INTEN_W {
224        INTEN_W { w: self }
225    }
226    #[doc = "Bits 1:2 - Selects timer mode."]
227    #[inline(always)]
228    pub fn mode(&mut self) -> MODE_W {
229        MODE_W { w: self }
230    }
231    #[doc = "Writes raw bits to the register."]
232    #[inline(always)]
233    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
234        self.0.bits(bits);
235        self
236    }
237}
238#[doc = "MRT Control register. This register controls the MRT modes.\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 [ctrl](index.html) module"]
239pub struct CTRL_SPEC;
240impl crate::RegisterSpec for CTRL_SPEC {
241    type Ux = u32;
242}
243#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
244impl crate::Readable for CTRL_SPEC {
245    type Reader = R;
246}
247#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
248impl crate::Writable for CTRL_SPEC {
249    type Writer = W;
250}
251#[doc = "`reset()` method sets CTRL to value 0"]
252impl crate::Resettable for CTRL_SPEC {
253    #[inline(always)]
254    fn reset_value() -> Self::Ux {
255        0
256    }
257}