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