stm32f2 0.16.0

Device support crates for STM32F2 devices
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
///Register `CLKCR` reader
pub type R = crate::R<CLKCRrs>;
///Register `CLKCR` writer
pub type W = crate::W<CLKCRrs>;
///Field `CLKDIV` reader - Clock divide factor
pub type CLKDIV_R = crate::FieldReader;
///Field `CLKDIV` writer - Clock divide factor
pub type CLKDIV_W<'a, REG> = crate::FieldWriter<'a, REG, 8, u8, crate::Safe>;
/**Clock enable bit

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CLKEN {
    ///0: Disable clock
    Disabled = 0,
    ///1: Enable clock
    Enabled = 1,
}
impl From<CLKEN> for bool {
    #[inline(always)]
    fn from(variant: CLKEN) -> Self {
        variant as u8 != 0
    }
}
///Field `CLKEN` reader - Clock enable bit
pub type CLKEN_R = crate::BitReader<CLKEN>;
impl CLKEN_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> CLKEN {
        match self.bits {
            false => CLKEN::Disabled,
            true => CLKEN::Enabled,
        }
    }
    ///Disable clock
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == CLKEN::Disabled
    }
    ///Enable clock
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == CLKEN::Enabled
    }
}
///Field `CLKEN` writer - Clock enable bit
pub type CLKEN_W<'a, REG> = crate::BitWriter<'a, REG, CLKEN>;
impl<'a, REG> CLKEN_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///Disable clock
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(CLKEN::Disabled)
    }
    ///Enable clock
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(CLKEN::Enabled)
    }
}
/**Power saving configuration bit

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PWRSAV {
    ///0: SDIO_CK clock is always enabled
    Enabled = 0,
    ///1: SDIO_CK is only enabled when the bus is active
    Disabled = 1,
}
impl From<PWRSAV> for bool {
    #[inline(always)]
    fn from(variant: PWRSAV) -> Self {
        variant as u8 != 0
    }
}
///Field `PWRSAV` reader - Power saving configuration bit
pub type PWRSAV_R = crate::BitReader<PWRSAV>;
impl PWRSAV_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> PWRSAV {
        match self.bits {
            false => PWRSAV::Enabled,
            true => PWRSAV::Disabled,
        }
    }
    ///SDIO_CK clock is always enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == PWRSAV::Enabled
    }
    ///SDIO_CK is only enabled when the bus is active
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == PWRSAV::Disabled
    }
}
///Field `PWRSAV` writer - Power saving configuration bit
pub type PWRSAV_W<'a, REG> = crate::BitWriter<'a, REG, PWRSAV>;
impl<'a, REG> PWRSAV_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///SDIO_CK clock is always enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(PWRSAV::Enabled)
    }
    ///SDIO_CK is only enabled when the bus is active
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(PWRSAV::Disabled)
    }
}
/**Clock divider bypass enable bit

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BYPASS {
    ///0: SDIOCLK is divided according to the CLKDIV value before driving the SDIO_CK output signal.
    Disabled = 0,
    ///1: SDIOCLK directly drives the SDIO_CK output signal
    Enabled = 1,
}
impl From<BYPASS> for bool {
    #[inline(always)]
    fn from(variant: BYPASS) -> Self {
        variant as u8 != 0
    }
}
///Field `BYPASS` reader - Clock divider bypass enable bit
pub type BYPASS_R = crate::BitReader<BYPASS>;
impl BYPASS_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> BYPASS {
        match self.bits {
            false => BYPASS::Disabled,
            true => BYPASS::Enabled,
        }
    }
    ///SDIOCLK is divided according to the CLKDIV value before driving the SDIO_CK output signal.
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == BYPASS::Disabled
    }
    ///SDIOCLK directly drives the SDIO_CK output signal
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == BYPASS::Enabled
    }
}
///Field `BYPASS` writer - Clock divider bypass enable bit
pub type BYPASS_W<'a, REG> = crate::BitWriter<'a, REG, BYPASS>;
impl<'a, REG> BYPASS_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///SDIOCLK is divided according to the CLKDIV value before driving the SDIO_CK output signal.
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(BYPASS::Disabled)
    }
    ///SDIOCLK directly drives the SDIO_CK output signal
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(BYPASS::Enabled)
    }
}
/**Wide bus mode enable bit

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum WIDBUS {
    ///0: 1 lane wide bus
    BusWidth1 = 0,
    ///1: 4 lane wide bus
    BusWidth4 = 1,
    ///2: 8 lane wide bus
    BusWidth8 = 2,
}
impl From<WIDBUS> for u8 {
    #[inline(always)]
    fn from(variant: WIDBUS) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for WIDBUS {
    type Ux = u8;
}
impl crate::IsEnum for WIDBUS {}
///Field `WIDBUS` reader - Wide bus mode enable bit
pub type WIDBUS_R = crate::FieldReader<WIDBUS>;
impl WIDBUS_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> Option<WIDBUS> {
        match self.bits {
            0 => Some(WIDBUS::BusWidth1),
            1 => Some(WIDBUS::BusWidth4),
            2 => Some(WIDBUS::BusWidth8),
            _ => None,
        }
    }
    ///1 lane wide bus
    #[inline(always)]
    pub fn is_bus_width1(&self) -> bool {
        *self == WIDBUS::BusWidth1
    }
    ///4 lane wide bus
    #[inline(always)]
    pub fn is_bus_width4(&self) -> bool {
        *self == WIDBUS::BusWidth4
    }
    ///8 lane wide bus
    #[inline(always)]
    pub fn is_bus_width8(&self) -> bool {
        *self == WIDBUS::BusWidth8
    }
}
///Field `WIDBUS` writer - Wide bus mode enable bit
pub type WIDBUS_W<'a, REG> = crate::FieldWriter<'a, REG, 2, WIDBUS>;
impl<'a, REG> WIDBUS_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    ///1 lane wide bus
    #[inline(always)]
    pub fn bus_width1(self) -> &'a mut crate::W<REG> {
        self.variant(WIDBUS::BusWidth1)
    }
    ///4 lane wide bus
    #[inline(always)]
    pub fn bus_width4(self) -> &'a mut crate::W<REG> {
        self.variant(WIDBUS::BusWidth4)
    }
    ///8 lane wide bus
    #[inline(always)]
    pub fn bus_width8(self) -> &'a mut crate::W<REG> {
        self.variant(WIDBUS::BusWidth8)
    }
}
/**SDIO_CK dephasing selection bit

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NEGEDGE {
    ///0: SDIO_CK generated on the rising edge
    Rising = 0,
    ///1: SDIO_CK generated on the falling edge
    Falling = 1,
}
impl From<NEGEDGE> for bool {
    #[inline(always)]
    fn from(variant: NEGEDGE) -> Self {
        variant as u8 != 0
    }
}
///Field `NEGEDGE` reader - SDIO_CK dephasing selection bit
pub type NEGEDGE_R = crate::BitReader<NEGEDGE>;
impl NEGEDGE_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> NEGEDGE {
        match self.bits {
            false => NEGEDGE::Rising,
            true => NEGEDGE::Falling,
        }
    }
    ///SDIO_CK generated on the rising edge
    #[inline(always)]
    pub fn is_rising(&self) -> bool {
        *self == NEGEDGE::Rising
    }
    ///SDIO_CK generated on the falling edge
    #[inline(always)]
    pub fn is_falling(&self) -> bool {
        *self == NEGEDGE::Falling
    }
}
///Field `NEGEDGE` writer - SDIO_CK dephasing selection bit
pub type NEGEDGE_W<'a, REG> = crate::BitWriter<'a, REG, NEGEDGE>;
impl<'a, REG> NEGEDGE_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///SDIO_CK generated on the rising edge
    #[inline(always)]
    pub fn rising(self) -> &'a mut crate::W<REG> {
        self.variant(NEGEDGE::Rising)
    }
    ///SDIO_CK generated on the falling edge
    #[inline(always)]
    pub fn falling(self) -> &'a mut crate::W<REG> {
        self.variant(NEGEDGE::Falling)
    }
}
/**HW Flow Control enable

Value on reset: 0*/
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HWFC_EN {
    ///0: HW Flow Control is disabled
    Disabled = 0,
    ///1: HW Flow Control is enabled
    Enabled = 1,
}
impl From<HWFC_EN> for bool {
    #[inline(always)]
    fn from(variant: HWFC_EN) -> Self {
        variant as u8 != 0
    }
}
///Field `HWFC_EN` reader - HW Flow Control enable
pub type HWFC_EN_R = crate::BitReader<HWFC_EN>;
impl HWFC_EN_R {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> HWFC_EN {
        match self.bits {
            false => HWFC_EN::Disabled,
            true => HWFC_EN::Enabled,
        }
    }
    ///HW Flow Control is disabled
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == HWFC_EN::Disabled
    }
    ///HW Flow Control is enabled
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == HWFC_EN::Enabled
    }
}
///Field `HWFC_EN` writer - HW Flow Control enable
pub type HWFC_EN_W<'a, REG> = crate::BitWriter<'a, REG, HWFC_EN>;
impl<'a, REG> HWFC_EN_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    ///HW Flow Control is disabled
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(HWFC_EN::Disabled)
    }
    ///HW Flow Control is enabled
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(HWFC_EN::Enabled)
    }
}
impl R {
    ///Bits 0:7 - Clock divide factor
    #[inline(always)]
    pub fn clkdiv(&self) -> CLKDIV_R {
        CLKDIV_R::new((self.bits & 0xff) as u8)
    }
    ///Bit 8 - Clock enable bit
    #[inline(always)]
    pub fn clken(&self) -> CLKEN_R {
        CLKEN_R::new(((self.bits >> 8) & 1) != 0)
    }
    ///Bit 9 - Power saving configuration bit
    #[inline(always)]
    pub fn pwrsav(&self) -> PWRSAV_R {
        PWRSAV_R::new(((self.bits >> 9) & 1) != 0)
    }
    ///Bit 10 - Clock divider bypass enable bit
    #[inline(always)]
    pub fn bypass(&self) -> BYPASS_R {
        BYPASS_R::new(((self.bits >> 10) & 1) != 0)
    }
    ///Bits 11:12 - Wide bus mode enable bit
    #[inline(always)]
    pub fn widbus(&self) -> WIDBUS_R {
        WIDBUS_R::new(((self.bits >> 11) & 3) as u8)
    }
    ///Bit 13 - SDIO_CK dephasing selection bit
    #[inline(always)]
    pub fn negedge(&self) -> NEGEDGE_R {
        NEGEDGE_R::new(((self.bits >> 13) & 1) != 0)
    }
    ///Bit 14 - HW Flow Control enable
    #[inline(always)]
    pub fn hwfc_en(&self) -> HWFC_EN_R {
        HWFC_EN_R::new(((self.bits >> 14) & 1) != 0)
    }
}
impl core::fmt::Debug for R {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("CLKCR")
            .field("hwfc_en", &self.hwfc_en())
            .field("negedge", &self.negedge())
            .field("widbus", &self.widbus())
            .field("bypass", &self.bypass())
            .field("pwrsav", &self.pwrsav())
            .field("clken", &self.clken())
            .field("clkdiv", &self.clkdiv())
            .finish()
    }
}
impl W {
    ///Bits 0:7 - Clock divide factor
    #[inline(always)]
    pub fn clkdiv(&mut self) -> CLKDIV_W<CLKCRrs> {
        CLKDIV_W::new(self, 0)
    }
    ///Bit 8 - Clock enable bit
    #[inline(always)]
    pub fn clken(&mut self) -> CLKEN_W<CLKCRrs> {
        CLKEN_W::new(self, 8)
    }
    ///Bit 9 - Power saving configuration bit
    #[inline(always)]
    pub fn pwrsav(&mut self) -> PWRSAV_W<CLKCRrs> {
        PWRSAV_W::new(self, 9)
    }
    ///Bit 10 - Clock divider bypass enable bit
    #[inline(always)]
    pub fn bypass(&mut self) -> BYPASS_W<CLKCRrs> {
        BYPASS_W::new(self, 10)
    }
    ///Bits 11:12 - Wide bus mode enable bit
    #[inline(always)]
    pub fn widbus(&mut self) -> WIDBUS_W<CLKCRrs> {
        WIDBUS_W::new(self, 11)
    }
    ///Bit 13 - SDIO_CK dephasing selection bit
    #[inline(always)]
    pub fn negedge(&mut self) -> NEGEDGE_W<CLKCRrs> {
        NEGEDGE_W::new(self, 13)
    }
    ///Bit 14 - HW Flow Control enable
    #[inline(always)]
    pub fn hwfc_en(&mut self) -> HWFC_EN_W<CLKCRrs> {
        HWFC_EN_W::new(self, 14)
    }
}
/**SDI clock control register

You can [`read`](crate::Reg::read) this register and get [`clkcr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`clkcr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).

See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F217.html#SDIO:CLKCR)*/
pub struct CLKCRrs;
impl crate::RegisterSpec for CLKCRrs {
    type Ux = u32;
}
///`read()` method returns [`clkcr::R`](R) reader structure
impl crate::Readable for CLKCRrs {}
///`write(|w| ..)` method takes [`clkcr::W`](W) writer structure
impl crate::Writable for CLKCRrs {
    type Safety = crate::Unsafe;
}
///`reset()` method sets CLKCR to value 0
impl crate::Resettable for CLKCRrs {}