rsl10_pac/timer/
timer_ctrl.rs1#[doc = "Reader of register TIMER_CTRL[%s]"]
2pub type R = crate::R<u32, super::TIMER_CTRL>;
3#[doc = "Writer for register TIMER_CTRL[%s]"]
4pub type W = crate::W<u32, super::TIMER_CTRL>;
5#[doc = "Register TIMER_CTRL[%s]
6`reset()`'s with value 0"]
7impl crate::ResetValue for super::TIMER_CTRL {
8 type Type = u32;
9 #[inline(always)]
10 fn reset_value() -> Self::Type {
11 0
12 }
13}
14#[doc = "Indicate if the timer is active or not\n\nValue on reset: 0"]
15#[derive(Clone, Copy, Debug, PartialEq)]
16pub enum TIMER_STATUS_A {
17 #[doc = "0: The timer is inactive"]
18 TIMER_INACTIVE = 0,
19 #[doc = "1: The timer is active"]
20 TIMER_ACTIVE = 1,
21}
22impl From<TIMER_STATUS_A> for bool {
23 #[inline(always)]
24 fn from(variant: TIMER_STATUS_A) -> Self {
25 variant as u8 != 0
26 }
27}
28#[doc = "Reader of field `TIMER_STATUS`"]
29pub type TIMER_STATUS_R = crate::R<bool, TIMER_STATUS_A>;
30impl TIMER_STATUS_R {
31 #[doc = r"Get enumerated values variant"]
32 #[inline(always)]
33 pub fn variant(&self) -> TIMER_STATUS_A {
34 match self.bits {
35 false => TIMER_STATUS_A::TIMER_INACTIVE,
36 true => TIMER_STATUS_A::TIMER_ACTIVE,
37 }
38 }
39 #[doc = "Checks if the value of the field is `TIMER_INACTIVE`"]
40 #[inline(always)]
41 pub fn is_timer_inactive(&self) -> bool {
42 *self == TIMER_STATUS_A::TIMER_INACTIVE
43 }
44 #[doc = "Checks if the value of the field is `TIMER_ACTIVE`"]
45 #[inline(always)]
46 pub fn is_timer_active(&self) -> bool {
47 *self == TIMER_STATUS_A::TIMER_ACTIVE
48 }
49}
50#[doc = "Start or restart the timer\n\nValue on reset: 0"]
51#[derive(Clone, Copy, Debug, PartialEq)]
52pub enum TIMER_START_AW {
53 #[doc = "1: Writing a 1 will start or restart the timer"]
54 TIMER_START = 1,
55}
56impl From<TIMER_START_AW> for bool {
57 #[inline(always)]
58 fn from(variant: TIMER_START_AW) -> Self {
59 variant as u8 != 0
60 }
61}
62#[doc = "Write proxy for field `TIMER_START`"]
63pub struct TIMER_START_W<'a> {
64 w: &'a mut W,
65}
66impl<'a> TIMER_START_W<'a> {
67 #[doc = r"Writes `variant` to the field"]
68 #[inline(always)]
69 pub fn variant(self, variant: TIMER_START_AW) -> &'a mut W {
70 {
71 self.bit(variant.into())
72 }
73 }
74 #[doc = "Writing a 1 will start or restart the timer"]
75 #[inline(always)]
76 pub fn timer_start(self) -> &'a mut W {
77 self.variant(TIMER_START_AW::TIMER_START)
78 }
79 #[doc = r"Sets the field bit"]
80 #[inline(always)]
81 pub fn set_bit(self) -> &'a mut W {
82 self.bit(true)
83 }
84 #[doc = r"Clears the field bit"]
85 #[inline(always)]
86 pub fn clear_bit(self) -> &'a mut W {
87 self.bit(false)
88 }
89 #[doc = r"Writes raw bits to the field"]
90 #[inline(always)]
91 pub fn bit(self, value: bool) -> &'a mut W {
92 self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
93 self.w
94 }
95}
96#[doc = "Stop the timer\n\nValue on reset: 0"]
97#[derive(Clone, Copy, Debug, PartialEq)]
98pub enum TIMER_STOP_AW {
99 #[doc = "1: Writing a 1 will stop the timer"]
100 TIMER_STOP = 1,
101}
102impl From<TIMER_STOP_AW> for bool {
103 #[inline(always)]
104 fn from(variant: TIMER_STOP_AW) -> Self {
105 variant as u8 != 0
106 }
107}
108#[doc = "Write proxy for field `TIMER_STOP`"]
109pub struct TIMER_STOP_W<'a> {
110 w: &'a mut W,
111}
112impl<'a> TIMER_STOP_W<'a> {
113 #[doc = r"Writes `variant` to the field"]
114 #[inline(always)]
115 pub fn variant(self, variant: TIMER_STOP_AW) -> &'a mut W {
116 {
117 self.bit(variant.into())
118 }
119 }
120 #[doc = "Writing a 1 will stop the timer"]
121 #[inline(always)]
122 pub fn timer_stop(self) -> &'a mut W {
123 self.variant(TIMER_STOP_AW::TIMER_STOP)
124 }
125 #[doc = r"Sets the field bit"]
126 #[inline(always)]
127 pub fn set_bit(self) -> &'a mut W {
128 self.bit(true)
129 }
130 #[doc = r"Clears the field bit"]
131 #[inline(always)]
132 pub fn clear_bit(self) -> &'a mut W {
133 self.bit(false)
134 }
135 #[doc = r"Writes raw bits to the field"]
136 #[inline(always)]
137 pub fn bit(self, value: bool) -> &'a mut W {
138 self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01);
139 self.w
140 }
141}
142impl R {
143 #[doc = "Bit 2 - Indicate if the timer is active or not"]
144 #[inline(always)]
145 pub fn timer_status(&self) -> TIMER_STATUS_R {
146 TIMER_STATUS_R::new(((self.bits >> 2) & 0x01) != 0)
147 }
148}
149impl W {
150 #[doc = "Bit 1 - Start or restart the timer"]
151 #[inline(always)]
152 pub fn timer_start(&mut self) -> TIMER_START_W {
153 TIMER_START_W { w: self }
154 }
155 #[doc = "Bit 0 - Stop the timer"]
156 #[inline(always)]
157 pub fn timer_stop(&mut self) -> TIMER_STOP_W {
158 TIMER_STOP_W { w: self }
159 }
160}