avr_device/devices/atmega4809/rtc/
pitctrla.rs1#[doc = "Register `PITCTRLA` reader"]
2pub struct R(crate::R<PITCTRLA_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<PITCTRLA_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<PITCTRLA_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<PITCTRLA_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `PITCTRLA` writer"]
17pub struct W(crate::W<PITCTRLA_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<PITCTRLA_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<PITCTRLA_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<PITCTRLA_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `PITEN` reader - Enable"]
38pub type PITEN_R = crate::BitReader<bool>;
39#[doc = "Field `PITEN` writer - Enable"]
40pub type PITEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, PITCTRLA_SPEC, bool, O>;
41#[doc = "Field `PERIOD` reader - Period"]
42pub type PERIOD_R = crate::FieldReader<u8, PERIOD_A>;
43#[doc = "Period\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum PERIOD_A {
47 #[doc = "0: Off"]
48 OFF = 0,
49 #[doc = "1: RTC Clock Cycles 4"]
50 CYC4 = 1,
51 #[doc = "2: RTC Clock Cycles 8"]
52 CYC8 = 2,
53 #[doc = "3: RTC Clock Cycles 16"]
54 CYC16 = 3,
55 #[doc = "4: RTC Clock Cycles 32"]
56 CYC32 = 4,
57 #[doc = "5: RTC Clock Cycles 64"]
58 CYC64 = 5,
59 #[doc = "6: RTC Clock Cycles 128"]
60 CYC128 = 6,
61 #[doc = "7: RTC Clock Cycles 256"]
62 CYC256 = 7,
63 #[doc = "8: RTC Clock Cycles 512"]
64 CYC512 = 8,
65 #[doc = "9: RTC Clock Cycles 1024"]
66 CYC1024 = 9,
67 #[doc = "10: RTC Clock Cycles 2048"]
68 CYC2048 = 10,
69 #[doc = "11: RTC Clock Cycles 4096"]
70 CYC4096 = 11,
71 #[doc = "12: RTC Clock Cycles 8192"]
72 CYC8192 = 12,
73 #[doc = "13: RTC Clock Cycles 16384"]
74 CYC16384 = 13,
75 #[doc = "14: RTC Clock Cycles 32768"]
76 CYC32768 = 14,
77}
78impl From<PERIOD_A> for u8 {
79 #[inline(always)]
80 fn from(variant: PERIOD_A) -> Self {
81 variant as _
82 }
83}
84impl PERIOD_R {
85 #[doc = "Get enumerated values variant"]
86 #[inline(always)]
87 pub fn variant(&self) -> Option<PERIOD_A> {
88 match self.bits {
89 0 => Some(PERIOD_A::OFF),
90 1 => Some(PERIOD_A::CYC4),
91 2 => Some(PERIOD_A::CYC8),
92 3 => Some(PERIOD_A::CYC16),
93 4 => Some(PERIOD_A::CYC32),
94 5 => Some(PERIOD_A::CYC64),
95 6 => Some(PERIOD_A::CYC128),
96 7 => Some(PERIOD_A::CYC256),
97 8 => Some(PERIOD_A::CYC512),
98 9 => Some(PERIOD_A::CYC1024),
99 10 => Some(PERIOD_A::CYC2048),
100 11 => Some(PERIOD_A::CYC4096),
101 12 => Some(PERIOD_A::CYC8192),
102 13 => Some(PERIOD_A::CYC16384),
103 14 => Some(PERIOD_A::CYC32768),
104 _ => None,
105 }
106 }
107 #[doc = "Checks if the value of the field is `OFF`"]
108 #[inline(always)]
109 pub fn is_off(&self) -> bool {
110 *self == PERIOD_A::OFF
111 }
112 #[doc = "Checks if the value of the field is `CYC4`"]
113 #[inline(always)]
114 pub fn is_cyc4(&self) -> bool {
115 *self == PERIOD_A::CYC4
116 }
117 #[doc = "Checks if the value of the field is `CYC8`"]
118 #[inline(always)]
119 pub fn is_cyc8(&self) -> bool {
120 *self == PERIOD_A::CYC8
121 }
122 #[doc = "Checks if the value of the field is `CYC16`"]
123 #[inline(always)]
124 pub fn is_cyc16(&self) -> bool {
125 *self == PERIOD_A::CYC16
126 }
127 #[doc = "Checks if the value of the field is `CYC32`"]
128 #[inline(always)]
129 pub fn is_cyc32(&self) -> bool {
130 *self == PERIOD_A::CYC32
131 }
132 #[doc = "Checks if the value of the field is `CYC64`"]
133 #[inline(always)]
134 pub fn is_cyc64(&self) -> bool {
135 *self == PERIOD_A::CYC64
136 }
137 #[doc = "Checks if the value of the field is `CYC128`"]
138 #[inline(always)]
139 pub fn is_cyc128(&self) -> bool {
140 *self == PERIOD_A::CYC128
141 }
142 #[doc = "Checks if the value of the field is `CYC256`"]
143 #[inline(always)]
144 pub fn is_cyc256(&self) -> bool {
145 *self == PERIOD_A::CYC256
146 }
147 #[doc = "Checks if the value of the field is `CYC512`"]
148 #[inline(always)]
149 pub fn is_cyc512(&self) -> bool {
150 *self == PERIOD_A::CYC512
151 }
152 #[doc = "Checks if the value of the field is `CYC1024`"]
153 #[inline(always)]
154 pub fn is_cyc1024(&self) -> bool {
155 *self == PERIOD_A::CYC1024
156 }
157 #[doc = "Checks if the value of the field is `CYC2048`"]
158 #[inline(always)]
159 pub fn is_cyc2048(&self) -> bool {
160 *self == PERIOD_A::CYC2048
161 }
162 #[doc = "Checks if the value of the field is `CYC4096`"]
163 #[inline(always)]
164 pub fn is_cyc4096(&self) -> bool {
165 *self == PERIOD_A::CYC4096
166 }
167 #[doc = "Checks if the value of the field is `CYC8192`"]
168 #[inline(always)]
169 pub fn is_cyc8192(&self) -> bool {
170 *self == PERIOD_A::CYC8192
171 }
172 #[doc = "Checks if the value of the field is `CYC16384`"]
173 #[inline(always)]
174 pub fn is_cyc16384(&self) -> bool {
175 *self == PERIOD_A::CYC16384
176 }
177 #[doc = "Checks if the value of the field is `CYC32768`"]
178 #[inline(always)]
179 pub fn is_cyc32768(&self) -> bool {
180 *self == PERIOD_A::CYC32768
181 }
182}
183#[doc = "Field `PERIOD` writer - Period"]
184pub type PERIOD_W<'a, const O: u8> = crate::FieldWriter<'a, u8, PITCTRLA_SPEC, u8, PERIOD_A, 4, O>;
185impl<'a, const O: u8> PERIOD_W<'a, O> {
186 #[doc = "Off"]
187 #[inline(always)]
188 pub fn off(self) -> &'a mut W {
189 self.variant(PERIOD_A::OFF)
190 }
191 #[doc = "RTC Clock Cycles 4"]
192 #[inline(always)]
193 pub fn cyc4(self) -> &'a mut W {
194 self.variant(PERIOD_A::CYC4)
195 }
196 #[doc = "RTC Clock Cycles 8"]
197 #[inline(always)]
198 pub fn cyc8(self) -> &'a mut W {
199 self.variant(PERIOD_A::CYC8)
200 }
201 #[doc = "RTC Clock Cycles 16"]
202 #[inline(always)]
203 pub fn cyc16(self) -> &'a mut W {
204 self.variant(PERIOD_A::CYC16)
205 }
206 #[doc = "RTC Clock Cycles 32"]
207 #[inline(always)]
208 pub fn cyc32(self) -> &'a mut W {
209 self.variant(PERIOD_A::CYC32)
210 }
211 #[doc = "RTC Clock Cycles 64"]
212 #[inline(always)]
213 pub fn cyc64(self) -> &'a mut W {
214 self.variant(PERIOD_A::CYC64)
215 }
216 #[doc = "RTC Clock Cycles 128"]
217 #[inline(always)]
218 pub fn cyc128(self) -> &'a mut W {
219 self.variant(PERIOD_A::CYC128)
220 }
221 #[doc = "RTC Clock Cycles 256"]
222 #[inline(always)]
223 pub fn cyc256(self) -> &'a mut W {
224 self.variant(PERIOD_A::CYC256)
225 }
226 #[doc = "RTC Clock Cycles 512"]
227 #[inline(always)]
228 pub fn cyc512(self) -> &'a mut W {
229 self.variant(PERIOD_A::CYC512)
230 }
231 #[doc = "RTC Clock Cycles 1024"]
232 #[inline(always)]
233 pub fn cyc1024(self) -> &'a mut W {
234 self.variant(PERIOD_A::CYC1024)
235 }
236 #[doc = "RTC Clock Cycles 2048"]
237 #[inline(always)]
238 pub fn cyc2048(self) -> &'a mut W {
239 self.variant(PERIOD_A::CYC2048)
240 }
241 #[doc = "RTC Clock Cycles 4096"]
242 #[inline(always)]
243 pub fn cyc4096(self) -> &'a mut W {
244 self.variant(PERIOD_A::CYC4096)
245 }
246 #[doc = "RTC Clock Cycles 8192"]
247 #[inline(always)]
248 pub fn cyc8192(self) -> &'a mut W {
249 self.variant(PERIOD_A::CYC8192)
250 }
251 #[doc = "RTC Clock Cycles 16384"]
252 #[inline(always)]
253 pub fn cyc16384(self) -> &'a mut W {
254 self.variant(PERIOD_A::CYC16384)
255 }
256 #[doc = "RTC Clock Cycles 32768"]
257 #[inline(always)]
258 pub fn cyc32768(self) -> &'a mut W {
259 self.variant(PERIOD_A::CYC32768)
260 }
261}
262impl R {
263 #[doc = "Bit 0 - Enable"]
264 #[inline(always)]
265 pub fn piten(&self) -> PITEN_R {
266 PITEN_R::new((self.bits & 1) != 0)
267 }
268 #[doc = "Bits 3:6 - Period"]
269 #[inline(always)]
270 pub fn period(&self) -> PERIOD_R {
271 PERIOD_R::new((self.bits >> 3) & 0x0f)
272 }
273}
274impl W {
275 #[doc = "Bit 0 - Enable"]
276 #[inline(always)]
277 #[must_use]
278 pub fn piten(&mut self) -> PITEN_W<0> {
279 PITEN_W::new(self)
280 }
281 #[doc = "Bits 3:6 - Period"]
282 #[inline(always)]
283 #[must_use]
284 pub fn period(&mut self) -> PERIOD_W<3> {
285 PERIOD_W::new(self)
286 }
287 #[doc = "Writes raw bits to the register."]
288 #[inline(always)]
289 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
290 self.0.bits(bits);
291 self
292 }
293}
294#[doc = "PIT Control A\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 [pitctrla](index.html) module"]
295pub struct PITCTRLA_SPEC;
296impl crate::RegisterSpec for PITCTRLA_SPEC {
297 type Ux = u8;
298}
299#[doc = "`read()` method returns [pitctrla::R](R) reader structure"]
300impl crate::Readable for PITCTRLA_SPEC {
301 type Reader = R;
302}
303#[doc = "`write(|w| ..)` method takes [pitctrla::W](W) writer structure"]
304impl crate::Writable for PITCTRLA_SPEC {
305 type Writer = W;
306 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
307 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
308}
309#[doc = "`reset()` method sets PITCTRLA to value 0"]
310impl crate::Resettable for PITCTRLA_SPEC {
311 const RESET_VALUE: Self::Ux = 0;
312}