gd32f4pac 0.9.2

Device support crate for GD32F4 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
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
504
#[doc = "Register `CS` reader"]
pub type R = crate::R<CsSpec>;
#[doc = "Register `CS` writer"]
pub type W = crate::W<CsSpec>;
#[doc = "Wakeup flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Wufr {
    #[doc = "0: No wakeup event received"]
    NoEvent = 0,
    #[doc = "1: Wakeup event occurred"]
    EventOccurred = 1,
}
impl From<Wufr> for bool {
    #[inline(always)]
    fn from(variant: Wufr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `WUF` reader - Wakeup flag"]
pub type WufR = crate::BitReader<Wufr>;
impl WufR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Wufr {
        match self.bits {
            false => Wufr::NoEvent,
            true => Wufr::EventOccurred,
        }
    }
    #[doc = "No wakeup event received"]
    #[inline(always)]
    pub fn is_no_event(&self) -> bool {
        *self == Wufr::NoEvent
    }
    #[doc = "Wakeup event occurred"]
    #[inline(always)]
    pub fn is_event_occurred(&self) -> bool {
        *self == Wufr::EventOccurred
    }
}
#[doc = "Standby flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Stbfr {
    #[doc = "0: The device has not entered Standby mode"]
    NotEntered = 0,
    #[doc = "1: The device has been in Standby mode"]
    Entered = 1,
}
impl From<Stbfr> for bool {
    #[inline(always)]
    fn from(variant: Stbfr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `STBF` reader - Standby flag"]
pub type StbfR = crate::BitReader<Stbfr>;
impl StbfR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Stbfr {
        match self.bits {
            false => Stbfr::NotEntered,
            true => Stbfr::Entered,
        }
    }
    #[doc = "The device has not entered Standby mode"]
    #[inline(always)]
    pub fn is_not_entered(&self) -> bool {
        *self == Stbfr::NotEntered
    }
    #[doc = "The device has been in Standby mode"]
    #[inline(always)]
    pub fn is_entered(&self) -> bool {
        *self == Stbfr::Entered
    }
}
#[doc = "Low Voltage Detector Status Flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Lvdfr {
    #[doc = "0: No Low Voltage event occurred (VDD > threshold)"]
    NoEvent = 0,
    #[doc = "1: Low Voltage event occurred (VDD ≤ threshold)"]
    EventOccurred = 1,
}
impl From<Lvdfr> for bool {
    #[inline(always)]
    fn from(variant: Lvdfr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `LVDF` reader - Low Voltage Detector Status Flag"]
pub type LvdfR = crate::BitReader<Lvdfr>;
impl LvdfR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Lvdfr {
        match self.bits {
            false => Lvdfr::NoEvent,
            true => Lvdfr::EventOccurred,
        }
    }
    #[doc = "No Low Voltage event occurred (VDD > threshold)"]
    #[inline(always)]
    pub fn is_no_event(&self) -> bool {
        *self == Lvdfr::NoEvent
    }
    #[doc = "Low Voltage event occurred (VDD ≤ threshold)"]
    #[inline(always)]
    pub fn is_event_occurred(&self) -> bool {
        *self == Lvdfr::EventOccurred
    }
}
#[doc = "Backup SRAM LDO ready flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Bldorfr {
    #[doc = "0: Backup SRAM LDO not ready"]
    NotReady = 0,
    #[doc = "1: Backup SRAM LDO ready"]
    Ready = 1,
}
impl From<Bldorfr> for bool {
    #[inline(always)]
    fn from(variant: Bldorfr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `BLDORF` reader - Backup SRAM LDO ready flag"]
pub type BldorfR = crate::BitReader<Bldorfr>;
impl BldorfR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Bldorfr {
        match self.bits {
            false => Bldorfr::NotReady,
            true => Bldorfr::Ready,
        }
    }
    #[doc = "Backup SRAM LDO not ready"]
    #[inline(always)]
    pub fn is_not_ready(&self) -> bool {
        *self == Bldorfr::NotReady
    }
    #[doc = "Backup SRAM LDO ready"]
    #[inline(always)]
    pub fn is_ready(&self) -> bool {
        *self == Bldorfr::Ready
    }
}
#[doc = "Enable WKUP pin\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Wupen {
    #[doc = "0: WKUP pin function disabled"]
    Disabled = 0,
    #[doc = "1: WKUP pin function enabled"]
    Enabled = 1,
}
impl From<Wupen> for bool {
    #[inline(always)]
    fn from(variant: Wupen) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `WUPEN` reader - Enable WKUP pin"]
pub type WupenR = crate::BitReader<Wupen>;
impl WupenR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Wupen {
        match self.bits {
            false => Wupen::Disabled,
            true => Wupen::Enabled,
        }
    }
    #[doc = "WKUP pin function disabled"]
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        *self == Wupen::Disabled
    }
    #[doc = "WKUP pin function enabled"]
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        *self == Wupen::Enabled
    }
}
#[doc = "Field `WUPEN` writer - Enable WKUP pin"]
pub type WupenW<'a, REG> = crate::BitWriter<'a, REG, Wupen>;
impl<'a, REG> WupenW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "WKUP pin function disabled"]
    #[inline(always)]
    pub fn disabled(self) -> &'a mut crate::W<REG> {
        self.variant(Wupen::Disabled)
    }
    #[doc = "WKUP pin function enabled"]
    #[inline(always)]
    pub fn enabled(self) -> &'a mut crate::W<REG> {
        self.variant(Wupen::Enabled)
    }
}
#[doc = "Backup SRAM LDO on\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Bldoon {
    #[doc = "0: Backup SRAM LDO closed"]
    Closed = 0,
    #[doc = "1: Open the Backup SRAM LDO"]
    Open = 1,
}
impl From<Bldoon> for bool {
    #[inline(always)]
    fn from(variant: Bldoon) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `BLDOON` reader - Backup SRAM LDO on"]
pub type BldoonR = crate::BitReader<Bldoon>;
impl BldoonR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Bldoon {
        match self.bits {
            false => Bldoon::Closed,
            true => Bldoon::Open,
        }
    }
    #[doc = "Backup SRAM LDO closed"]
    #[inline(always)]
    pub fn is_closed(&self) -> bool {
        *self == Bldoon::Closed
    }
    #[doc = "Open the Backup SRAM LDO"]
    #[inline(always)]
    pub fn is_open(&self) -> bool {
        *self == Bldoon::Open
    }
}
#[doc = "Field `BLDOON` writer - Backup SRAM LDO on"]
pub type BldoonW<'a, REG> = crate::BitWriter<'a, REG, Bldoon>;
impl<'a, REG> BldoonW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
{
    #[doc = "Backup SRAM LDO closed"]
    #[inline(always)]
    pub fn closed(self) -> &'a mut crate::W<REG> {
        self.variant(Bldoon::Closed)
    }
    #[doc = "Open the Backup SRAM LDO"]
    #[inline(always)]
    pub fn open(self) -> &'a mut crate::W<REG> {
        self.variant(Bldoon::Open)
    }
}
#[doc = "LDO voltage select ready flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Ldovsrfr {
    #[doc = "0: LDO voltage select not ready"]
    NotReady = 0,
    #[doc = "1: LDO voltage select ready"]
    Ready = 1,
}
impl From<Ldovsrfr> for bool {
    #[inline(always)]
    fn from(variant: Ldovsrfr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `LDOVSRF` reader - LDO voltage select ready flag"]
pub type LdovsrfR = crate::BitReader<Ldovsrfr>;
impl LdovsrfR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Ldovsrfr {
        match self.bits {
            false => Ldovsrfr::NotReady,
            true => Ldovsrfr::Ready,
        }
    }
    #[doc = "LDO voltage select not ready"]
    #[inline(always)]
    pub fn is_not_ready(&self) -> bool {
        *self == Ldovsrfr::NotReady
    }
    #[doc = "LDO voltage select ready"]
    #[inline(always)]
    pub fn is_ready(&self) -> bool {
        *self == Ldovsrfr::Ready
    }
}
#[doc = "High-driver ready flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Hdrfr {
    #[doc = "0: High-driver not ready"]
    NotReady = 0,
    #[doc = "1: High-driver ready"]
    Ready = 1,
}
impl From<Hdrfr> for bool {
    #[inline(always)]
    fn from(variant: Hdrfr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `HDRF` reader - High-driver ready flag"]
pub type HdrfR = crate::BitReader<Hdrfr>;
impl HdrfR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Hdrfr {
        match self.bits {
            false => Hdrfr::NotReady,
            true => Hdrfr::Ready,
        }
    }
    #[doc = "High-driver not ready"]
    #[inline(always)]
    pub fn is_not_ready(&self) -> bool {
        *self == Hdrfr::NotReady
    }
    #[doc = "High-driver ready"]
    #[inline(always)]
    pub fn is_ready(&self) -> bool {
        *self == Hdrfr::Ready
    }
}
#[doc = "High-driver switch ready flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Hdsrfr {
    #[doc = "0: High-driver switch not ready"]
    NotReady = 0,
    #[doc = "1: High-driver switch ready"]
    Ready = 1,
}
impl From<Hdsrfr> for bool {
    #[inline(always)]
    fn from(variant: Hdsrfr) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `HDSRF` reader - High-driver switch ready flag"]
pub type HdsrfR = crate::BitReader<Hdsrfr>;
impl HdsrfR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Hdsrfr {
        match self.bits {
            false => Hdsrfr::NotReady,
            true => Hdsrfr::Ready,
        }
    }
    #[doc = "High-driver switch not ready"]
    #[inline(always)]
    pub fn is_not_ready(&self) -> bool {
        *self == Hdsrfr::NotReady
    }
    #[doc = "High-driver switch ready"]
    #[inline(always)]
    pub fn is_ready(&self) -> bool {
        *self == Hdsrfr::Ready
    }
}
#[doc = "Low-driver mode ready flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum Ldrf {
    #[doc = "0: Normal driver in Deep-sleep mode"]
    NormalDriver = 0,
    #[doc = "3: Low-driver mode in Deep-sleep mode"]
    LowDriver = 3,
}
impl From<Ldrf> for u8 {
    #[inline(always)]
    fn from(variant: Ldrf) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for Ldrf {
    type Ux = u8;
}
impl crate::IsEnum for Ldrf {}
#[doc = "Field `LDRF` reader - Low-driver mode ready flag"]
pub type LdrfR = crate::FieldReader<Ldrf>;
impl LdrfR {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Option<Ldrf> {
        match self.bits {
            0 => Some(Ldrf::NormalDriver),
            3 => Some(Ldrf::LowDriver),
            _ => None,
        }
    }
    #[doc = "Normal driver in Deep-sleep mode"]
    #[inline(always)]
    pub fn is_normal_driver(&self) -> bool {
        *self == Ldrf::NormalDriver
    }
    #[doc = "Low-driver mode in Deep-sleep mode"]
    #[inline(always)]
    pub fn is_low_driver(&self) -> bool {
        *self == Ldrf::LowDriver
    }
}
#[doc = "Field `LDRF` writer - Low-driver mode ready flag"]
pub type LdrfW<'a, REG> = crate::FieldWriter<'a, REG, 2, Ldrf>;
impl<'a, REG> LdrfW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "Normal driver in Deep-sleep mode"]
    #[inline(always)]
    pub fn normal_driver(self) -> &'a mut crate::W<REG> {
        self.variant(Ldrf::NormalDriver)
    }
    #[doc = "Low-driver mode in Deep-sleep mode"]
    #[inline(always)]
    pub fn low_driver(self) -> &'a mut crate::W<REG> {
        self.variant(Ldrf::LowDriver)
    }
}
impl R {
    #[doc = "Bit 0 - Wakeup flag"]
    #[inline(always)]
    pub fn wuf(&self) -> WufR {
        WufR::new((self.bits & 1) != 0)
    }
    #[doc = "Bit 1 - Standby flag"]
    #[inline(always)]
    pub fn stbf(&self) -> StbfR {
        StbfR::new(((self.bits >> 1) & 1) != 0)
    }
    #[doc = "Bit 2 - Low Voltage Detector Status Flag"]
    #[inline(always)]
    pub fn lvdf(&self) -> LvdfR {
        LvdfR::new(((self.bits >> 2) & 1) != 0)
    }
    #[doc = "Bit 3 - Backup SRAM LDO ready flag"]
    #[inline(always)]
    pub fn bldorf(&self) -> BldorfR {
        BldorfR::new(((self.bits >> 3) & 1) != 0)
    }
    #[doc = "Bit 8 - Enable WKUP pin"]
    #[inline(always)]
    pub fn wupen(&self) -> WupenR {
        WupenR::new(((self.bits >> 8) & 1) != 0)
    }
    #[doc = "Bit 9 - Backup SRAM LDO on"]
    #[inline(always)]
    pub fn bldoon(&self) -> BldoonR {
        BldoonR::new(((self.bits >> 9) & 1) != 0)
    }
    #[doc = "Bit 14 - LDO voltage select ready flag"]
    #[inline(always)]
    pub fn ldovsrf(&self) -> LdovsrfR {
        LdovsrfR::new(((self.bits >> 14) & 1) != 0)
    }
    #[doc = "Bit 16 - High-driver ready flag"]
    #[inline(always)]
    pub fn hdrf(&self) -> HdrfR {
        HdrfR::new(((self.bits >> 16) & 1) != 0)
    }
    #[doc = "Bit 17 - High-driver switch ready flag"]
    #[inline(always)]
    pub fn hdsrf(&self) -> HdsrfR {
        HdsrfR::new(((self.bits >> 17) & 1) != 0)
    }
    #[doc = "Bits 18:19 - Low-driver mode ready flag"]
    #[inline(always)]
    pub fn ldrf(&self) -> LdrfR {
        LdrfR::new(((self.bits >> 18) & 3) as u8)
    }
}
impl W {
    #[doc = "Bit 8 - Enable WKUP pin"]
    #[inline(always)]
    pub fn wupen(&mut self) -> WupenW<CsSpec> {
        WupenW::new(self, 8)
    }
    #[doc = "Bit 9 - Backup SRAM LDO on"]
    #[inline(always)]
    pub fn bldoon(&mut self) -> BldoonW<CsSpec> {
        BldoonW::new(self, 9)
    }
    #[doc = "Bits 18:19 - Low-driver mode ready flag"]
    #[inline(always)]
    pub fn ldrf(&mut self) -> LdrfW<CsSpec> {
        LdrfW::new(self, 18)
    }
}
#[doc = "power control/status register\n\nYou can [`read`](crate::Reg::read) this register and get [`cs::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`cs::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct CsSpec;
impl crate::RegisterSpec for CsSpec {
    type Ux = u32;
}
#[doc = "`read()` method returns [`cs::R`](R) reader structure"]
impl crate::Readable for CsSpec {}
#[doc = "`write(|w| ..)` method takes [`cs::W`](W) writer structure"]
impl crate::Writable for CsSpec {
    type Safety = crate::Unsafe;
}
#[doc = "`reset()` method sets CS to value 0"]
impl crate::Resettable for CsSpec {}