stm32f1/stm32f102/usart1/
cr2.rs1pub type R = crate::R<CR2rs>;
3pub type W = crate::W<CR2rs>;
5pub type ADD_R = crate::FieldReader;
7pub type ADD_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
9#[cfg_attr(feature = "defmt", derive(defmt::Format))]
13#[derive(Clone, Copy, Debug, PartialEq, Eq)]
14pub enum LBDL {
15 Lbdl10 = 0,
17 Lbdl11 = 1,
19}
20impl From<LBDL> for bool {
21 #[inline(always)]
22 fn from(variant: LBDL) -> Self {
23 variant as u8 != 0
24 }
25}
26pub type LBDL_R = crate::BitReader<LBDL>;
28impl LBDL_R {
29 #[inline(always)]
31 pub const fn variant(&self) -> LBDL {
32 match self.bits {
33 false => LBDL::Lbdl10,
34 true => LBDL::Lbdl11,
35 }
36 }
37 #[inline(always)]
39 pub fn is_lbdl10(&self) -> bool {
40 *self == LBDL::Lbdl10
41 }
42 #[inline(always)]
44 pub fn is_lbdl11(&self) -> bool {
45 *self == LBDL::Lbdl11
46 }
47}
48pub type LBDL_W<'a, REG> = crate::BitWriter<'a, REG, LBDL>;
50impl<'a, REG> LBDL_W<'a, REG>
51where
52 REG: crate::Writable + crate::RegisterSpec,
53{
54 #[inline(always)]
56 pub fn lbdl10(self) -> &'a mut crate::W<REG> {
57 self.variant(LBDL::Lbdl10)
58 }
59 #[inline(always)]
61 pub fn lbdl11(self) -> &'a mut crate::W<REG> {
62 self.variant(LBDL::Lbdl11)
63 }
64}
65#[cfg_attr(feature = "defmt", derive(defmt::Format))]
69#[derive(Clone, Copy, Debug, PartialEq, Eq)]
70pub enum LBDIE {
71 Disabled = 0,
73 Enabled = 1,
75}
76impl From<LBDIE> for bool {
77 #[inline(always)]
78 fn from(variant: LBDIE) -> Self {
79 variant as u8 != 0
80 }
81}
82pub type LBDIE_R = crate::BitReader<LBDIE>;
84impl LBDIE_R {
85 #[inline(always)]
87 pub const fn variant(&self) -> LBDIE {
88 match self.bits {
89 false => LBDIE::Disabled,
90 true => LBDIE::Enabled,
91 }
92 }
93 #[inline(always)]
95 pub fn is_disabled(&self) -> bool {
96 *self == LBDIE::Disabled
97 }
98 #[inline(always)]
100 pub fn is_enabled(&self) -> bool {
101 *self == LBDIE::Enabled
102 }
103}
104pub type LBDIE_W<'a, REG> = crate::BitWriter<'a, REG, LBDIE>;
106impl<'a, REG> LBDIE_W<'a, REG>
107where
108 REG: crate::Writable + crate::RegisterSpec,
109{
110 #[inline(always)]
112 pub fn disabled(self) -> &'a mut crate::W<REG> {
113 self.variant(LBDIE::Disabled)
114 }
115 #[inline(always)]
117 pub fn enabled(self) -> &'a mut crate::W<REG> {
118 self.variant(LBDIE::Enabled)
119 }
120}
121#[cfg_attr(feature = "defmt", derive(defmt::Format))]
125#[derive(Clone, Copy, Debug, PartialEq, Eq)]
126pub enum LBCL {
127 Disabled = 0,
129 Enabled = 1,
131}
132impl From<LBCL> for bool {
133 #[inline(always)]
134 fn from(variant: LBCL) -> Self {
135 variant as u8 != 0
136 }
137}
138pub type LBCL_R = crate::BitReader<LBCL>;
140impl LBCL_R {
141 #[inline(always)]
143 pub const fn variant(&self) -> LBCL {
144 match self.bits {
145 false => LBCL::Disabled,
146 true => LBCL::Enabled,
147 }
148 }
149 #[inline(always)]
151 pub fn is_disabled(&self) -> bool {
152 *self == LBCL::Disabled
153 }
154 #[inline(always)]
156 pub fn is_enabled(&self) -> bool {
157 *self == LBCL::Enabled
158 }
159}
160pub type LBCL_W<'a, REG> = crate::BitWriter<'a, REG, LBCL>;
162impl<'a, REG> LBCL_W<'a, REG>
163where
164 REG: crate::Writable + crate::RegisterSpec,
165{
166 #[inline(always)]
168 pub fn disabled(self) -> &'a mut crate::W<REG> {
169 self.variant(LBCL::Disabled)
170 }
171 #[inline(always)]
173 pub fn enabled(self) -> &'a mut crate::W<REG> {
174 self.variant(LBCL::Enabled)
175 }
176}
177#[cfg_attr(feature = "defmt", derive(defmt::Format))]
181#[derive(Clone, Copy, Debug, PartialEq, Eq)]
182pub enum CPHA {
183 First = 0,
185 Second = 1,
187}
188impl From<CPHA> for bool {
189 #[inline(always)]
190 fn from(variant: CPHA) -> Self {
191 variant as u8 != 0
192 }
193}
194pub type CPHA_R = crate::BitReader<CPHA>;
196impl CPHA_R {
197 #[inline(always)]
199 pub const fn variant(&self) -> CPHA {
200 match self.bits {
201 false => CPHA::First,
202 true => CPHA::Second,
203 }
204 }
205 #[inline(always)]
207 pub fn is_first(&self) -> bool {
208 *self == CPHA::First
209 }
210 #[inline(always)]
212 pub fn is_second(&self) -> bool {
213 *self == CPHA::Second
214 }
215}
216pub type CPHA_W<'a, REG> = crate::BitWriter<'a, REG, CPHA>;
218impl<'a, REG> CPHA_W<'a, REG>
219where
220 REG: crate::Writable + crate::RegisterSpec,
221{
222 #[inline(always)]
224 pub fn first(self) -> &'a mut crate::W<REG> {
225 self.variant(CPHA::First)
226 }
227 #[inline(always)]
229 pub fn second(self) -> &'a mut crate::W<REG> {
230 self.variant(CPHA::Second)
231 }
232}
233#[cfg_attr(feature = "defmt", derive(defmt::Format))]
237#[derive(Clone, Copy, Debug, PartialEq, Eq)]
238pub enum CPOL {
239 Low = 0,
241 High = 1,
243}
244impl From<CPOL> for bool {
245 #[inline(always)]
246 fn from(variant: CPOL) -> Self {
247 variant as u8 != 0
248 }
249}
250pub type CPOL_R = crate::BitReader<CPOL>;
252impl CPOL_R {
253 #[inline(always)]
255 pub const fn variant(&self) -> CPOL {
256 match self.bits {
257 false => CPOL::Low,
258 true => CPOL::High,
259 }
260 }
261 #[inline(always)]
263 pub fn is_low(&self) -> bool {
264 *self == CPOL::Low
265 }
266 #[inline(always)]
268 pub fn is_high(&self) -> bool {
269 *self == CPOL::High
270 }
271}
272pub type CPOL_W<'a, REG> = crate::BitWriter<'a, REG, CPOL>;
274impl<'a, REG> CPOL_W<'a, REG>
275where
276 REG: crate::Writable + crate::RegisterSpec,
277{
278 #[inline(always)]
280 pub fn low(self) -> &'a mut crate::W<REG> {
281 self.variant(CPOL::Low)
282 }
283 #[inline(always)]
285 pub fn high(self) -> &'a mut crate::W<REG> {
286 self.variant(CPOL::High)
287 }
288}
289#[cfg_attr(feature = "defmt", derive(defmt::Format))]
293#[derive(Clone, Copy, Debug, PartialEq, Eq)]
294pub enum CLKEN {
295 Disabled = 0,
297 Enabled = 1,
299}
300impl From<CLKEN> for bool {
301 #[inline(always)]
302 fn from(variant: CLKEN) -> Self {
303 variant as u8 != 0
304 }
305}
306pub type CLKEN_R = crate::BitReader<CLKEN>;
308impl CLKEN_R {
309 #[inline(always)]
311 pub const fn variant(&self) -> CLKEN {
312 match self.bits {
313 false => CLKEN::Disabled,
314 true => CLKEN::Enabled,
315 }
316 }
317 #[inline(always)]
319 pub fn is_disabled(&self) -> bool {
320 *self == CLKEN::Disabled
321 }
322 #[inline(always)]
324 pub fn is_enabled(&self) -> bool {
325 *self == CLKEN::Enabled
326 }
327}
328pub type CLKEN_W<'a, REG> = crate::BitWriter<'a, REG, CLKEN>;
330impl<'a, REG> CLKEN_W<'a, REG>
331where
332 REG: crate::Writable + crate::RegisterSpec,
333{
334 #[inline(always)]
336 pub fn disabled(self) -> &'a mut crate::W<REG> {
337 self.variant(CLKEN::Disabled)
338 }
339 #[inline(always)]
341 pub fn enabled(self) -> &'a mut crate::W<REG> {
342 self.variant(CLKEN::Enabled)
343 }
344}
345#[cfg_attr(feature = "defmt", derive(defmt::Format))]
349#[derive(Clone, Copy, Debug, PartialEq, Eq)]
350#[repr(u8)]
351pub enum STOP {
352 Stop1 = 0,
354 Stop0p5 = 1,
356 Stop2 = 2,
358 Stop1p5 = 3,
360}
361impl From<STOP> for u8 {
362 #[inline(always)]
363 fn from(variant: STOP) -> Self {
364 variant as _
365 }
366}
367impl crate::FieldSpec for STOP {
368 type Ux = u8;
369}
370impl crate::IsEnum for STOP {}
371pub type STOP_R = crate::FieldReader<STOP>;
373impl STOP_R {
374 #[inline(always)]
376 pub const fn variant(&self) -> STOP {
377 match self.bits {
378 0 => STOP::Stop1,
379 1 => STOP::Stop0p5,
380 2 => STOP::Stop2,
381 3 => STOP::Stop1p5,
382 _ => unreachable!(),
383 }
384 }
385 #[inline(always)]
387 pub fn is_stop1(&self) -> bool {
388 *self == STOP::Stop1
389 }
390 #[inline(always)]
392 pub fn is_stop0p5(&self) -> bool {
393 *self == STOP::Stop0p5
394 }
395 #[inline(always)]
397 pub fn is_stop2(&self) -> bool {
398 *self == STOP::Stop2
399 }
400 #[inline(always)]
402 pub fn is_stop1p5(&self) -> bool {
403 *self == STOP::Stop1p5
404 }
405}
406pub type STOP_W<'a, REG> = crate::FieldWriter<'a, REG, 2, STOP, crate::Safe>;
408impl<'a, REG> STOP_W<'a, REG>
409where
410 REG: crate::Writable + crate::RegisterSpec,
411 REG::Ux: From<u8>,
412{
413 #[inline(always)]
415 pub fn stop1(self) -> &'a mut crate::W<REG> {
416 self.variant(STOP::Stop1)
417 }
418 #[inline(always)]
420 pub fn stop0p5(self) -> &'a mut crate::W<REG> {
421 self.variant(STOP::Stop0p5)
422 }
423 #[inline(always)]
425 pub fn stop2(self) -> &'a mut crate::W<REG> {
426 self.variant(STOP::Stop2)
427 }
428 #[inline(always)]
430 pub fn stop1p5(self) -> &'a mut crate::W<REG> {
431 self.variant(STOP::Stop1p5)
432 }
433}
434#[cfg_attr(feature = "defmt", derive(defmt::Format))]
438#[derive(Clone, Copy, Debug, PartialEq, Eq)]
439pub enum LINEN {
440 Disabled = 0,
442 Enabled = 1,
444}
445impl From<LINEN> for bool {
446 #[inline(always)]
447 fn from(variant: LINEN) -> Self {
448 variant as u8 != 0
449 }
450}
451pub type LINEN_R = crate::BitReader<LINEN>;
453impl LINEN_R {
454 #[inline(always)]
456 pub const fn variant(&self) -> LINEN {
457 match self.bits {
458 false => LINEN::Disabled,
459 true => LINEN::Enabled,
460 }
461 }
462 #[inline(always)]
464 pub fn is_disabled(&self) -> bool {
465 *self == LINEN::Disabled
466 }
467 #[inline(always)]
469 pub fn is_enabled(&self) -> bool {
470 *self == LINEN::Enabled
471 }
472}
473pub type LINEN_W<'a, REG> = crate::BitWriter<'a, REG, LINEN>;
475impl<'a, REG> LINEN_W<'a, REG>
476where
477 REG: crate::Writable + crate::RegisterSpec,
478{
479 #[inline(always)]
481 pub fn disabled(self) -> &'a mut crate::W<REG> {
482 self.variant(LINEN::Disabled)
483 }
484 #[inline(always)]
486 pub fn enabled(self) -> &'a mut crate::W<REG> {
487 self.variant(LINEN::Enabled)
488 }
489}
490impl R {
491 #[inline(always)]
493 pub fn add(&self) -> ADD_R {
494 ADD_R::new((self.bits & 0x0f) as u8)
495 }
496 #[inline(always)]
498 pub fn lbdl(&self) -> LBDL_R {
499 LBDL_R::new(((self.bits >> 5) & 1) != 0)
500 }
501 #[inline(always)]
503 pub fn lbdie(&self) -> LBDIE_R {
504 LBDIE_R::new(((self.bits >> 6) & 1) != 0)
505 }
506 #[inline(always)]
508 pub fn lbcl(&self) -> LBCL_R {
509 LBCL_R::new(((self.bits >> 8) & 1) != 0)
510 }
511 #[inline(always)]
513 pub fn cpha(&self) -> CPHA_R {
514 CPHA_R::new(((self.bits >> 9) & 1) != 0)
515 }
516 #[inline(always)]
518 pub fn cpol(&self) -> CPOL_R {
519 CPOL_R::new(((self.bits >> 10) & 1) != 0)
520 }
521 #[inline(always)]
523 pub fn clken(&self) -> CLKEN_R {
524 CLKEN_R::new(((self.bits >> 11) & 1) != 0)
525 }
526 #[inline(always)]
528 pub fn stop(&self) -> STOP_R {
529 STOP_R::new(((self.bits >> 12) & 3) as u8)
530 }
531 #[inline(always)]
533 pub fn linen(&self) -> LINEN_R {
534 LINEN_R::new(((self.bits >> 14) & 1) != 0)
535 }
536}
537impl core::fmt::Debug for R {
538 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
539 f.debug_struct("CR2")
540 .field("linen", &self.linen())
541 .field("stop", &self.stop())
542 .field("clken", &self.clken())
543 .field("cpol", &self.cpol())
544 .field("cpha", &self.cpha())
545 .field("lbcl", &self.lbcl())
546 .field("lbdie", &self.lbdie())
547 .field("lbdl", &self.lbdl())
548 .field("add", &self.add())
549 .finish()
550 }
551}
552impl W {
553 #[inline(always)]
555 pub fn add(&mut self) -> ADD_W<CR2rs> {
556 ADD_W::new(self, 0)
557 }
558 #[inline(always)]
560 pub fn lbdl(&mut self) -> LBDL_W<CR2rs> {
561 LBDL_W::new(self, 5)
562 }
563 #[inline(always)]
565 pub fn lbdie(&mut self) -> LBDIE_W<CR2rs> {
566 LBDIE_W::new(self, 6)
567 }
568 #[inline(always)]
570 pub fn lbcl(&mut self) -> LBCL_W<CR2rs> {
571 LBCL_W::new(self, 8)
572 }
573 #[inline(always)]
575 pub fn cpha(&mut self) -> CPHA_W<CR2rs> {
576 CPHA_W::new(self, 9)
577 }
578 #[inline(always)]
580 pub fn cpol(&mut self) -> CPOL_W<CR2rs> {
581 CPOL_W::new(self, 10)
582 }
583 #[inline(always)]
585 pub fn clken(&mut self) -> CLKEN_W<CR2rs> {
586 CLKEN_W::new(self, 11)
587 }
588 #[inline(always)]
590 pub fn stop(&mut self) -> STOP_W<CR2rs> {
591 STOP_W::new(self, 12)
592 }
593 #[inline(always)]
595 pub fn linen(&mut self) -> LINEN_W<CR2rs> {
596 LINEN_W::new(self, 14)
597 }
598}
599pub struct CR2rs;
605impl crate::RegisterSpec for CR2rs {
606 type Ux = u16;
607}
608impl crate::Readable for CR2rs {}
610impl crate::Writable for CR2rs {
612 type Safety = crate::Unsafe;
613}
614impl crate::Resettable for CR2rs {}