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
503
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::identity_op)]
#![allow(clippy::unnecessary_cast)]
#![allow(clippy::erasing_op)]

#[doc = "Management data input/output slave"]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mdios {
    ptr: *mut u8,
}
unsafe impl Send for Mdios {}
unsafe impl Sync for Mdios {}
impl Mdios {
    #[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 = "MDIOS configuration register"]
    #[inline(always)]
    pub const fn cr(self) -> crate::common::Reg<regs::Cr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0usize) as _) }
    }
    #[doc = "MDIOS write flag register"]
    #[inline(always)]
    pub const fn wrfr(self) -> crate::common::Reg<regs::Wrfr, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x04usize) as _) }
    }
    #[doc = "MDIOS clear write flag register"]
    #[inline(always)]
    pub const fn cwrfr(self) -> crate::common::Reg<regs::Cwrfr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x08usize) as _) }
    }
    #[doc = "MDIOS read flag register"]
    #[inline(always)]
    pub const fn rdfr(self) -> crate::common::Reg<regs::Rdfr, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize) as _) }
    }
    #[doc = "MDIOS clear read flag register"]
    #[inline(always)]
    pub const fn crdfr(self) -> crate::common::Reg<regs::Crdfr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x10usize) as _) }
    }
    #[doc = "MDIOS status register"]
    #[inline(always)]
    pub const fn sr(self) -> crate::common::Reg<regs::Sr, crate::common::R> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x14usize) as _) }
    }
    #[doc = "MDIOS clear flag register"]
    #[inline(always)]
    pub const fn clrfr(self) -> crate::common::Reg<regs::Clrfr, crate::common::RW> {
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x18usize) as _) }
    }
    #[doc = "MDIOS input data register %s"]
    #[inline(always)]
    pub const fn dinr(self, n: usize) -> crate::common::Reg<regs::Dinr, crate::common::R> {
        assert!(n < 32usize);
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0100usize + n * 4usize) as _) }
    }
    #[doc = "MDIOS output data register %s"]
    #[inline(always)]
    pub const fn doutr(self, n: usize) -> crate::common::Reg<regs::Doutr, crate::common::RW> {
        assert!(n < 32usize);
        unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0180usize + n * 4usize) as _) }
    }
}
pub mod regs {
    #[doc = "MDIOS clear flag register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Clrfr(pub u32);
    impl Clrfr {
        #[doc = "Clear the preamble error flag"]
        #[inline(always)]
        pub const fn cperf(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Clear the preamble error flag"]
        #[inline(always)]
        pub fn set_cperf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Clear the start error flag"]
        #[inline(always)]
        pub const fn cserf(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Clear the start error flag"]
        #[inline(always)]
        pub fn set_cserf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
        }
        #[doc = "Clear the turnaround error flag"]
        #[inline(always)]
        pub const fn cterf(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Clear the turnaround error flag"]
        #[inline(always)]
        pub fn set_cterf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
    }
    impl Default for Clrfr {
        #[inline(always)]
        fn default() -> Clrfr {
            Clrfr(0)
        }
    }
    impl core::fmt::Debug for Clrfr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Clrfr")
                .field("cperf", &self.cperf())
                .field("cserf", &self.cserf())
                .field("cterf", &self.cterf())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Clrfr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(
                f,
                "Clrfr {{ cperf: {=bool:?}, cserf: {=bool:?}, cterf: {=bool:?} }}",
                self.cperf(),
                self.cserf(),
                self.cterf()
            )
        }
    }
    #[doc = "MDIOS configuration register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Cr(pub u32);
    impl Cr {
        #[doc = "Peripheral enable"]
        #[inline(always)]
        pub const fn en(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Peripheral enable"]
        #[inline(always)]
        pub fn set_en(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Register write interrupt enable"]
        #[inline(always)]
        pub const fn wrie(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Register write interrupt enable"]
        #[inline(always)]
        pub fn set_wrie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
        }
        #[doc = "Register Read Interrupt Enable"]
        #[inline(always)]
        pub const fn rdie(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Register Read Interrupt Enable"]
        #[inline(always)]
        pub fn set_rdie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
        #[doc = "Error interrupt enable"]
        #[inline(always)]
        pub const fn eie(&self) -> bool {
            let val = (self.0 >> 3usize) & 0x01;
            val != 0
        }
        #[doc = "Error interrupt enable"]
        #[inline(always)]
        pub fn set_eie(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
        }
        #[doc = "Disable Preamble Check"]
        #[inline(always)]
        pub const fn dpc(&self) -> bool {
            let val = (self.0 >> 7usize) & 0x01;
            val != 0
        }
        #[doc = "Disable Preamble Check"]
        #[inline(always)]
        pub fn set_dpc(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
        }
        #[doc = "Slaves's address"]
        #[inline(always)]
        pub const fn port_address(&self) -> u8 {
            let val = (self.0 >> 8usize) & 0x1f;
            val as u8
        }
        #[doc = "Slaves's address"]
        #[inline(always)]
        pub fn set_port_address(&mut self, val: u8) {
            self.0 = (self.0 & !(0x1f << 8usize)) | (((val as u32) & 0x1f) << 8usize);
        }
    }
    impl Default for Cr {
        #[inline(always)]
        fn default() -> Cr {
            Cr(0)
        }
    }
    impl core::fmt::Debug for Cr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Cr")
                .field("en", &self.en())
                .field("wrie", &self.wrie())
                .field("rdie", &self.rdie())
                .field("eie", &self.eie())
                .field("dpc", &self.dpc())
                .field("port_address", &self.port_address())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Cr {
        fn format(&self, f: defmt::Formatter) {
            defmt :: write ! (f , "Cr {{ en: {=bool:?}, wrie: {=bool:?}, rdie: {=bool:?}, eie: {=bool:?}, dpc: {=bool:?}, port_address: {=u8:?} }}" , self . en () , self . wrie () , self . rdie () , self . eie () , self . dpc () , self . port_address ())
        }
    }
    #[doc = "MDIOS clear read flag register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Crdfr(pub u32);
    impl Crdfr {
        #[doc = "Clear the read flag"]
        #[inline(always)]
        pub const fn crdf(&self) -> u32 {
            let val = (self.0 >> 0usize) & 0xffff_ffff;
            val as u32
        }
        #[doc = "Clear the read flag"]
        #[inline(always)]
        pub fn set_crdf(&mut self, val: u32) {
            self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
        }
    }
    impl Default for Crdfr {
        #[inline(always)]
        fn default() -> Crdfr {
            Crdfr(0)
        }
    }
    impl core::fmt::Debug for Crdfr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Crdfr").field("crdf", &self.crdf()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Crdfr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Crdfr {{ crdf: {=u32:?} }}", self.crdf())
        }
    }
    #[doc = "MDIOS clear write flag register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Cwrfr(pub u32);
    impl Cwrfr {
        #[doc = "Clear the write flag"]
        #[inline(always)]
        pub const fn cwrf(&self) -> u32 {
            let val = (self.0 >> 0usize) & 0xffff_ffff;
            val as u32
        }
        #[doc = "Clear the write flag"]
        #[inline(always)]
        pub fn set_cwrf(&mut self, val: u32) {
            self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
        }
    }
    impl Default for Cwrfr {
        #[inline(always)]
        fn default() -> Cwrfr {
            Cwrfr(0)
        }
    }
    impl core::fmt::Debug for Cwrfr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Cwrfr").field("cwrf", &self.cwrf()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Cwrfr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Cwrfr {{ cwrf: {=u32:?} }}", self.cwrf())
        }
    }
    #[doc = "MDIOS input data register %s"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Dinr(pub u32);
    impl Dinr {
        #[doc = "Input data received from MDIO Master during write frames"]
        #[inline(always)]
        pub const fn din(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0xffff;
            val as u16
        }
        #[doc = "Input data received from MDIO Master during write frames"]
        #[inline(always)]
        pub fn set_din(&mut self, val: u16) {
            self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
        }
    }
    impl Default for Dinr {
        #[inline(always)]
        fn default() -> Dinr {
            Dinr(0)
        }
    }
    impl core::fmt::Debug for Dinr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Dinr").field("din", &self.din()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Dinr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Dinr {{ din: {=u16:?} }}", self.din())
        }
    }
    #[doc = "MDIOS output data register %s"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Doutr(pub u32);
    impl Doutr {
        #[doc = "Output data sent to MDIO Master during read frames"]
        #[inline(always)]
        pub const fn dout(&self) -> u16 {
            let val = (self.0 >> 0usize) & 0xffff;
            val as u16
        }
        #[doc = "Output data sent to MDIO Master during read frames"]
        #[inline(always)]
        pub fn set_dout(&mut self, val: u16) {
            self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
        }
    }
    impl Default for Doutr {
        #[inline(always)]
        fn default() -> Doutr {
            Doutr(0)
        }
    }
    impl core::fmt::Debug for Doutr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Doutr").field("dout", &self.dout()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Doutr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Doutr {{ dout: {=u16:?} }}", self.dout())
        }
    }
    #[doc = "MDIOS read flag register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Rdfr(pub u32);
    impl Rdfr {
        #[doc = "Read flags for MDIO registers 0 to 31"]
        #[inline(always)]
        pub const fn rdf(&self) -> u32 {
            let val = (self.0 >> 0usize) & 0xffff_ffff;
            val as u32
        }
        #[doc = "Read flags for MDIO registers 0 to 31"]
        #[inline(always)]
        pub fn set_rdf(&mut self, val: u32) {
            self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
        }
    }
    impl Default for Rdfr {
        #[inline(always)]
        fn default() -> Rdfr {
            Rdfr(0)
        }
    }
    impl core::fmt::Debug for Rdfr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Rdfr").field("rdf", &self.rdf()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Rdfr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Rdfr {{ rdf: {=u32:?} }}", self.rdf())
        }
    }
    #[doc = "MDIOS status register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Sr(pub u32);
    impl Sr {
        #[doc = "Preamble error flag"]
        #[inline(always)]
        pub const fn perf(&self) -> bool {
            let val = (self.0 >> 0usize) & 0x01;
            val != 0
        }
        #[doc = "Preamble error flag"]
        #[inline(always)]
        pub fn set_perf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
        }
        #[doc = "Start error flag"]
        #[inline(always)]
        pub const fn serf(&self) -> bool {
            let val = (self.0 >> 1usize) & 0x01;
            val != 0
        }
        #[doc = "Start error flag"]
        #[inline(always)]
        pub fn set_serf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
        }
        #[doc = "Turnaround error flag"]
        #[inline(always)]
        pub const fn terf(&self) -> bool {
            let val = (self.0 >> 2usize) & 0x01;
            val != 0
        }
        #[doc = "Turnaround error flag"]
        #[inline(always)]
        pub fn set_terf(&mut self, val: bool) {
            self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
        }
    }
    impl Default for Sr {
        #[inline(always)]
        fn default() -> Sr {
            Sr(0)
        }
    }
    impl core::fmt::Debug for Sr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Sr")
                .field("perf", &self.perf())
                .field("serf", &self.serf())
                .field("terf", &self.terf())
                .finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Sr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(
                f,
                "Sr {{ perf: {=bool:?}, serf: {=bool:?}, terf: {=bool:?} }}",
                self.perf(),
                self.serf(),
                self.terf()
            )
        }
    }
    #[doc = "MDIOS write flag register"]
    #[repr(transparent)]
    #[derive(Copy, Clone, Eq, PartialEq)]
    pub struct Wrfr(pub u32);
    impl Wrfr {
        #[doc = "Write flags for MDIO registers 0 to 31"]
        #[inline(always)]
        pub const fn wrf(&self) -> u32 {
            let val = (self.0 >> 0usize) & 0xffff_ffff;
            val as u32
        }
        #[doc = "Write flags for MDIO registers 0 to 31"]
        #[inline(always)]
        pub fn set_wrf(&mut self, val: u32) {
            self.0 = (self.0 & !(0xffff_ffff << 0usize)) | (((val as u32) & 0xffff_ffff) << 0usize);
        }
    }
    impl Default for Wrfr {
        #[inline(always)]
        fn default() -> Wrfr {
            Wrfr(0)
        }
    }
    impl core::fmt::Debug for Wrfr {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
            f.debug_struct("Wrfr").field("wrf", &self.wrf()).finish()
        }
    }
    #[cfg(feature = "defmt")]
    impl defmt::Format for Wrfr {
        fn format(&self, f: defmt::Formatter) {
            defmt::write!(f, "Wrfr {{ wrf: {=u32:?} }}", self.wrf())
        }
    }
}