stm32f1_staging/stm32f107/spi1/
i2scfgr.rs1pub type R = crate::R<I2SCFGRrs>;
3pub type W = crate::W<I2SCFGRrs>;
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum CHLEN {
11 SixteenBit = 0,
13 ThirtyTwoBit = 1,
15}
16impl From<CHLEN> for bool {
17 #[inline(always)]
18 fn from(variant: CHLEN) -> Self {
19 variant as u8 != 0
20 }
21}
22pub type CHLEN_R = crate::BitReader<CHLEN>;
24impl CHLEN_R {
25 #[inline(always)]
27 pub const fn variant(&self) -> CHLEN {
28 match self.bits {
29 false => CHLEN::SixteenBit,
30 true => CHLEN::ThirtyTwoBit,
31 }
32 }
33 #[inline(always)]
35 pub fn is_sixteen_bit(&self) -> bool {
36 *self == CHLEN::SixteenBit
37 }
38 #[inline(always)]
40 pub fn is_thirty_two_bit(&self) -> bool {
41 *self == CHLEN::ThirtyTwoBit
42 }
43}
44pub type CHLEN_W<'a, REG> = crate::BitWriter<'a, REG, CHLEN>;
46impl<'a, REG> CHLEN_W<'a, REG>
47where
48 REG: crate::Writable + crate::RegisterSpec,
49{
50 #[inline(always)]
52 pub fn sixteen_bit(self) -> &'a mut crate::W<REG> {
53 self.variant(CHLEN::SixteenBit)
54 }
55 #[inline(always)]
57 pub fn thirty_two_bit(self) -> &'a mut crate::W<REG> {
58 self.variant(CHLEN::ThirtyTwoBit)
59 }
60}
61#[cfg_attr(feature = "defmt", derive(defmt::Format))]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66#[repr(u8)]
67pub enum DATLEN {
68 SixteenBit = 0,
70 TwentyFourBit = 1,
72 ThirtyTwoBit = 2,
74}
75impl From<DATLEN> for u8 {
76 #[inline(always)]
77 fn from(variant: DATLEN) -> Self {
78 variant as _
79 }
80}
81impl crate::FieldSpec for DATLEN {
82 type Ux = u8;
83}
84impl crate::IsEnum for DATLEN {}
85pub type DATLEN_R = crate::FieldReader<DATLEN>;
87impl DATLEN_R {
88 #[inline(always)]
90 pub const fn variant(&self) -> Option<DATLEN> {
91 match self.bits {
92 0 => Some(DATLEN::SixteenBit),
93 1 => Some(DATLEN::TwentyFourBit),
94 2 => Some(DATLEN::ThirtyTwoBit),
95 _ => None,
96 }
97 }
98 #[inline(always)]
100 pub fn is_sixteen_bit(&self) -> bool {
101 *self == DATLEN::SixteenBit
102 }
103 #[inline(always)]
105 pub fn is_twenty_four_bit(&self) -> bool {
106 *self == DATLEN::TwentyFourBit
107 }
108 #[inline(always)]
110 pub fn is_thirty_two_bit(&self) -> bool {
111 *self == DATLEN::ThirtyTwoBit
112 }
113}
114pub type DATLEN_W<'a, REG> = crate::FieldWriter<'a, REG, 2, DATLEN>;
116impl<'a, REG> DATLEN_W<'a, REG>
117where
118 REG: crate::Writable + crate::RegisterSpec,
119 REG::Ux: From<u8>,
120{
121 #[inline(always)]
123 pub fn sixteen_bit(self) -> &'a mut crate::W<REG> {
124 self.variant(DATLEN::SixteenBit)
125 }
126 #[inline(always)]
128 pub fn twenty_four_bit(self) -> &'a mut crate::W<REG> {
129 self.variant(DATLEN::TwentyFourBit)
130 }
131 #[inline(always)]
133 pub fn thirty_two_bit(self) -> &'a mut crate::W<REG> {
134 self.variant(DATLEN::ThirtyTwoBit)
135 }
136}
137#[cfg_attr(feature = "defmt", derive(defmt::Format))]
141#[derive(Clone, Copy, Debug, PartialEq, Eq)]
142pub enum CKPOL {
143 IdleLow = 0,
145 IdleHigh = 1,
147}
148impl From<CKPOL> for bool {
149 #[inline(always)]
150 fn from(variant: CKPOL) -> Self {
151 variant as u8 != 0
152 }
153}
154pub type CKPOL_R = crate::BitReader<CKPOL>;
156impl CKPOL_R {
157 #[inline(always)]
159 pub const fn variant(&self) -> CKPOL {
160 match self.bits {
161 false => CKPOL::IdleLow,
162 true => CKPOL::IdleHigh,
163 }
164 }
165 #[inline(always)]
167 pub fn is_idle_low(&self) -> bool {
168 *self == CKPOL::IdleLow
169 }
170 #[inline(always)]
172 pub fn is_idle_high(&self) -> bool {
173 *self == CKPOL::IdleHigh
174 }
175}
176pub type CKPOL_W<'a, REG> = crate::BitWriter<'a, REG, CKPOL>;
178impl<'a, REG> CKPOL_W<'a, REG>
179where
180 REG: crate::Writable + crate::RegisterSpec,
181{
182 #[inline(always)]
184 pub fn idle_low(self) -> &'a mut crate::W<REG> {
185 self.variant(CKPOL::IdleLow)
186 }
187 #[inline(always)]
189 pub fn idle_high(self) -> &'a mut crate::W<REG> {
190 self.variant(CKPOL::IdleHigh)
191 }
192}
193#[cfg_attr(feature = "defmt", derive(defmt::Format))]
197#[derive(Clone, Copy, Debug, PartialEq, Eq)]
198#[repr(u8)]
199pub enum I2SSTD {
200 Philips = 0,
202 Msb = 1,
204 Lsb = 2,
206 Pcm = 3,
208}
209impl From<I2SSTD> for u8 {
210 #[inline(always)]
211 fn from(variant: I2SSTD) -> Self {
212 variant as _
213 }
214}
215impl crate::FieldSpec for I2SSTD {
216 type Ux = u8;
217}
218impl crate::IsEnum for I2SSTD {}
219pub type I2SSTD_R = crate::FieldReader<I2SSTD>;
221impl I2SSTD_R {
222 #[inline(always)]
224 pub const fn variant(&self) -> I2SSTD {
225 match self.bits {
226 0 => I2SSTD::Philips,
227 1 => I2SSTD::Msb,
228 2 => I2SSTD::Lsb,
229 3 => I2SSTD::Pcm,
230 _ => unreachable!(),
231 }
232 }
233 #[inline(always)]
235 pub fn is_philips(&self) -> bool {
236 *self == I2SSTD::Philips
237 }
238 #[inline(always)]
240 pub fn is_msb(&self) -> bool {
241 *self == I2SSTD::Msb
242 }
243 #[inline(always)]
245 pub fn is_lsb(&self) -> bool {
246 *self == I2SSTD::Lsb
247 }
248 #[inline(always)]
250 pub fn is_pcm(&self) -> bool {
251 *self == I2SSTD::Pcm
252 }
253}
254pub type I2SSTD_W<'a, REG> = crate::FieldWriter<'a, REG, 2, I2SSTD, crate::Safe>;
256impl<'a, REG> I2SSTD_W<'a, REG>
257where
258 REG: crate::Writable + crate::RegisterSpec,
259 REG::Ux: From<u8>,
260{
261 #[inline(always)]
263 pub fn philips(self) -> &'a mut crate::W<REG> {
264 self.variant(I2SSTD::Philips)
265 }
266 #[inline(always)]
268 pub fn msb(self) -> &'a mut crate::W<REG> {
269 self.variant(I2SSTD::Msb)
270 }
271 #[inline(always)]
273 pub fn lsb(self) -> &'a mut crate::W<REG> {
274 self.variant(I2SSTD::Lsb)
275 }
276 #[inline(always)]
278 pub fn pcm(self) -> &'a mut crate::W<REG> {
279 self.variant(I2SSTD::Pcm)
280 }
281}
282#[cfg_attr(feature = "defmt", derive(defmt::Format))]
286#[derive(Clone, Copy, Debug, PartialEq, Eq)]
287pub enum PCMSYNC {
288 Short = 0,
290 Long = 1,
292}
293impl From<PCMSYNC> for bool {
294 #[inline(always)]
295 fn from(variant: PCMSYNC) -> Self {
296 variant as u8 != 0
297 }
298}
299pub type PCMSYNC_R = crate::BitReader<PCMSYNC>;
301impl PCMSYNC_R {
302 #[inline(always)]
304 pub const fn variant(&self) -> PCMSYNC {
305 match self.bits {
306 false => PCMSYNC::Short,
307 true => PCMSYNC::Long,
308 }
309 }
310 #[inline(always)]
312 pub fn is_short(&self) -> bool {
313 *self == PCMSYNC::Short
314 }
315 #[inline(always)]
317 pub fn is_long(&self) -> bool {
318 *self == PCMSYNC::Long
319 }
320}
321pub type PCMSYNC_W<'a, REG> = crate::BitWriter<'a, REG, PCMSYNC>;
323impl<'a, REG> PCMSYNC_W<'a, REG>
324where
325 REG: crate::Writable + crate::RegisterSpec,
326{
327 #[inline(always)]
329 pub fn short(self) -> &'a mut crate::W<REG> {
330 self.variant(PCMSYNC::Short)
331 }
332 #[inline(always)]
334 pub fn long(self) -> &'a mut crate::W<REG> {
335 self.variant(PCMSYNC::Long)
336 }
337}
338#[cfg_attr(feature = "defmt", derive(defmt::Format))]
342#[derive(Clone, Copy, Debug, PartialEq, Eq)]
343#[repr(u8)]
344pub enum I2SCFG {
345 SlaveTx = 0,
347 SlaveRx = 1,
349 MasterTx = 2,
351 MasterRx = 3,
353}
354impl From<I2SCFG> for u8 {
355 #[inline(always)]
356 fn from(variant: I2SCFG) -> Self {
357 variant as _
358 }
359}
360impl crate::FieldSpec for I2SCFG {
361 type Ux = u8;
362}
363impl crate::IsEnum for I2SCFG {}
364pub type I2SCFG_R = crate::FieldReader<I2SCFG>;
366impl I2SCFG_R {
367 #[inline(always)]
369 pub const fn variant(&self) -> I2SCFG {
370 match self.bits {
371 0 => I2SCFG::SlaveTx,
372 1 => I2SCFG::SlaveRx,
373 2 => I2SCFG::MasterTx,
374 3 => I2SCFG::MasterRx,
375 _ => unreachable!(),
376 }
377 }
378 #[inline(always)]
380 pub fn is_slave_tx(&self) -> bool {
381 *self == I2SCFG::SlaveTx
382 }
383 #[inline(always)]
385 pub fn is_slave_rx(&self) -> bool {
386 *self == I2SCFG::SlaveRx
387 }
388 #[inline(always)]
390 pub fn is_master_tx(&self) -> bool {
391 *self == I2SCFG::MasterTx
392 }
393 #[inline(always)]
395 pub fn is_master_rx(&self) -> bool {
396 *self == I2SCFG::MasterRx
397 }
398}
399pub type I2SCFG_W<'a, REG> = crate::FieldWriter<'a, REG, 2, I2SCFG, crate::Safe>;
401impl<'a, REG> I2SCFG_W<'a, REG>
402where
403 REG: crate::Writable + crate::RegisterSpec,
404 REG::Ux: From<u8>,
405{
406 #[inline(always)]
408 pub fn slave_tx(self) -> &'a mut crate::W<REG> {
409 self.variant(I2SCFG::SlaveTx)
410 }
411 #[inline(always)]
413 pub fn slave_rx(self) -> &'a mut crate::W<REG> {
414 self.variant(I2SCFG::SlaveRx)
415 }
416 #[inline(always)]
418 pub fn master_tx(self) -> &'a mut crate::W<REG> {
419 self.variant(I2SCFG::MasterTx)
420 }
421 #[inline(always)]
423 pub fn master_rx(self) -> &'a mut crate::W<REG> {
424 self.variant(I2SCFG::MasterRx)
425 }
426}
427#[cfg_attr(feature = "defmt", derive(defmt::Format))]
431#[derive(Clone, Copy, Debug, PartialEq, Eq)]
432pub enum I2SE {
433 Disabled = 0,
435 Enabled = 1,
437}
438impl From<I2SE> for bool {
439 #[inline(always)]
440 fn from(variant: I2SE) -> Self {
441 variant as u8 != 0
442 }
443}
444pub type I2SE_R = crate::BitReader<I2SE>;
446impl I2SE_R {
447 #[inline(always)]
449 pub const fn variant(&self) -> I2SE {
450 match self.bits {
451 false => I2SE::Disabled,
452 true => I2SE::Enabled,
453 }
454 }
455 #[inline(always)]
457 pub fn is_disabled(&self) -> bool {
458 *self == I2SE::Disabled
459 }
460 #[inline(always)]
462 pub fn is_enabled(&self) -> bool {
463 *self == I2SE::Enabled
464 }
465}
466pub type I2SE_W<'a, REG> = crate::BitWriter<'a, REG, I2SE>;
468impl<'a, REG> I2SE_W<'a, REG>
469where
470 REG: crate::Writable + crate::RegisterSpec,
471{
472 #[inline(always)]
474 pub fn disabled(self) -> &'a mut crate::W<REG> {
475 self.variant(I2SE::Disabled)
476 }
477 #[inline(always)]
479 pub fn enabled(self) -> &'a mut crate::W<REG> {
480 self.variant(I2SE::Enabled)
481 }
482}
483#[cfg_attr(feature = "defmt", derive(defmt::Format))]
487#[derive(Clone, Copy, Debug, PartialEq, Eq)]
488pub enum I2SMOD {
489 Spimode = 0,
491 I2smode = 1,
493}
494impl From<I2SMOD> for bool {
495 #[inline(always)]
496 fn from(variant: I2SMOD) -> Self {
497 variant as u8 != 0
498 }
499}
500pub type I2SMOD_R = crate::BitReader<I2SMOD>;
502impl I2SMOD_R {
503 #[inline(always)]
505 pub const fn variant(&self) -> I2SMOD {
506 match self.bits {
507 false => I2SMOD::Spimode,
508 true => I2SMOD::I2smode,
509 }
510 }
511 #[inline(always)]
513 pub fn is_spimode(&self) -> bool {
514 *self == I2SMOD::Spimode
515 }
516 #[inline(always)]
518 pub fn is_i2smode(&self) -> bool {
519 *self == I2SMOD::I2smode
520 }
521}
522pub type I2SMOD_W<'a, REG> = crate::BitWriter<'a, REG, I2SMOD>;
524impl<'a, REG> I2SMOD_W<'a, REG>
525where
526 REG: crate::Writable + crate::RegisterSpec,
527{
528 #[inline(always)]
530 pub fn spimode(self) -> &'a mut crate::W<REG> {
531 self.variant(I2SMOD::Spimode)
532 }
533 #[inline(always)]
535 pub fn i2smode(self) -> &'a mut crate::W<REG> {
536 self.variant(I2SMOD::I2smode)
537 }
538}
539impl R {
540 #[inline(always)]
542 pub fn chlen(&self) -> CHLEN_R {
543 CHLEN_R::new((self.bits & 1) != 0)
544 }
545 #[inline(always)]
547 pub fn datlen(&self) -> DATLEN_R {
548 DATLEN_R::new(((self.bits >> 1) & 3) as u8)
549 }
550 #[inline(always)]
552 pub fn ckpol(&self) -> CKPOL_R {
553 CKPOL_R::new(((self.bits >> 3) & 1) != 0)
554 }
555 #[inline(always)]
557 pub fn i2sstd(&self) -> I2SSTD_R {
558 I2SSTD_R::new(((self.bits >> 4) & 3) as u8)
559 }
560 #[inline(always)]
562 pub fn pcmsync(&self) -> PCMSYNC_R {
563 PCMSYNC_R::new(((self.bits >> 7) & 1) != 0)
564 }
565 #[inline(always)]
567 pub fn i2scfg(&self) -> I2SCFG_R {
568 I2SCFG_R::new(((self.bits >> 8) & 3) as u8)
569 }
570 #[inline(always)]
572 pub fn i2se(&self) -> I2SE_R {
573 I2SE_R::new(((self.bits >> 10) & 1) != 0)
574 }
575 #[inline(always)]
577 pub fn i2smod(&self) -> I2SMOD_R {
578 I2SMOD_R::new(((self.bits >> 11) & 1) != 0)
579 }
580}
581impl core::fmt::Debug for R {
582 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
583 f.debug_struct("I2SCFGR")
584 .field("i2smod", &self.i2smod())
585 .field("i2se", &self.i2se())
586 .field("i2scfg", &self.i2scfg())
587 .field("pcmsync", &self.pcmsync())
588 .field("i2sstd", &self.i2sstd())
589 .field("ckpol", &self.ckpol())
590 .field("datlen", &self.datlen())
591 .field("chlen", &self.chlen())
592 .finish()
593 }
594}
595impl W {
596 #[inline(always)]
598 pub fn chlen(&mut self) -> CHLEN_W<I2SCFGRrs> {
599 CHLEN_W::new(self, 0)
600 }
601 #[inline(always)]
603 pub fn datlen(&mut self) -> DATLEN_W<I2SCFGRrs> {
604 DATLEN_W::new(self, 1)
605 }
606 #[inline(always)]
608 pub fn ckpol(&mut self) -> CKPOL_W<I2SCFGRrs> {
609 CKPOL_W::new(self, 3)
610 }
611 #[inline(always)]
613 pub fn i2sstd(&mut self) -> I2SSTD_W<I2SCFGRrs> {
614 I2SSTD_W::new(self, 4)
615 }
616 #[inline(always)]
618 pub fn pcmsync(&mut self) -> PCMSYNC_W<I2SCFGRrs> {
619 PCMSYNC_W::new(self, 7)
620 }
621 #[inline(always)]
623 pub fn i2scfg(&mut self) -> I2SCFG_W<I2SCFGRrs> {
624 I2SCFG_W::new(self, 8)
625 }
626 #[inline(always)]
628 pub fn i2se(&mut self) -> I2SE_W<I2SCFGRrs> {
629 I2SE_W::new(self, 10)
630 }
631 #[inline(always)]
633 pub fn i2smod(&mut self) -> I2SMOD_W<I2SCFGRrs> {
634 I2SMOD_W::new(self, 11)
635 }
636}
637pub struct I2SCFGRrs;
643impl crate::RegisterSpec for I2SCFGRrs {
644 type Ux = u16;
645}
646impl crate::Readable for I2SCFGRrs {}
648impl crate::Writable for I2SCFGRrs {
650 type Safety = crate::Unsafe;
651}
652impl crate::Resettable for I2SCFGRrs {}