stm32-metapac 18.0.0

Peripheral Access Crate (PAC) for all STM32 chips, including metadata.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::identity_op)]
#![allow(clippy::unnecessary_cast)]
#![allow(clippy::erasing_op)]

#[doc = "HDMI-CEC controller."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cec {
    ptr: *mut u8,
}
unsafe impl Send for Cec {}
unsafe impl Sync for Cec {}
impl Cec {
    #[inline(always)]
    pub const unsafe fn from_ptr(ptr: *mut ()) -> Self {
        Self { ptr: ptr as _ }
    }
    #[inline(always)]
    pub const fn as_ptr(&self) -> *mut () {
        self.ptr as _
    }
    #[doc = "configuration register."]
    #[inline(always)]
    pub const fn cfgr(self) -> crate::common::Reg<regs::Cfgr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0usize) as _) }
    }
    #[doc = "CEC own address register."]
    #[inline(always)]
    pub const fn oar(self) -> crate::common::Reg<regs::Oar, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x04usize) as _) }
    }
    #[doc = "Rx Data Register."]
    #[inline(always)]
    pub const fn pres(self) -> crate::common::Reg<regs::Pres, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x08usize) as _) }
    }
    #[doc = "CEC error status register."]
    #[inline(always)]
    pub const fn esr(self) -> crate::common::Reg<regs::Esr, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize) as _) }
    }
    #[doc = "CEC control and status register."]
    #[inline(always)]
    pub const fn csr(self) -> crate::common::Reg<regs::Csr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x10usize) as _) }
    }
    #[doc = "CEC Tx data register."]
    #[inline(always)]
    pub const fn txd(self) -> crate::common::Reg<regs::Txd, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x14usize) as _) }
    }
    #[doc = "CEC Rx data register."]
    #[inline(always)]
    pub const fn rxd(self) -> crate::common::Reg<regs::Rxd, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x18usize) as _) }
    }
}
pub mod regs {
    #[doc = "configuration register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Cfgr(pub u32);
    impl Cfgr {
        #[doc = "Peripheral enable."]
        #[inline(always)]
        pub const fn pe(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Peripheral enable."]
        #[inline(always)]
        pub fn set_pe(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Interrupt enable."]
        #[inline(always)]
        pub const fn ie(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Interrupt enable."]
        #[inline(always)]
        pub fn set_ie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
        }
        #[doc = "Bit timing error mode."]
        #[inline(always)]
        pub const fn btem(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Bit timing error mode."]
        #[inline(always)]
        pub fn set_btem(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
        #[doc = "Bit period error mode."]
        #[inline(always)]
        pub const fn bpem(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Bit period error mode."]
        #[inline(always)]
        pub fn set_bpem(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
        }
    }
    impl Default for Cfgr {
        #[inline(always)]
        fn default() -> Cfgr {
            Cfgr(0)
        }
    }
    impl core::fmt::Debug for Cfgr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Cfgr")
                .field("pe", &self.pe())
                .field("ie", &self.ie())
                .field("btem", &self.btem())
                .field("bpem", &self.bpem())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Cfgr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(
                f,
                "Cfgr {{ pe: {=bool:?}, ie: {=bool:?}, btem: {=bool:?}, bpem: {=bool:?} }}",
                self.pe(),
                self.ie(),
                self.btem(),
                self.bpem()
            )
        }
    }
    #[doc = "CEC control and status register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Csr(pub u32);
    impl Csr {
        #[doc = "Tx start of message."]
        #[inline(always)]
        pub const fn tsom(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Tx start of message."]
        #[inline(always)]
        pub fn set_tsom(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Tx end of message."]
        #[inline(always)]
        pub const fn teom(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Tx end of message."]
        #[inline(always)]
        pub fn set_teom(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
        }
        #[doc = "Tx error."]
        #[inline(always)]
        pub const fn terr(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Tx error."]
        #[inline(always)]
        pub fn set_terr(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
        #[doc = "Tx byte transfer request or block transfer finished."]
        #[inline(always)]
        pub const fn tbtrf(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Tx byte transfer request or block transfer finished."]
        #[inline(always)]
        pub fn set_tbtrf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
        }
        #[doc = "Rx start of message."]
        #[inline(always)]
        pub const fn rsom(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Rx start of message."]
        #[inline(always)]
        pub fn set_rsom(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
        }
        #[doc = "Rx end of message."]
        #[inline(always)]
        pub const fn reom(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Rx end of message."]
        #[inline(always)]
        pub fn set_reom(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
        }
        #[doc = "Rx error."]
        #[inline(always)]
        pub const fn rerr(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Rx error."]
        #[inline(always)]
        pub fn set_rerr(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
        }
        #[doc = "Rx byte/block transfer finished."]
        #[inline(always)]
        pub const fn rbtf(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Rx byte/block transfer finished."]
        #[inline(always)]
        pub fn set_rbtf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
        }
    }
    impl Default for Csr {
        #[inline(always)]
        fn default() -> Csr {
            Csr(0)
        }
    }
    impl core::fmt::Debug for Csr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Csr")
                .field("tsom", &self.tsom())
                .field("teom", &self.teom())
                .field("terr", &self.terr())
                .field("tbtrf", &self.tbtrf())
                .field("rsom", &self.rsom())
                .field("reom", &self.reom())
                .field("rerr", &self.rerr())
                .field("rbtf", &self.rbtf())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Csr {
        fn format(&self, f: defmt::Formatter) {
            defmt :: write ! (f , "Csr {{ tsom: {=bool:?}, teom: {=bool:?}, terr: {=bool:?}, tbtrf: {=bool:?}, rsom: {=bool:?}, reom: {=bool:?}, rerr: {=bool:?}, rbtf: {=bool:?} }}" , self . tsom () , self . teom () , self . terr () , self . tbtrf () , self . rsom () , self . reom () , self . rerr () , self . rbtf ())
        }
    }
    #[doc = "CEC error status register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Esr(pub u32);
    impl Esr {
        #[doc = "Bit timing error."]
        #[inline(always)]
        pub const fn bte(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Bit timing error."]
        #[inline(always)]
        pub fn set_bte(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Bit period error."]
        #[inline(always)]
        pub const fn bpe(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Bit period error."]
        #[inline(always)]
        pub fn set_bpe(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
        }
        #[doc = "Rx block transfer finished error."]
        #[inline(always)]
        pub const fn rbtfe(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Rx block transfer finished error."]
        #[inline(always)]
        pub fn set_rbtfe(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
        #[doc = "Start bit error."]
        #[inline(always)]
        pub const fn sbe(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Start bit error."]
        #[inline(always)]
        pub fn set_sbe(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
        }
        #[doc = "Block acknowledge error."]
        #[inline(always)]
        pub const fn acke(&self) -> bool {
            let val = (self.0 >> 4usize) & 0x01;
            val != 0
        }
        #[doc = "Block acknowledge error."]
        #[inline(always)]
        pub fn set_acke(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
        }
        #[doc = "Line error."]
        #[inline(always)]
        pub const fn line(&self) -> bool {
            let val = (self.0 >> 5usize) & 0x01;
            val != 0
        }
        #[doc = "Line error."]
        #[inline(always)]
        pub fn set_line(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
        }
        #[doc = "Tx block transfer finished error."]
        #[inline(always)]
        pub const fn tbtfe(&self) -> bool {
            let val = (self.0 >> 6usize) & 0x01;
            val != 0
        }
        #[doc = "Tx block transfer finished error."]
        #[inline(always)]
        pub fn set_tbtfe(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
        }
    }
    impl Default for Esr {
        #[inline(always)]
        fn default() -> Esr {
            Esr(0)
        }
    }
    impl core::fmt::Debug for Esr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Esr")
                .field("bte", &self.bte())
                .field("bpe", &self.bpe())
                .field("rbtfe", &self.rbtfe())
                .field("sbe", &self.sbe())
                .field("acke", &self.acke())
                .field("line", &self.line())
                .field("tbtfe", &self.tbtfe())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Esr {
        fn format(&self, f: defmt::Formatter) {
            defmt :: write ! (f , "Esr {{ bte: {=bool:?}, bpe: {=bool:?}, rbtfe: {=bool:?}, sbe: {=bool:?}, acke: {=bool:?}, line: {=bool:?}, tbtfe: {=bool:?} }}" , self . bte () , self . bpe () , self . rbtfe () , self . sbe () , self . acke () , self . line () , self . tbtfe ())
        }
    }
    #[doc = "CEC own address register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Oar(pub u32);
    impl Oar {
        #[doc = "Own address."]
        #[inline(always)]
        pub const fn oa(&self) -> u8 {
            let val = (self.0 >> 0usize) & 0x0f;
            val as u8
        }
        #[doc = "Own address."]
        #[inline(always)]
        pub fn set_oa(&mut self, val: u8) {
            self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
        }
    }
    impl Default for Oar {
        #[inline(always)]
        fn default() -> Oar {
            Oar(0)
        }
    }
    impl core::fmt::Debug for Oar {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Oar").field("oa", &self.oa()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Oar {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Oar {{ oa: {=u8:?} }}", self.oa())
        }
    }
    #[doc = "Rx Data Register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Pres(pub u32);
    impl Pres {
        #[doc = "CEC Rx Data Register."]
        #[inline(always)]
        pub const fn presc(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0x3fff;
            val as u16
        }
        #[doc = "CEC Rx Data Register."]
        #[inline(always)]
        pub fn set_presc(&mut self, val: u16) {
            self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
        }
    }
    impl Default for Pres {
        #[inline(always)]
        fn default() -> Pres {
            Pres(0)
        }
    }
    impl core::fmt::Debug for Pres {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Pres").field("presc", &self.presc()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Pres {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Pres {{ presc: {=u16:?} }}", self.presc())
        }
    }
    #[doc = "CEC Rx data register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Rxd(pub u32);
    impl Rxd {
        #[doc = "Rx data."]
        #[inline(always)]
        pub const fn rxd(&self) -> u8 {
            let val = (self.0 >> 0usize) & 0xff;
            val as u8
        }
        #[doc = "Rx data."]
        #[inline(always)]
        pub fn set_rxd(&mut self, val: u8) {
            self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
        }
    }
    impl Default for Rxd {
        #[inline(always)]
        fn default() -> Rxd {
            Rxd(0)
        }
    }
    impl core::fmt::Debug for Rxd {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Rxd").field("rxd", &self.rxd()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Rxd {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Rxd {{ rxd: {=u8:?} }}", self.rxd())
        }
    }
    #[doc = "CEC Tx data register."]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Txd(pub u32);
    impl Txd {
        #[doc = "Tx Data register."]
        #[inline(always)]
        pub const fn txd(&self) -> u8 {
            let val = (self.0 >> 0usize) & 0xff;
            val as u8
        }
        #[doc = "Tx Data register."]
        #[inline(always)]
        pub fn set_txd(&mut self, val: u8) {
            self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
        }
    }
    impl Default for Txd {
        #[inline(always)]
        fn default() -> Txd {
            Txd(0)
        }
    }
    impl core::fmt::Debug for Txd {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Txd").field("txd", &self.txd()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Txd {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Txd {{ txd: {=u8:?} }}", self.txd())
        }
    }
}