Skip to main content

rsl10_pac/sysctrl/
sysctrl_cnt_ctrl.rs

1#[doc = "Reader of register SYSCTRL_CNT_CTRL"]
2pub type R = crate::R<u32, super::SYSCTRL_CNT_CTRL>;
3#[doc = "Writer for register SYSCTRL_CNT_CTRL"]
4pub type W = crate::W<u32, super::SYSCTRL_CNT_CTRL>;
5#[doc = "Register SYSCTRL_CNT_CTRL `reset()`'s with value 0"]
6impl crate::ResetValue for super::SYSCTRL_CNT_CTRL {
7    type Type = u32;
8    #[inline(always)]
9    fn reset_value() -> Self::Type {
10        0
11    }
12}
13#[doc = "Activity counters status bit\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub enum CNT_STATUS_A {
16    #[doc = "0: Activity counters stopped"]
17    CNT_STOPPED = 0,
18    #[doc = "1: Activity counters running"]
19    CNT_RUNNING = 1,
20}
21impl From<CNT_STATUS_A> for bool {
22    #[inline(always)]
23    fn from(variant: CNT_STATUS_A) -> Self {
24        variant as u8 != 0
25    }
26}
27#[doc = "Reader of field `CNT_STATUS`"]
28pub type CNT_STATUS_R = crate::R<bool, CNT_STATUS_A>;
29impl CNT_STATUS_R {
30    #[doc = r"Get enumerated values variant"]
31    #[inline(always)]
32    pub fn variant(&self) -> CNT_STATUS_A {
33        match self.bits {
34            false => CNT_STATUS_A::CNT_STOPPED,
35            true => CNT_STATUS_A::CNT_RUNNING,
36        }
37    }
38    #[doc = "Checks if the value of the field is `CNT_STOPPED`"]
39    #[inline(always)]
40    pub fn is_cnt_stopped(&self) -> bool {
41        *self == CNT_STATUS_A::CNT_STOPPED
42    }
43    #[doc = "Checks if the value of the field is `CNT_RUNNING`"]
44    #[inline(always)]
45    pub fn is_cnt_running(&self) -> bool {
46        *self == CNT_STATUS_A::CNT_RUNNING
47    }
48}
49#[doc = "Clear activity counters\n\nValue on reset: 0"]
50#[derive(Clone, Copy, Debug, PartialEq)]
51pub enum CNT_CLEAR_AW {
52    #[doc = "1: Clear activity counters"]
53    CNT_CLEAR = 1,
54}
55impl From<CNT_CLEAR_AW> for bool {
56    #[inline(always)]
57    fn from(variant: CNT_CLEAR_AW) -> Self {
58        variant as u8 != 0
59    }
60}
61#[doc = "Write proxy for field `CNT_CLEAR`"]
62pub struct CNT_CLEAR_W<'a> {
63    w: &'a mut W,
64}
65impl<'a> CNT_CLEAR_W<'a> {
66    #[doc = r"Writes `variant` to the field"]
67    #[inline(always)]
68    pub fn variant(self, variant: CNT_CLEAR_AW) -> &'a mut W {
69        {
70            self.bit(variant.into())
71        }
72    }
73    #[doc = "Clear activity counters"]
74    #[inline(always)]
75    pub fn cnt_clear(self) -> &'a mut W {
76        self.variant(CNT_CLEAR_AW::CNT_CLEAR)
77    }
78    #[doc = r"Sets the field bit"]
79    #[inline(always)]
80    pub fn set_bit(self) -> &'a mut W {
81        self.bit(true)
82    }
83    #[doc = r"Clears the field bit"]
84    #[inline(always)]
85    pub fn clear_bit(self) -> &'a mut W {
86        self.bit(false)
87    }
88    #[doc = r"Writes raw bits to the field"]
89    #[inline(always)]
90    pub fn bit(self, value: bool) -> &'a mut W {
91        self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
92        self.w
93    }
94}
95#[doc = "Stop activity counters\n\nValue on reset: 0"]
96#[derive(Clone, Copy, Debug, PartialEq)]
97pub enum CNT_STOP_AW {
98    #[doc = "1: Stop activity counters"]
99    CNT_STOP = 1,
100}
101impl From<CNT_STOP_AW> for bool {
102    #[inline(always)]
103    fn from(variant: CNT_STOP_AW) -> Self {
104        variant as u8 != 0
105    }
106}
107#[doc = "Write proxy for field `CNT_STOP`"]
108pub struct CNT_STOP_W<'a> {
109    w: &'a mut W,
110}
111impl<'a> CNT_STOP_W<'a> {
112    #[doc = r"Writes `variant` to the field"]
113    #[inline(always)]
114    pub fn variant(self, variant: CNT_STOP_AW) -> &'a mut W {
115        {
116            self.bit(variant.into())
117        }
118    }
119    #[doc = "Stop activity counters"]
120    #[inline(always)]
121    pub fn cnt_stop(self) -> &'a mut W {
122        self.variant(CNT_STOP_AW::CNT_STOP)
123    }
124    #[doc = r"Sets the field bit"]
125    #[inline(always)]
126    pub fn set_bit(self) -> &'a mut W {
127        self.bit(true)
128    }
129    #[doc = r"Clears the field bit"]
130    #[inline(always)]
131    pub fn clear_bit(self) -> &'a mut W {
132        self.bit(false)
133    }
134    #[doc = r"Writes raw bits to the field"]
135    #[inline(always)]
136    pub fn bit(self, value: bool) -> &'a mut W {
137        self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
138        self.w
139    }
140}
141#[doc = "Start activity counters\n\nValue on reset: 0"]
142#[derive(Clone, Copy, Debug, PartialEq)]
143pub enum CNT_START_AW {
144    #[doc = "1: Start activity counters"]
145    CNT_START = 1,
146}
147impl From<CNT_START_AW> for bool {
148    #[inline(always)]
149    fn from(variant: CNT_START_AW) -> Self {
150        variant as u8 != 0
151    }
152}
153#[doc = "Write proxy for field `CNT_START`"]
154pub struct CNT_START_W<'a> {
155    w: &'a mut W,
156}
157impl<'a> CNT_START_W<'a> {
158    #[doc = r"Writes `variant` to the field"]
159    #[inline(always)]
160    pub fn variant(self, variant: CNT_START_AW) -> &'a mut W {
161        {
162            self.bit(variant.into())
163        }
164    }
165    #[doc = "Start activity counters"]
166    #[inline(always)]
167    pub fn cnt_start(self) -> &'a mut W {
168        self.variant(CNT_START_AW::CNT_START)
169    }
170    #[doc = r"Sets the field bit"]
171    #[inline(always)]
172    pub fn set_bit(self) -> &'a mut W {
173        self.bit(true)
174    }
175    #[doc = r"Clears the field bit"]
176    #[inline(always)]
177    pub fn clear_bit(self) -> &'a mut W {
178        self.bit(false)
179    }
180    #[doc = r"Writes raw bits to the field"]
181    #[inline(always)]
182    pub fn bit(self, value: bool) -> &'a mut W {
183        self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
184        self.w
185    }
186}
187impl R {
188    #[doc = "Bit 3 - Activity counters status bit"]
189    #[inline(always)]
190    pub fn cnt_status(&self) -> CNT_STATUS_R {
191        CNT_STATUS_R::new(((self.bits >> 3) & 0x01) != 0)
192    }
193}
194impl W {
195    #[doc = "Bit 2 - Clear activity counters"]
196    #[inline(always)]
197    pub fn cnt_clear(&mut self) -> CNT_CLEAR_W {
198        CNT_CLEAR_W { w: self }
199    }
200    #[doc = "Bit 1 - Stop activity counters"]
201    #[inline(always)]
202    pub fn cnt_stop(&mut self) -> CNT_STOP_W {
203        CNT_STOP_W { w: self }
204    }
205    #[doc = "Bit 0 - Start activity counters"]
206    #[inline(always)]
207    pub fn cnt_start(&mut self) -> CNT_START_W {
208        CNT_START_W { w: self }
209    }
210}