atsamd51g/cmcc/
mcfg.rs
1#[doc = "Register `MCFG` reader"]
2pub type R = crate::R<McfgSpec>;
3#[doc = "Register `MCFG` writer"]
4pub type W = crate::W<McfgSpec>;
5#[doc = "Cache Controller Monitor Counter Mode\n\nValue on reset: 0"]
6#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7#[repr(u8)]
8pub enum Modeselect {
9 #[doc = "0: Cycle counter"]
10 CycleCount = 0,
11 #[doc = "1: Instruction hit counter"]
12 IhitCount = 1,
13 #[doc = "2: Data hit counter"]
14 DhitCount = 2,
15}
16impl From<Modeselect> for u8 {
17 #[inline(always)]
18 fn from(variant: Modeselect) -> Self {
19 variant as _
20 }
21}
22impl crate::FieldSpec for Modeselect {
23 type Ux = u8;
24}
25impl crate::IsEnum for Modeselect {}
26#[doc = "Field `MODE` reader - Cache Controller Monitor Counter Mode"]
27pub type ModeR = crate::FieldReader<Modeselect>;
28impl ModeR {
29 #[doc = "Get enumerated values variant"]
30 #[inline(always)]
31 pub const fn variant(&self) -> Option<Modeselect> {
32 match self.bits {
33 0 => Some(Modeselect::CycleCount),
34 1 => Some(Modeselect::IhitCount),
35 2 => Some(Modeselect::DhitCount),
36 _ => None,
37 }
38 }
39 #[doc = "Cycle counter"]
40 #[inline(always)]
41 pub fn is_cycle_count(&self) -> bool {
42 *self == Modeselect::CycleCount
43 }
44 #[doc = "Instruction hit counter"]
45 #[inline(always)]
46 pub fn is_ihit_count(&self) -> bool {
47 *self == Modeselect::IhitCount
48 }
49 #[doc = "Data hit counter"]
50 #[inline(always)]
51 pub fn is_dhit_count(&self) -> bool {
52 *self == Modeselect::DhitCount
53 }
54}
55#[doc = "Field `MODE` writer - Cache Controller Monitor Counter Mode"]
56pub type ModeW<'a, REG> = crate::FieldWriter<'a, REG, 2, Modeselect>;
57impl<'a, REG> ModeW<'a, REG>
58where
59 REG: crate::Writable + crate::RegisterSpec,
60 REG::Ux: From<u8>,
61{
62 #[doc = "Cycle counter"]
63 #[inline(always)]
64 pub fn cycle_count(self) -> &'a mut crate::W<REG> {
65 self.variant(Modeselect::CycleCount)
66 }
67 #[doc = "Instruction hit counter"]
68 #[inline(always)]
69 pub fn ihit_count(self) -> &'a mut crate::W<REG> {
70 self.variant(Modeselect::IhitCount)
71 }
72 #[doc = "Data hit counter"]
73 #[inline(always)]
74 pub fn dhit_count(self) -> &'a mut crate::W<REG> {
75 self.variant(Modeselect::DhitCount)
76 }
77}
78impl R {
79 #[doc = "Bits 0:1 - Cache Controller Monitor Counter Mode"]
80 #[inline(always)]
81 pub fn mode(&self) -> ModeR {
82 ModeR::new((self.bits & 3) as u8)
83 }
84}
85impl W {
86 #[doc = "Bits 0:1 - Cache Controller Monitor Counter Mode"]
87 #[inline(always)]
88 #[must_use]
89 pub fn mode(&mut self) -> ModeW<McfgSpec> {
90 ModeW::new(self, 0)
91 }
92}
93#[doc = "Cache Monitor Configuration Register\n\nYou can [`read`](crate::Reg::read) this register and get [`mcfg::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`mcfg::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
94pub struct McfgSpec;
95impl crate::RegisterSpec for McfgSpec {
96 type Ux = u32;
97}
98#[doc = "`read()` method returns [`mcfg::R`](R) reader structure"]
99impl crate::Readable for McfgSpec {}
100#[doc = "`write(|w| ..)` method takes [`mcfg::W`](W) writer structure"]
101impl crate::Writable for McfgSpec {
102 type Safety = crate::Unsafe;
103 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
104 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
105}
106#[doc = "`reset()` method sets MCFG to value 0"]
107impl crate::Resettable for McfgSpec {
108 const RESET_VALUE: u32 = 0;
109}