efm32gg_pac/efm32gg230/usart2/
frame.rs1#[doc = "Register `FRAME` reader"]
2pub struct R(crate::R<FRAME_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<FRAME_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<FRAME_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<FRAME_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `FRAME` writer"]
17pub struct W(crate::W<FRAME_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<FRAME_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<FRAME_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<FRAME_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `DATABITS` reader - Data-Bit Mode"]
38pub type DATABITS_R = crate::FieldReader<u8, DATABITS_A>;
39#[doc = "Data-Bit Mode\n\nValue on reset: 5"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum DATABITS_A {
43 #[doc = "1: Each frame contains 4 data bits"]
44 FOUR = 1,
45 #[doc = "2: Each frame contains 5 data bits"]
46 FIVE = 2,
47 #[doc = "3: Each frame contains 6 data bits"]
48 SIX = 3,
49 #[doc = "4: Each frame contains 7 data bits"]
50 SEVEN = 4,
51 #[doc = "5: Each frame contains 8 data bits"]
52 EIGHT = 5,
53 #[doc = "6: Each frame contains 9 data bits"]
54 NINE = 6,
55 #[doc = "7: Each frame contains 10 data bits"]
56 TEN = 7,
57 #[doc = "8: Each frame contains 11 data bits"]
58 ELEVEN = 8,
59 #[doc = "9: Each frame contains 12 data bits"]
60 TWELVE = 9,
61 #[doc = "10: Each frame contains 13 data bits"]
62 THIRTEEN = 10,
63 #[doc = "11: Each frame contains 14 data bits"]
64 FOURTEEN = 11,
65 #[doc = "12: Each frame contains 15 data bits"]
66 FIFTEEN = 12,
67 #[doc = "13: Each frame contains 16 data bits"]
68 SIXTEEN = 13,
69}
70impl From<DATABITS_A> for u8 {
71 #[inline(always)]
72 fn from(variant: DATABITS_A) -> Self {
73 variant as _
74 }
75}
76impl DATABITS_R {
77 #[doc = "Get enumerated values variant"]
78 #[inline(always)]
79 pub fn variant(&self) -> Option<DATABITS_A> {
80 match self.bits {
81 1 => Some(DATABITS_A::FOUR),
82 2 => Some(DATABITS_A::FIVE),
83 3 => Some(DATABITS_A::SIX),
84 4 => Some(DATABITS_A::SEVEN),
85 5 => Some(DATABITS_A::EIGHT),
86 6 => Some(DATABITS_A::NINE),
87 7 => Some(DATABITS_A::TEN),
88 8 => Some(DATABITS_A::ELEVEN),
89 9 => Some(DATABITS_A::TWELVE),
90 10 => Some(DATABITS_A::THIRTEEN),
91 11 => Some(DATABITS_A::FOURTEEN),
92 12 => Some(DATABITS_A::FIFTEEN),
93 13 => Some(DATABITS_A::SIXTEEN),
94 _ => None,
95 }
96 }
97 #[doc = "Checks if the value of the field is `FOUR`"]
98 #[inline(always)]
99 pub fn is_four(&self) -> bool {
100 *self == DATABITS_A::FOUR
101 }
102 #[doc = "Checks if the value of the field is `FIVE`"]
103 #[inline(always)]
104 pub fn is_five(&self) -> bool {
105 *self == DATABITS_A::FIVE
106 }
107 #[doc = "Checks if the value of the field is `SIX`"]
108 #[inline(always)]
109 pub fn is_six(&self) -> bool {
110 *self == DATABITS_A::SIX
111 }
112 #[doc = "Checks if the value of the field is `SEVEN`"]
113 #[inline(always)]
114 pub fn is_seven(&self) -> bool {
115 *self == DATABITS_A::SEVEN
116 }
117 #[doc = "Checks if the value of the field is `EIGHT`"]
118 #[inline(always)]
119 pub fn is_eight(&self) -> bool {
120 *self == DATABITS_A::EIGHT
121 }
122 #[doc = "Checks if the value of the field is `NINE`"]
123 #[inline(always)]
124 pub fn is_nine(&self) -> bool {
125 *self == DATABITS_A::NINE
126 }
127 #[doc = "Checks if the value of the field is `TEN`"]
128 #[inline(always)]
129 pub fn is_ten(&self) -> bool {
130 *self == DATABITS_A::TEN
131 }
132 #[doc = "Checks if the value of the field is `ELEVEN`"]
133 #[inline(always)]
134 pub fn is_eleven(&self) -> bool {
135 *self == DATABITS_A::ELEVEN
136 }
137 #[doc = "Checks if the value of the field is `TWELVE`"]
138 #[inline(always)]
139 pub fn is_twelve(&self) -> bool {
140 *self == DATABITS_A::TWELVE
141 }
142 #[doc = "Checks if the value of the field is `THIRTEEN`"]
143 #[inline(always)]
144 pub fn is_thirteen(&self) -> bool {
145 *self == DATABITS_A::THIRTEEN
146 }
147 #[doc = "Checks if the value of the field is `FOURTEEN`"]
148 #[inline(always)]
149 pub fn is_fourteen(&self) -> bool {
150 *self == DATABITS_A::FOURTEEN
151 }
152 #[doc = "Checks if the value of the field is `FIFTEEN`"]
153 #[inline(always)]
154 pub fn is_fifteen(&self) -> bool {
155 *self == DATABITS_A::FIFTEEN
156 }
157 #[doc = "Checks if the value of the field is `SIXTEEN`"]
158 #[inline(always)]
159 pub fn is_sixteen(&self) -> bool {
160 *self == DATABITS_A::SIXTEEN
161 }
162}
163#[doc = "Field `DATABITS` writer - Data-Bit Mode"]
164pub type DATABITS_W<'a, const O: u8> =
165 crate::FieldWriter<'a, u32, FRAME_SPEC, u8, DATABITS_A, 4, O>;
166impl<'a, const O: u8> DATABITS_W<'a, O> {
167 #[doc = "Each frame contains 4 data bits"]
168 #[inline(always)]
169 pub fn four(self) -> &'a mut W {
170 self.variant(DATABITS_A::FOUR)
171 }
172 #[doc = "Each frame contains 5 data bits"]
173 #[inline(always)]
174 pub fn five(self) -> &'a mut W {
175 self.variant(DATABITS_A::FIVE)
176 }
177 #[doc = "Each frame contains 6 data bits"]
178 #[inline(always)]
179 pub fn six(self) -> &'a mut W {
180 self.variant(DATABITS_A::SIX)
181 }
182 #[doc = "Each frame contains 7 data bits"]
183 #[inline(always)]
184 pub fn seven(self) -> &'a mut W {
185 self.variant(DATABITS_A::SEVEN)
186 }
187 #[doc = "Each frame contains 8 data bits"]
188 #[inline(always)]
189 pub fn eight(self) -> &'a mut W {
190 self.variant(DATABITS_A::EIGHT)
191 }
192 #[doc = "Each frame contains 9 data bits"]
193 #[inline(always)]
194 pub fn nine(self) -> &'a mut W {
195 self.variant(DATABITS_A::NINE)
196 }
197 #[doc = "Each frame contains 10 data bits"]
198 #[inline(always)]
199 pub fn ten(self) -> &'a mut W {
200 self.variant(DATABITS_A::TEN)
201 }
202 #[doc = "Each frame contains 11 data bits"]
203 #[inline(always)]
204 pub fn eleven(self) -> &'a mut W {
205 self.variant(DATABITS_A::ELEVEN)
206 }
207 #[doc = "Each frame contains 12 data bits"]
208 #[inline(always)]
209 pub fn twelve(self) -> &'a mut W {
210 self.variant(DATABITS_A::TWELVE)
211 }
212 #[doc = "Each frame contains 13 data bits"]
213 #[inline(always)]
214 pub fn thirteen(self) -> &'a mut W {
215 self.variant(DATABITS_A::THIRTEEN)
216 }
217 #[doc = "Each frame contains 14 data bits"]
218 #[inline(always)]
219 pub fn fourteen(self) -> &'a mut W {
220 self.variant(DATABITS_A::FOURTEEN)
221 }
222 #[doc = "Each frame contains 15 data bits"]
223 #[inline(always)]
224 pub fn fifteen(self) -> &'a mut W {
225 self.variant(DATABITS_A::FIFTEEN)
226 }
227 #[doc = "Each frame contains 16 data bits"]
228 #[inline(always)]
229 pub fn sixteen(self) -> &'a mut W {
230 self.variant(DATABITS_A::SIXTEEN)
231 }
232}
233#[doc = "Field `PARITY` reader - Parity-Bit Mode"]
234pub type PARITY_R = crate::FieldReader<u8, PARITY_A>;
235#[doc = "Parity-Bit Mode\n\nValue on reset: 0"]
236#[derive(Clone, Copy, Debug, PartialEq, Eq)]
237#[repr(u8)]
238pub enum PARITY_A {
239 #[doc = "0: Parity bits are not used"]
240 NONE = 0,
241 #[doc = "2: Even parity are used. Parity bits are automatically generated and checked by hardware."]
242 EVEN = 2,
243 #[doc = "3: Odd parity is used. Parity bits are automatically generated and checked by hardware."]
244 ODD = 3,
245}
246impl From<PARITY_A> for u8 {
247 #[inline(always)]
248 fn from(variant: PARITY_A) -> Self {
249 variant as _
250 }
251}
252impl PARITY_R {
253 #[doc = "Get enumerated values variant"]
254 #[inline(always)]
255 pub fn variant(&self) -> Option<PARITY_A> {
256 match self.bits {
257 0 => Some(PARITY_A::NONE),
258 2 => Some(PARITY_A::EVEN),
259 3 => Some(PARITY_A::ODD),
260 _ => None,
261 }
262 }
263 #[doc = "Checks if the value of the field is `NONE`"]
264 #[inline(always)]
265 pub fn is_none(&self) -> bool {
266 *self == PARITY_A::NONE
267 }
268 #[doc = "Checks if the value of the field is `EVEN`"]
269 #[inline(always)]
270 pub fn is_even(&self) -> bool {
271 *self == PARITY_A::EVEN
272 }
273 #[doc = "Checks if the value of the field is `ODD`"]
274 #[inline(always)]
275 pub fn is_odd(&self) -> bool {
276 *self == PARITY_A::ODD
277 }
278}
279#[doc = "Field `PARITY` writer - Parity-Bit Mode"]
280pub type PARITY_W<'a, const O: u8> = crate::FieldWriter<'a, u32, FRAME_SPEC, u8, PARITY_A, 2, O>;
281impl<'a, const O: u8> PARITY_W<'a, O> {
282 #[doc = "Parity bits are not used"]
283 #[inline(always)]
284 pub fn none(self) -> &'a mut W {
285 self.variant(PARITY_A::NONE)
286 }
287 #[doc = "Even parity are used. Parity bits are automatically generated and checked by hardware."]
288 #[inline(always)]
289 pub fn even(self) -> &'a mut W {
290 self.variant(PARITY_A::EVEN)
291 }
292 #[doc = "Odd parity is used. Parity bits are automatically generated and checked by hardware."]
293 #[inline(always)]
294 pub fn odd(self) -> &'a mut W {
295 self.variant(PARITY_A::ODD)
296 }
297}
298#[doc = "Field `STOPBITS` reader - Stop-Bit Mode"]
299pub type STOPBITS_R = crate::FieldReader<u8, STOPBITS_A>;
300#[doc = "Stop-Bit Mode\n\nValue on reset: 1"]
301#[derive(Clone, Copy, Debug, PartialEq, Eq)]
302#[repr(u8)]
303pub enum STOPBITS_A {
304 #[doc = "0: The transmitter generates a half stop bit. Stop-bits are not verified by receiver"]
305 HALF = 0,
306 #[doc = "1: One stop bit is generated and verified"]
307 ONE = 1,
308 #[doc = "2: The transmitter generates one and a half stop bit. The receiver verifies the first stop bit"]
309 ONEANDAHALF = 2,
310 #[doc = "3: The transmitter generates two stop bits. The receiver checks the first stop-bit only"]
311 TWO = 3,
312}
313impl From<STOPBITS_A> for u8 {
314 #[inline(always)]
315 fn from(variant: STOPBITS_A) -> Self {
316 variant as _
317 }
318}
319impl STOPBITS_R {
320 #[doc = "Get enumerated values variant"]
321 #[inline(always)]
322 pub fn variant(&self) -> STOPBITS_A {
323 match self.bits {
324 0 => STOPBITS_A::HALF,
325 1 => STOPBITS_A::ONE,
326 2 => STOPBITS_A::ONEANDAHALF,
327 3 => STOPBITS_A::TWO,
328 _ => unreachable!(),
329 }
330 }
331 #[doc = "Checks if the value of the field is `HALF`"]
332 #[inline(always)]
333 pub fn is_half(&self) -> bool {
334 *self == STOPBITS_A::HALF
335 }
336 #[doc = "Checks if the value of the field is `ONE`"]
337 #[inline(always)]
338 pub fn is_one(&self) -> bool {
339 *self == STOPBITS_A::ONE
340 }
341 #[doc = "Checks if the value of the field is `ONEANDAHALF`"]
342 #[inline(always)]
343 pub fn is_oneandahalf(&self) -> bool {
344 *self == STOPBITS_A::ONEANDAHALF
345 }
346 #[doc = "Checks if the value of the field is `TWO`"]
347 #[inline(always)]
348 pub fn is_two(&self) -> bool {
349 *self == STOPBITS_A::TWO
350 }
351}
352#[doc = "Field `STOPBITS` writer - Stop-Bit Mode"]
353pub type STOPBITS_W<'a, const O: u8> =
354 crate::FieldWriterSafe<'a, u32, FRAME_SPEC, u8, STOPBITS_A, 2, O>;
355impl<'a, const O: u8> STOPBITS_W<'a, O> {
356 #[doc = "The transmitter generates a half stop bit. Stop-bits are not verified by receiver"]
357 #[inline(always)]
358 pub fn half(self) -> &'a mut W {
359 self.variant(STOPBITS_A::HALF)
360 }
361 #[doc = "One stop bit is generated and verified"]
362 #[inline(always)]
363 pub fn one(self) -> &'a mut W {
364 self.variant(STOPBITS_A::ONE)
365 }
366 #[doc = "The transmitter generates one and a half stop bit. The receiver verifies the first stop bit"]
367 #[inline(always)]
368 pub fn oneandahalf(self) -> &'a mut W {
369 self.variant(STOPBITS_A::ONEANDAHALF)
370 }
371 #[doc = "The transmitter generates two stop bits. The receiver checks the first stop-bit only"]
372 #[inline(always)]
373 pub fn two(self) -> &'a mut W {
374 self.variant(STOPBITS_A::TWO)
375 }
376}
377impl R {
378 #[doc = "Bits 0:3 - Data-Bit Mode"]
379 #[inline(always)]
380 pub fn databits(&self) -> DATABITS_R {
381 DATABITS_R::new((self.bits & 0x0f) as u8)
382 }
383 #[doc = "Bits 8:9 - Parity-Bit Mode"]
384 #[inline(always)]
385 pub fn parity(&self) -> PARITY_R {
386 PARITY_R::new(((self.bits >> 8) & 3) as u8)
387 }
388 #[doc = "Bits 12:13 - Stop-Bit Mode"]
389 #[inline(always)]
390 pub fn stopbits(&self) -> STOPBITS_R {
391 STOPBITS_R::new(((self.bits >> 12) & 3) as u8)
392 }
393}
394impl W {
395 #[doc = "Bits 0:3 - Data-Bit Mode"]
396 #[inline(always)]
397 #[must_use]
398 pub fn databits(&mut self) -> DATABITS_W<0> {
399 DATABITS_W::new(self)
400 }
401 #[doc = "Bits 8:9 - Parity-Bit Mode"]
402 #[inline(always)]
403 #[must_use]
404 pub fn parity(&mut self) -> PARITY_W<8> {
405 PARITY_W::new(self)
406 }
407 #[doc = "Bits 12:13 - Stop-Bit Mode"]
408 #[inline(always)]
409 #[must_use]
410 pub fn stopbits(&mut self) -> STOPBITS_W<12> {
411 STOPBITS_W::new(self)
412 }
413 #[doc = "Writes raw bits to the register."]
414 #[inline(always)]
415 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
416 self.0.bits(bits);
417 self
418 }
419}
420#[doc = "USART Frame Format 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 [frame](index.html) module"]
421pub struct FRAME_SPEC;
422impl crate::RegisterSpec for FRAME_SPEC {
423 type Ux = u32;
424}
425#[doc = "`read()` method returns [frame::R](R) reader structure"]
426impl crate::Readable for FRAME_SPEC {
427 type Reader = R;
428}
429#[doc = "`write(|w| ..)` method takes [frame::W](W) writer structure"]
430impl crate::Writable for FRAME_SPEC {
431 type Writer = W;
432 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
433 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
434}
435#[doc = "`reset()` method sets FRAME to value 0x1005"]
436impl crate::Resettable for FRAME_SPEC {
437 const RESET_VALUE: Self::Ux = 0x1005;
438}