s32k118_pac/mtb_dwt/
fct0.rs

1#[doc = "Register `FCT0` reader"]
2pub struct R(crate::R<FCT0_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<FCT0_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<FCT0_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<FCT0_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `FCT0` writer"]
17pub struct W(crate::W<FCT0_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<FCT0_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<FCT0_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<FCT0_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Function\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum FUNCTION_A {
41    #[doc = "0: Disabled."]
42    _0000 = 0,
43    #[doc = "4: Instruction fetch."]
44    _0100 = 4,
45    #[doc = "5: Data operand read."]
46    _0101 = 5,
47    #[doc = "6: Data operand write."]
48    _0110 = 6,
49    #[doc = "7: Data operand (read + write)."]
50    _0111 = 7,
51}
52impl From<FUNCTION_A> for u8 {
53    #[inline(always)]
54    fn from(variant: FUNCTION_A) -> Self {
55        variant as _
56    }
57}
58#[doc = "Field `FUNCTION` reader - Function"]
59pub struct FUNCTION_R(crate::FieldReader<u8, FUNCTION_A>);
60impl FUNCTION_R {
61    #[inline(always)]
62    pub(crate) fn new(bits: u8) -> Self {
63        FUNCTION_R(crate::FieldReader::new(bits))
64    }
65    #[doc = r"Get enumerated values variant"]
66    #[inline(always)]
67    pub fn variant(&self) -> Option<FUNCTION_A> {
68        match self.bits {
69            0 => Some(FUNCTION_A::_0000),
70            4 => Some(FUNCTION_A::_0100),
71            5 => Some(FUNCTION_A::_0101),
72            6 => Some(FUNCTION_A::_0110),
73            7 => Some(FUNCTION_A::_0111),
74            _ => None,
75        }
76    }
77    #[doc = "Checks if the value of the field is `_0000`"]
78    #[inline(always)]
79    pub fn is_0000(&self) -> bool {
80        **self == FUNCTION_A::_0000
81    }
82    #[doc = "Checks if the value of the field is `_0100`"]
83    #[inline(always)]
84    pub fn is_0100(&self) -> bool {
85        **self == FUNCTION_A::_0100
86    }
87    #[doc = "Checks if the value of the field is `_0101`"]
88    #[inline(always)]
89    pub fn is_0101(&self) -> bool {
90        **self == FUNCTION_A::_0101
91    }
92    #[doc = "Checks if the value of the field is `_0110`"]
93    #[inline(always)]
94    pub fn is_0110(&self) -> bool {
95        **self == FUNCTION_A::_0110
96    }
97    #[doc = "Checks if the value of the field is `_0111`"]
98    #[inline(always)]
99    pub fn is_0111(&self) -> bool {
100        **self == FUNCTION_A::_0111
101    }
102}
103impl core::ops::Deref for FUNCTION_R {
104    type Target = crate::FieldReader<u8, FUNCTION_A>;
105    #[inline(always)]
106    fn deref(&self) -> &Self::Target {
107        &self.0
108    }
109}
110#[doc = "Field `FUNCTION` writer - Function"]
111pub struct FUNCTION_W<'a> {
112    w: &'a mut W,
113}
114impl<'a> FUNCTION_W<'a> {
115    #[doc = r"Writes `variant` to the field"]
116    #[inline(always)]
117    pub fn variant(self, variant: FUNCTION_A) -> &'a mut W {
118        unsafe { self.bits(variant.into()) }
119    }
120    #[doc = "Disabled."]
121    #[inline(always)]
122    pub fn _0000(self) -> &'a mut W {
123        self.variant(FUNCTION_A::_0000)
124    }
125    #[doc = "Instruction fetch."]
126    #[inline(always)]
127    pub fn _0100(self) -> &'a mut W {
128        self.variant(FUNCTION_A::_0100)
129    }
130    #[doc = "Data operand read."]
131    #[inline(always)]
132    pub fn _0101(self) -> &'a mut W {
133        self.variant(FUNCTION_A::_0101)
134    }
135    #[doc = "Data operand write."]
136    #[inline(always)]
137    pub fn _0110(self) -> &'a mut W {
138        self.variant(FUNCTION_A::_0110)
139    }
140    #[doc = "Data operand (read + write)."]
141    #[inline(always)]
142    pub fn _0111(self) -> &'a mut W {
143        self.variant(FUNCTION_A::_0111)
144    }
145    #[doc = r"Writes raw bits to the field"]
146    #[inline(always)]
147    pub unsafe fn bits(self, value: u8) -> &'a mut W {
148        self.w.bits = (self.w.bits & !0x0f) | (value as u32 & 0x0f);
149        self.w
150    }
151}
152#[doc = "Data Value Match\n\nValue on reset: 0"]
153#[derive(Clone, Copy, Debug, PartialEq)]
154pub enum DATAVMATCH_A {
155    #[doc = "0: Perform address comparison."]
156    _0 = 0,
157    #[doc = "1: Perform data value comparison."]
158    _1 = 1,
159}
160impl From<DATAVMATCH_A> for bool {
161    #[inline(always)]
162    fn from(variant: DATAVMATCH_A) -> Self {
163        variant as u8 != 0
164    }
165}
166#[doc = "Field `DATAVMATCH` reader - Data Value Match"]
167pub struct DATAVMATCH_R(crate::FieldReader<bool, DATAVMATCH_A>);
168impl DATAVMATCH_R {
169    #[inline(always)]
170    pub(crate) fn new(bits: bool) -> Self {
171        DATAVMATCH_R(crate::FieldReader::new(bits))
172    }
173    #[doc = r"Get enumerated values variant"]
174    #[inline(always)]
175    pub fn variant(&self) -> DATAVMATCH_A {
176        match self.bits {
177            false => DATAVMATCH_A::_0,
178            true => DATAVMATCH_A::_1,
179        }
180    }
181    #[doc = "Checks if the value of the field is `_0`"]
182    #[inline(always)]
183    pub fn is_0(&self) -> bool {
184        **self == DATAVMATCH_A::_0
185    }
186    #[doc = "Checks if the value of the field is `_1`"]
187    #[inline(always)]
188    pub fn is_1(&self) -> bool {
189        **self == DATAVMATCH_A::_1
190    }
191}
192impl core::ops::Deref for DATAVMATCH_R {
193    type Target = crate::FieldReader<bool, DATAVMATCH_A>;
194    #[inline(always)]
195    fn deref(&self) -> &Self::Target {
196        &self.0
197    }
198}
199#[doc = "Field `DATAVMATCH` writer - Data Value Match"]
200pub struct DATAVMATCH_W<'a> {
201    w: &'a mut W,
202}
203impl<'a> DATAVMATCH_W<'a> {
204    #[doc = r"Writes `variant` to the field"]
205    #[inline(always)]
206    pub fn variant(self, variant: DATAVMATCH_A) -> &'a mut W {
207        self.bit(variant.into())
208    }
209    #[doc = "Perform address comparison."]
210    #[inline(always)]
211    pub fn _0(self) -> &'a mut W {
212        self.variant(DATAVMATCH_A::_0)
213    }
214    #[doc = "Perform data value comparison."]
215    #[inline(always)]
216    pub fn _1(self) -> &'a mut W {
217        self.variant(DATAVMATCH_A::_1)
218    }
219    #[doc = r"Sets the field bit"]
220    #[inline(always)]
221    pub fn set_bit(self) -> &'a mut W {
222        self.bit(true)
223    }
224    #[doc = r"Clears the field bit"]
225    #[inline(always)]
226    pub fn clear_bit(self) -> &'a mut W {
227        self.bit(false)
228    }
229    #[doc = r"Writes raw bits to the field"]
230    #[inline(always)]
231    pub fn bit(self, value: bool) -> &'a mut W {
232        self.w.bits = (self.w.bits & !(0x01 << 8)) | ((value as u32 & 0x01) << 8);
233        self.w
234    }
235}
236#[doc = "Data Value Size\n\nValue on reset: 0"]
237#[derive(Clone, Copy, Debug, PartialEq)]
238#[repr(u8)]
239pub enum DATAVSIZE_A {
240    #[doc = "0: Byte."]
241    _00 = 0,
242    #[doc = "1: Halfword."]
243    _01 = 1,
244    #[doc = "2: Word."]
245    _10 = 2,
246    #[doc = "3: Reserved. Any attempts to use this value results in UNPREDICTABLE behavior."]
247    _11 = 3,
248}
249impl From<DATAVSIZE_A> for u8 {
250    #[inline(always)]
251    fn from(variant: DATAVSIZE_A) -> Self {
252        variant as _
253    }
254}
255#[doc = "Field `DATAVSIZE` reader - Data Value Size"]
256pub struct DATAVSIZE_R(crate::FieldReader<u8, DATAVSIZE_A>);
257impl DATAVSIZE_R {
258    #[inline(always)]
259    pub(crate) fn new(bits: u8) -> Self {
260        DATAVSIZE_R(crate::FieldReader::new(bits))
261    }
262    #[doc = r"Get enumerated values variant"]
263    #[inline(always)]
264    pub fn variant(&self) -> DATAVSIZE_A {
265        match self.bits {
266            0 => DATAVSIZE_A::_00,
267            1 => DATAVSIZE_A::_01,
268            2 => DATAVSIZE_A::_10,
269            3 => DATAVSIZE_A::_11,
270            _ => unreachable!(),
271        }
272    }
273    #[doc = "Checks if the value of the field is `_00`"]
274    #[inline(always)]
275    pub fn is_00(&self) -> bool {
276        **self == DATAVSIZE_A::_00
277    }
278    #[doc = "Checks if the value of the field is `_01`"]
279    #[inline(always)]
280    pub fn is_01(&self) -> bool {
281        **self == DATAVSIZE_A::_01
282    }
283    #[doc = "Checks if the value of the field is `_10`"]
284    #[inline(always)]
285    pub fn is_10(&self) -> bool {
286        **self == DATAVSIZE_A::_10
287    }
288    #[doc = "Checks if the value of the field is `_11`"]
289    #[inline(always)]
290    pub fn is_11(&self) -> bool {
291        **self == DATAVSIZE_A::_11
292    }
293}
294impl core::ops::Deref for DATAVSIZE_R {
295    type Target = crate::FieldReader<u8, DATAVSIZE_A>;
296    #[inline(always)]
297    fn deref(&self) -> &Self::Target {
298        &self.0
299    }
300}
301#[doc = "Field `DATAVSIZE` writer - Data Value Size"]
302pub struct DATAVSIZE_W<'a> {
303    w: &'a mut W,
304}
305impl<'a> DATAVSIZE_W<'a> {
306    #[doc = r"Writes `variant` to the field"]
307    #[inline(always)]
308    pub fn variant(self, variant: DATAVSIZE_A) -> &'a mut W {
309        self.bits(variant.into())
310    }
311    #[doc = "Byte."]
312    #[inline(always)]
313    pub fn _00(self) -> &'a mut W {
314        self.variant(DATAVSIZE_A::_00)
315    }
316    #[doc = "Halfword."]
317    #[inline(always)]
318    pub fn _01(self) -> &'a mut W {
319        self.variant(DATAVSIZE_A::_01)
320    }
321    #[doc = "Word."]
322    #[inline(always)]
323    pub fn _10(self) -> &'a mut W {
324        self.variant(DATAVSIZE_A::_10)
325    }
326    #[doc = "Reserved. Any attempts to use this value results in UNPREDICTABLE behavior."]
327    #[inline(always)]
328    pub fn _11(self) -> &'a mut W {
329        self.variant(DATAVSIZE_A::_11)
330    }
331    #[doc = r"Writes raw bits to the field"]
332    #[inline(always)]
333    pub fn bits(self, value: u8) -> &'a mut W {
334        self.w.bits = (self.w.bits & !(0x03 << 10)) | ((value as u32 & 0x03) << 10);
335        self.w
336    }
337}
338#[doc = "Field `DATAVADDR0` reader - Data Value Address 0"]
339pub struct DATAVADDR0_R(crate::FieldReader<u8, u8>);
340impl DATAVADDR0_R {
341    #[inline(always)]
342    pub(crate) fn new(bits: u8) -> Self {
343        DATAVADDR0_R(crate::FieldReader::new(bits))
344    }
345}
346impl core::ops::Deref for DATAVADDR0_R {
347    type Target = crate::FieldReader<u8, u8>;
348    #[inline(always)]
349    fn deref(&self) -> &Self::Target {
350        &self.0
351    }
352}
353#[doc = "Field `DATAVADDR0` writer - Data Value Address 0"]
354pub struct DATAVADDR0_W<'a> {
355    w: &'a mut W,
356}
357impl<'a> DATAVADDR0_W<'a> {
358    #[doc = r"Writes raw bits to the field"]
359    #[inline(always)]
360    pub unsafe fn bits(self, value: u8) -> &'a mut W {
361        self.w.bits = (self.w.bits & !(0x0f << 12)) | ((value as u32 & 0x0f) << 12);
362        self.w
363    }
364}
365#[doc = "Comparator match\n\nValue on reset: 0"]
366#[derive(Clone, Copy, Debug, PartialEq)]
367pub enum MATCHED_A {
368    #[doc = "0: No match."]
369    _0 = 0,
370    #[doc = "1: Match occurred."]
371    _1 = 1,
372}
373impl From<MATCHED_A> for bool {
374    #[inline(always)]
375    fn from(variant: MATCHED_A) -> Self {
376        variant as u8 != 0
377    }
378}
379#[doc = "Field `MATCHED` reader - Comparator match"]
380pub struct MATCHED_R(crate::FieldReader<bool, MATCHED_A>);
381impl MATCHED_R {
382    #[inline(always)]
383    pub(crate) fn new(bits: bool) -> Self {
384        MATCHED_R(crate::FieldReader::new(bits))
385    }
386    #[doc = r"Get enumerated values variant"]
387    #[inline(always)]
388    pub fn variant(&self) -> MATCHED_A {
389        match self.bits {
390            false => MATCHED_A::_0,
391            true => MATCHED_A::_1,
392        }
393    }
394    #[doc = "Checks if the value of the field is `_0`"]
395    #[inline(always)]
396    pub fn is_0(&self) -> bool {
397        **self == MATCHED_A::_0
398    }
399    #[doc = "Checks if the value of the field is `_1`"]
400    #[inline(always)]
401    pub fn is_1(&self) -> bool {
402        **self == MATCHED_A::_1
403    }
404}
405impl core::ops::Deref for MATCHED_R {
406    type Target = crate::FieldReader<bool, MATCHED_A>;
407    #[inline(always)]
408    fn deref(&self) -> &Self::Target {
409        &self.0
410    }
411}
412impl R {
413    #[doc = "Bits 0:3 - Function"]
414    #[inline(always)]
415    pub fn function(&self) -> FUNCTION_R {
416        FUNCTION_R::new((self.bits & 0x0f) as u8)
417    }
418    #[doc = "Bit 8 - Data Value Match"]
419    #[inline(always)]
420    pub fn datavmatch(&self) -> DATAVMATCH_R {
421        DATAVMATCH_R::new(((self.bits >> 8) & 0x01) != 0)
422    }
423    #[doc = "Bits 10:11 - Data Value Size"]
424    #[inline(always)]
425    pub fn datavsize(&self) -> DATAVSIZE_R {
426        DATAVSIZE_R::new(((self.bits >> 10) & 0x03) as u8)
427    }
428    #[doc = "Bits 12:15 - Data Value Address 0"]
429    #[inline(always)]
430    pub fn datavaddr0(&self) -> DATAVADDR0_R {
431        DATAVADDR0_R::new(((self.bits >> 12) & 0x0f) as u8)
432    }
433    #[doc = "Bit 24 - Comparator match"]
434    #[inline(always)]
435    pub fn matched(&self) -> MATCHED_R {
436        MATCHED_R::new(((self.bits >> 24) & 0x01) != 0)
437    }
438}
439impl W {
440    #[doc = "Bits 0:3 - Function"]
441    #[inline(always)]
442    pub fn function(&mut self) -> FUNCTION_W {
443        FUNCTION_W { w: self }
444    }
445    #[doc = "Bit 8 - Data Value Match"]
446    #[inline(always)]
447    pub fn datavmatch(&mut self) -> DATAVMATCH_W {
448        DATAVMATCH_W { w: self }
449    }
450    #[doc = "Bits 10:11 - Data Value Size"]
451    #[inline(always)]
452    pub fn datavsize(&mut self) -> DATAVSIZE_W {
453        DATAVSIZE_W { w: self }
454    }
455    #[doc = "Bits 12:15 - Data Value Address 0"]
456    #[inline(always)]
457    pub fn datavaddr0(&mut self) -> DATAVADDR0_W {
458        DATAVADDR0_W { w: self }
459    }
460    #[doc = "Writes raw bits to the register."]
461    #[inline(always)]
462    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
463        self.0.bits(bits);
464        self
465    }
466}
467#[doc = "MTB_DWT Comparator Function Register 0\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 [fct0](index.html) module"]
468pub struct FCT0_SPEC;
469impl crate::RegisterSpec for FCT0_SPEC {
470    type Ux = u32;
471}
472#[doc = "`read()` method returns [fct0::R](R) reader structure"]
473impl crate::Readable for FCT0_SPEC {
474    type Reader = R;
475}
476#[doc = "`write(|w| ..)` method takes [fct0::W](W) writer structure"]
477impl crate::Writable for FCT0_SPEC {
478    type Writer = W;
479}
480#[doc = "`reset()` method sets FCT0 to value 0"]
481impl crate::Resettable for FCT0_SPEC {
482    #[inline(always)]
483    fn reset_value() -> Self::Ux {
484        0
485    }
486}