efm32g842_pac/lcd/
bactrl.rs1#[doc = "Register `BACTRL` reader"]
2pub struct R(crate::R<BACTRL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<BACTRL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<BACTRL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<BACTRL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `BACTRL` writer"]
17pub struct W(crate::W<BACTRL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<BACTRL_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<BACTRL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<BACTRL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `BLINKEN` reader - Blink Enable"]
38pub type BLINKEN_R = crate::BitReader<bool>;
39#[doc = "Field `BLINKEN` writer - Blink Enable"]
40pub type BLINKEN_W<'a> = crate::BitWriter<'a, u32, BACTRL_SPEC, bool, 0>;
41#[doc = "Field `BLANK` reader - Blank Display"]
42pub type BLANK_R = crate::BitReader<bool>;
43#[doc = "Field `BLANK` writer - Blank Display"]
44pub type BLANK_W<'a> = crate::BitWriter<'a, u32, BACTRL_SPEC, bool, 1>;
45#[doc = "Field `AEN` reader - Animation Enable"]
46pub type AEN_R = crate::BitReader<bool>;
47#[doc = "Field `AEN` writer - Animation Enable"]
48pub type AEN_W<'a> = crate::BitWriter<'a, u32, BACTRL_SPEC, bool, 2>;
49#[doc = "Animate Register A Shift Control\n\nValue on reset: 0"]
50#[derive(Clone, Copy, Debug, PartialEq)]
51#[repr(u8)]
52pub enum AREGASC_A {
53 #[doc = "0: No Shift operation on Animation Register A"]
54 NOSHIFT = 0,
55 #[doc = "1: Animation Register A is shifted left"]
56 SHIFTLEFT = 1,
57 #[doc = "2: Animation Register A is shifted right"]
58 SHIFTRIGHT = 2,
59}
60impl From<AREGASC_A> for u8 {
61 #[inline(always)]
62 fn from(variant: AREGASC_A) -> Self {
63 variant as _
64 }
65}
66#[doc = "Field `AREGASC` reader - Animate Register A Shift Control"]
67pub type AREGASC_R = crate::FieldReader<u8, AREGASC_A>;
68impl AREGASC_R {
69 #[doc = "Get enumerated values variant"]
70 #[inline(always)]
71 pub fn variant(&self) -> Option<AREGASC_A> {
72 match self.bits {
73 0 => Some(AREGASC_A::NOSHIFT),
74 1 => Some(AREGASC_A::SHIFTLEFT),
75 2 => Some(AREGASC_A::SHIFTRIGHT),
76 _ => None,
77 }
78 }
79 #[doc = "Checks if the value of the field is `NOSHIFT`"]
80 #[inline(always)]
81 pub fn is_noshift(&self) -> bool {
82 *self == AREGASC_A::NOSHIFT
83 }
84 #[doc = "Checks if the value of the field is `SHIFTLEFT`"]
85 #[inline(always)]
86 pub fn is_shiftleft(&self) -> bool {
87 *self == AREGASC_A::SHIFTLEFT
88 }
89 #[doc = "Checks if the value of the field is `SHIFTRIGHT`"]
90 #[inline(always)]
91 pub fn is_shiftright(&self) -> bool {
92 *self == AREGASC_A::SHIFTRIGHT
93 }
94}
95#[doc = "Field `AREGASC` writer - Animate Register A Shift Control"]
96pub type AREGASC_W<'a> = crate::FieldWriter<'a, u32, BACTRL_SPEC, u8, AREGASC_A, 2, 3>;
97impl<'a> AREGASC_W<'a> {
98 #[doc = "No Shift operation on Animation Register A"]
99 #[inline(always)]
100 pub fn noshift(self) -> &'a mut W {
101 self.variant(AREGASC_A::NOSHIFT)
102 }
103 #[doc = "Animation Register A is shifted left"]
104 #[inline(always)]
105 pub fn shiftleft(self) -> &'a mut W {
106 self.variant(AREGASC_A::SHIFTLEFT)
107 }
108 #[doc = "Animation Register A is shifted right"]
109 #[inline(always)]
110 pub fn shiftright(self) -> &'a mut W {
111 self.variant(AREGASC_A::SHIFTRIGHT)
112 }
113}
114#[doc = "Animate Register B Shift Control\n\nValue on reset: 0"]
115#[derive(Clone, Copy, Debug, PartialEq)]
116#[repr(u8)]
117pub enum AREGBSC_A {
118 #[doc = "0: No Shift operation on Animation Register B"]
119 NOSHIFT = 0,
120 #[doc = "1: Animation Register B is shifted left"]
121 SHIFTLEFT = 1,
122 #[doc = "2: Animation Register B is shifted right"]
123 SHIFTRIGHT = 2,
124}
125impl From<AREGBSC_A> for u8 {
126 #[inline(always)]
127 fn from(variant: AREGBSC_A) -> Self {
128 variant as _
129 }
130}
131#[doc = "Field `AREGBSC` reader - Animate Register B Shift Control"]
132pub type AREGBSC_R = crate::FieldReader<u8, AREGBSC_A>;
133impl AREGBSC_R {
134 #[doc = "Get enumerated values variant"]
135 #[inline(always)]
136 pub fn variant(&self) -> Option<AREGBSC_A> {
137 match self.bits {
138 0 => Some(AREGBSC_A::NOSHIFT),
139 1 => Some(AREGBSC_A::SHIFTLEFT),
140 2 => Some(AREGBSC_A::SHIFTRIGHT),
141 _ => None,
142 }
143 }
144 #[doc = "Checks if the value of the field is `NOSHIFT`"]
145 #[inline(always)]
146 pub fn is_noshift(&self) -> bool {
147 *self == AREGBSC_A::NOSHIFT
148 }
149 #[doc = "Checks if the value of the field is `SHIFTLEFT`"]
150 #[inline(always)]
151 pub fn is_shiftleft(&self) -> bool {
152 *self == AREGBSC_A::SHIFTLEFT
153 }
154 #[doc = "Checks if the value of the field is `SHIFTRIGHT`"]
155 #[inline(always)]
156 pub fn is_shiftright(&self) -> bool {
157 *self == AREGBSC_A::SHIFTRIGHT
158 }
159}
160#[doc = "Field `AREGBSC` writer - Animate Register B Shift Control"]
161pub type AREGBSC_W<'a> = crate::FieldWriter<'a, u32, BACTRL_SPEC, u8, AREGBSC_A, 2, 5>;
162impl<'a> AREGBSC_W<'a> {
163 #[doc = "No Shift operation on Animation Register B"]
164 #[inline(always)]
165 pub fn noshift(self) -> &'a mut W {
166 self.variant(AREGBSC_A::NOSHIFT)
167 }
168 #[doc = "Animation Register B is shifted left"]
169 #[inline(always)]
170 pub fn shiftleft(self) -> &'a mut W {
171 self.variant(AREGBSC_A::SHIFTLEFT)
172 }
173 #[doc = "Animation Register B is shifted right"]
174 #[inline(always)]
175 pub fn shiftright(self) -> &'a mut W {
176 self.variant(AREGBSC_A::SHIFTRIGHT)
177 }
178}
179#[doc = "Field `ALOGSEL` reader - Animate Logic Function Select"]
180pub type ALOGSEL_R = crate::BitReader<bool>;
181#[doc = "Field `ALOGSEL` writer - Animate Logic Function Select"]
182pub type ALOGSEL_W<'a> = crate::BitWriter<'a, u32, BACTRL_SPEC, bool, 7>;
183#[doc = "Field `FCEN` reader - Frame Counter Enable"]
184pub type FCEN_R = crate::BitReader<bool>;
185#[doc = "Field `FCEN` writer - Frame Counter Enable"]
186pub type FCEN_W<'a> = crate::BitWriter<'a, u32, BACTRL_SPEC, bool, 8>;
187#[doc = "Frame Counter Prescaler\n\nValue on reset: 0"]
188#[derive(Clone, Copy, Debug, PartialEq)]
189#[repr(u8)]
190pub enum FCPRESC_A {
191 #[doc = "0: CLKFC = CLKFRAME / 1"]
192 DIV1 = 0,
193 #[doc = "1: CLKFC = CLKFRAME / 2"]
194 DIV2 = 1,
195 #[doc = "2: CLKFC = CLKFRAME / 4"]
196 DIV4 = 2,
197 #[doc = "3: CLKFC = CLKFRAME / 8"]
198 DIV8 = 3,
199}
200impl From<FCPRESC_A> for u8 {
201 #[inline(always)]
202 fn from(variant: FCPRESC_A) -> Self {
203 variant as _
204 }
205}
206#[doc = "Field `FCPRESC` reader - Frame Counter Prescaler"]
207pub type FCPRESC_R = crate::FieldReader<u8, FCPRESC_A>;
208impl FCPRESC_R {
209 #[doc = "Get enumerated values variant"]
210 #[inline(always)]
211 pub fn variant(&self) -> FCPRESC_A {
212 match self.bits {
213 0 => FCPRESC_A::DIV1,
214 1 => FCPRESC_A::DIV2,
215 2 => FCPRESC_A::DIV4,
216 3 => FCPRESC_A::DIV8,
217 _ => unreachable!(),
218 }
219 }
220 #[doc = "Checks if the value of the field is `DIV1`"]
221 #[inline(always)]
222 pub fn is_div1(&self) -> bool {
223 *self == FCPRESC_A::DIV1
224 }
225 #[doc = "Checks if the value of the field is `DIV2`"]
226 #[inline(always)]
227 pub fn is_div2(&self) -> bool {
228 *self == FCPRESC_A::DIV2
229 }
230 #[doc = "Checks if the value of the field is `DIV4`"]
231 #[inline(always)]
232 pub fn is_div4(&self) -> bool {
233 *self == FCPRESC_A::DIV4
234 }
235 #[doc = "Checks if the value of the field is `DIV8`"]
236 #[inline(always)]
237 pub fn is_div8(&self) -> bool {
238 *self == FCPRESC_A::DIV8
239 }
240}
241#[doc = "Field `FCPRESC` writer - Frame Counter Prescaler"]
242pub type FCPRESC_W<'a> = crate::FieldWriterSafe<'a, u32, BACTRL_SPEC, u8, FCPRESC_A, 2, 16>;
243impl<'a> FCPRESC_W<'a> {
244 #[doc = "CLKFC = CLKFRAME / 1"]
245 #[inline(always)]
246 pub fn div1(self) -> &'a mut W {
247 self.variant(FCPRESC_A::DIV1)
248 }
249 #[doc = "CLKFC = CLKFRAME / 2"]
250 #[inline(always)]
251 pub fn div2(self) -> &'a mut W {
252 self.variant(FCPRESC_A::DIV2)
253 }
254 #[doc = "CLKFC = CLKFRAME / 4"]
255 #[inline(always)]
256 pub fn div4(self) -> &'a mut W {
257 self.variant(FCPRESC_A::DIV4)
258 }
259 #[doc = "CLKFC = CLKFRAME / 8"]
260 #[inline(always)]
261 pub fn div8(self) -> &'a mut W {
262 self.variant(FCPRESC_A::DIV8)
263 }
264}
265#[doc = "Field `FCTOP` reader - Frame Counter Top Value"]
266pub type FCTOP_R = crate::FieldReader<u8, u8>;
267#[doc = "Field `FCTOP` writer - Frame Counter Top Value"]
268pub type FCTOP_W<'a> = crate::FieldWriter<'a, u32, BACTRL_SPEC, u8, u8, 6, 18>;
269impl R {
270 #[doc = "Bit 0 - Blink Enable"]
271 #[inline(always)]
272 pub fn blinken(&self) -> BLINKEN_R {
273 BLINKEN_R::new((self.bits & 1) != 0)
274 }
275 #[doc = "Bit 1 - Blank Display"]
276 #[inline(always)]
277 pub fn blank(&self) -> BLANK_R {
278 BLANK_R::new(((self.bits >> 1) & 1) != 0)
279 }
280 #[doc = "Bit 2 - Animation Enable"]
281 #[inline(always)]
282 pub fn aen(&self) -> AEN_R {
283 AEN_R::new(((self.bits >> 2) & 1) != 0)
284 }
285 #[doc = "Bits 3:4 - Animate Register A Shift Control"]
286 #[inline(always)]
287 pub fn aregasc(&self) -> AREGASC_R {
288 AREGASC_R::new(((self.bits >> 3) & 3) as u8)
289 }
290 #[doc = "Bits 5:6 - Animate Register B Shift Control"]
291 #[inline(always)]
292 pub fn aregbsc(&self) -> AREGBSC_R {
293 AREGBSC_R::new(((self.bits >> 5) & 3) as u8)
294 }
295 #[doc = "Bit 7 - Animate Logic Function Select"]
296 #[inline(always)]
297 pub fn alogsel(&self) -> ALOGSEL_R {
298 ALOGSEL_R::new(((self.bits >> 7) & 1) != 0)
299 }
300 #[doc = "Bit 8 - Frame Counter Enable"]
301 #[inline(always)]
302 pub fn fcen(&self) -> FCEN_R {
303 FCEN_R::new(((self.bits >> 8) & 1) != 0)
304 }
305 #[doc = "Bits 16:17 - Frame Counter Prescaler"]
306 #[inline(always)]
307 pub fn fcpresc(&self) -> FCPRESC_R {
308 FCPRESC_R::new(((self.bits >> 16) & 3) as u8)
309 }
310 #[doc = "Bits 18:23 - Frame Counter Top Value"]
311 #[inline(always)]
312 pub fn fctop(&self) -> FCTOP_R {
313 FCTOP_R::new(((self.bits >> 18) & 0x3f) as u8)
314 }
315}
316impl W {
317 #[doc = "Bit 0 - Blink Enable"]
318 #[inline(always)]
319 pub fn blinken(&mut self) -> BLINKEN_W {
320 BLINKEN_W::new(self)
321 }
322 #[doc = "Bit 1 - Blank Display"]
323 #[inline(always)]
324 pub fn blank(&mut self) -> BLANK_W {
325 BLANK_W::new(self)
326 }
327 #[doc = "Bit 2 - Animation Enable"]
328 #[inline(always)]
329 pub fn aen(&mut self) -> AEN_W {
330 AEN_W::new(self)
331 }
332 #[doc = "Bits 3:4 - Animate Register A Shift Control"]
333 #[inline(always)]
334 pub fn aregasc(&mut self) -> AREGASC_W {
335 AREGASC_W::new(self)
336 }
337 #[doc = "Bits 5:6 - Animate Register B Shift Control"]
338 #[inline(always)]
339 pub fn aregbsc(&mut self) -> AREGBSC_W {
340 AREGBSC_W::new(self)
341 }
342 #[doc = "Bit 7 - Animate Logic Function Select"]
343 #[inline(always)]
344 pub fn alogsel(&mut self) -> ALOGSEL_W {
345 ALOGSEL_W::new(self)
346 }
347 #[doc = "Bit 8 - Frame Counter Enable"]
348 #[inline(always)]
349 pub fn fcen(&mut self) -> FCEN_W {
350 FCEN_W::new(self)
351 }
352 #[doc = "Bits 16:17 - Frame Counter Prescaler"]
353 #[inline(always)]
354 pub fn fcpresc(&mut self) -> FCPRESC_W {
355 FCPRESC_W::new(self)
356 }
357 #[doc = "Bits 18:23 - Frame Counter Top Value"]
358 #[inline(always)]
359 pub fn fctop(&mut self) -> FCTOP_W {
360 FCTOP_W::new(self)
361 }
362 #[doc = "Writes raw bits to the register."]
363 #[inline(always)]
364 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
365 self.0.bits(bits);
366 self
367 }
368}
369#[doc = "Blink and Animation Control 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 [bactrl](index.html) module"]
370pub struct BACTRL_SPEC;
371impl crate::RegisterSpec for BACTRL_SPEC {
372 type Ux = u32;
373}
374#[doc = "`read()` method returns [bactrl::R](R) reader structure"]
375impl crate::Readable for BACTRL_SPEC {
376 type Reader = R;
377}
378#[doc = "`write(|w| ..)` method takes [bactrl::W](W) writer structure"]
379impl crate::Writable for BACTRL_SPEC {
380 type Writer = W;
381}
382#[doc = "`reset()` method sets BACTRL to value 0"]
383impl crate::Resettable for BACTRL_SPEC {
384 #[inline(always)]
385 fn reset_value() -> Self::Ux {
386 0
387 }
388}