avr_device/devices/attiny85/cpu/
clkpr.rs1#[doc = "Register `CLKPR` reader"]
2pub struct R(crate::R<CLKPR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CLKPR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CLKPR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CLKPR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CLKPR` writer"]
17pub struct W(crate::W<CLKPR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CLKPR_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<CLKPR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CLKPR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `CLKPS` reader - Clock Prescaler Select Bits"]
38pub type CLKPS_R = crate::FieldReader<u8, CLKPS_A>;
39#[doc = "Clock Prescaler Select Bits\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum CLKPS_A {
43 #[doc = "0: Prescaler Value 1"]
44 PRESCALER_1 = 0,
45 #[doc = "1: Prescaler Value 2"]
46 PRESCALER_2 = 1,
47 #[doc = "2: Prescaler Value 4"]
48 PRESCALER_4 = 2,
49 #[doc = "3: Prescaler Value 8"]
50 PRESCALER_8 = 3,
51 #[doc = "4: Prescaler Value 16"]
52 PRESCALER_16 = 4,
53 #[doc = "5: Prescaler Value 32"]
54 PRESCALER_32 = 5,
55 #[doc = "6: Prescaler Value 64"]
56 PRESCALER_64 = 6,
57 #[doc = "7: Prescaler Value 128"]
58 PRESCALER_128 = 7,
59 #[doc = "8: Prescaler Value 256"]
60 PRESCALER_256 = 8,
61}
62impl From<CLKPS_A> for u8 {
63 #[inline(always)]
64 fn from(variant: CLKPS_A) -> Self {
65 variant as _
66 }
67}
68impl CLKPS_R {
69 #[doc = "Get enumerated values variant"]
70 #[inline(always)]
71 pub fn variant(&self) -> Option<CLKPS_A> {
72 match self.bits {
73 0 => Some(CLKPS_A::PRESCALER_1),
74 1 => Some(CLKPS_A::PRESCALER_2),
75 2 => Some(CLKPS_A::PRESCALER_4),
76 3 => Some(CLKPS_A::PRESCALER_8),
77 4 => Some(CLKPS_A::PRESCALER_16),
78 5 => Some(CLKPS_A::PRESCALER_32),
79 6 => Some(CLKPS_A::PRESCALER_64),
80 7 => Some(CLKPS_A::PRESCALER_128),
81 8 => Some(CLKPS_A::PRESCALER_256),
82 _ => None,
83 }
84 }
85 #[doc = "Checks if the value of the field is `PRESCALER_1`"]
86 #[inline(always)]
87 pub fn is_prescaler_1(&self) -> bool {
88 *self == CLKPS_A::PRESCALER_1
89 }
90 #[doc = "Checks if the value of the field is `PRESCALER_2`"]
91 #[inline(always)]
92 pub fn is_prescaler_2(&self) -> bool {
93 *self == CLKPS_A::PRESCALER_2
94 }
95 #[doc = "Checks if the value of the field is `PRESCALER_4`"]
96 #[inline(always)]
97 pub fn is_prescaler_4(&self) -> bool {
98 *self == CLKPS_A::PRESCALER_4
99 }
100 #[doc = "Checks if the value of the field is `PRESCALER_8`"]
101 #[inline(always)]
102 pub fn is_prescaler_8(&self) -> bool {
103 *self == CLKPS_A::PRESCALER_8
104 }
105 #[doc = "Checks if the value of the field is `PRESCALER_16`"]
106 #[inline(always)]
107 pub fn is_prescaler_16(&self) -> bool {
108 *self == CLKPS_A::PRESCALER_16
109 }
110 #[doc = "Checks if the value of the field is `PRESCALER_32`"]
111 #[inline(always)]
112 pub fn is_prescaler_32(&self) -> bool {
113 *self == CLKPS_A::PRESCALER_32
114 }
115 #[doc = "Checks if the value of the field is `PRESCALER_64`"]
116 #[inline(always)]
117 pub fn is_prescaler_64(&self) -> bool {
118 *self == CLKPS_A::PRESCALER_64
119 }
120 #[doc = "Checks if the value of the field is `PRESCALER_128`"]
121 #[inline(always)]
122 pub fn is_prescaler_128(&self) -> bool {
123 *self == CLKPS_A::PRESCALER_128
124 }
125 #[doc = "Checks if the value of the field is `PRESCALER_256`"]
126 #[inline(always)]
127 pub fn is_prescaler_256(&self) -> bool {
128 *self == CLKPS_A::PRESCALER_256
129 }
130}
131#[doc = "Field `CLKPS` writer - Clock Prescaler Select Bits"]
132pub type CLKPS_W<'a, const O: u8> = crate::FieldWriter<'a, u8, CLKPR_SPEC, u8, CLKPS_A, 4, O>;
133impl<'a, const O: u8> CLKPS_W<'a, O> {
134 #[doc = "Prescaler Value 1"]
135 #[inline(always)]
136 pub fn prescaler_1(self) -> &'a mut W {
137 self.variant(CLKPS_A::PRESCALER_1)
138 }
139 #[doc = "Prescaler Value 2"]
140 #[inline(always)]
141 pub fn prescaler_2(self) -> &'a mut W {
142 self.variant(CLKPS_A::PRESCALER_2)
143 }
144 #[doc = "Prescaler Value 4"]
145 #[inline(always)]
146 pub fn prescaler_4(self) -> &'a mut W {
147 self.variant(CLKPS_A::PRESCALER_4)
148 }
149 #[doc = "Prescaler Value 8"]
150 #[inline(always)]
151 pub fn prescaler_8(self) -> &'a mut W {
152 self.variant(CLKPS_A::PRESCALER_8)
153 }
154 #[doc = "Prescaler Value 16"]
155 #[inline(always)]
156 pub fn prescaler_16(self) -> &'a mut W {
157 self.variant(CLKPS_A::PRESCALER_16)
158 }
159 #[doc = "Prescaler Value 32"]
160 #[inline(always)]
161 pub fn prescaler_32(self) -> &'a mut W {
162 self.variant(CLKPS_A::PRESCALER_32)
163 }
164 #[doc = "Prescaler Value 64"]
165 #[inline(always)]
166 pub fn prescaler_64(self) -> &'a mut W {
167 self.variant(CLKPS_A::PRESCALER_64)
168 }
169 #[doc = "Prescaler Value 128"]
170 #[inline(always)]
171 pub fn prescaler_128(self) -> &'a mut W {
172 self.variant(CLKPS_A::PRESCALER_128)
173 }
174 #[doc = "Prescaler Value 256"]
175 #[inline(always)]
176 pub fn prescaler_256(self) -> &'a mut W {
177 self.variant(CLKPS_A::PRESCALER_256)
178 }
179}
180#[doc = "Field `CLKPCE` reader - Clock Prescaler Change Enable"]
181pub type CLKPCE_R = crate::BitReader<bool>;
182#[doc = "Field `CLKPCE` writer - Clock Prescaler Change Enable"]
183pub type CLKPCE_W<'a, const O: u8> = crate::BitWriter<'a, u8, CLKPR_SPEC, bool, O>;
184impl R {
185 #[doc = "Bits 0:3 - Clock Prescaler Select Bits"]
186 #[inline(always)]
187 pub fn clkps(&self) -> CLKPS_R {
188 CLKPS_R::new(self.bits & 0x0f)
189 }
190 #[doc = "Bit 7 - Clock Prescaler Change Enable"]
191 #[inline(always)]
192 pub fn clkpce(&self) -> CLKPCE_R {
193 CLKPCE_R::new(((self.bits >> 7) & 1) != 0)
194 }
195}
196impl W {
197 #[doc = "Bits 0:3 - Clock Prescaler Select Bits"]
198 #[inline(always)]
199 #[must_use]
200 pub fn clkps(&mut self) -> CLKPS_W<0> {
201 CLKPS_W::new(self)
202 }
203 #[doc = "Bit 7 - Clock Prescaler Change Enable"]
204 #[inline(always)]
205 #[must_use]
206 pub fn clkpce(&mut self) -> CLKPCE_W<7> {
207 CLKPCE_W::new(self)
208 }
209 #[doc = "Writes raw bits to the register."]
210 #[inline(always)]
211 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
212 self.0.bits(bits);
213 self
214 }
215}
216#[doc = "Clock Prescale Register\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 [clkpr](index.html) module"]
217pub struct CLKPR_SPEC;
218impl crate::RegisterSpec for CLKPR_SPEC {
219 type Ux = u8;
220}
221#[doc = "`read()` method returns [clkpr::R](R) reader structure"]
222impl crate::Readable for CLKPR_SPEC {
223 type Reader = R;
224}
225#[doc = "`write(|w| ..)` method takes [clkpr::W](W) writer structure"]
226impl crate::Writable for CLKPR_SPEC {
227 type Writer = W;
228 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
229 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
230}
231#[doc = "`reset()` method sets CLKPR to value 0"]
232impl crate::Resettable for CLKPR_SPEC {
233 const RESET_VALUE: Self::Ux = 0;
234}