efm32pg1b-pac 0.4.3

Peripheral access API for Silicon Labs EFM32PG1B microcontrollers
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
///Register `FRAME` reader
pub type R = crate::R<FRAMErs>;
///Register `FRAME` writer
pub type W = crate::W<FRAMErs>;
///Data-Bit Mode
///
///Value on reset: 5
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum DATABITS {
    ///1: Each frame contains 4 data bits
    Four = 1,
    ///2: Each frame contains 5 data bits
    Five = 2,
    ///3: Each frame contains 6 data bits
    Six = 3,
    ///4: Each frame contains 7 data bits
    Seven = 4,
    ///5: Each frame contains 8 data bits
    Eight = 5,
    ///6: Each frame contains 9 data bits
    Nine = 6,
    ///7: Each frame contains 10 data bits
    Ten = 7,
    ///8: Each frame contains 11 data bits
    Eleven = 8,
    ///9: Each frame contains 12 data bits
    Twelve = 9,
    ///10: Each frame contains 13 data bits
    Thirteen = 10,
    ///11: Each frame contains 14 data bits
    Fourteen = 11,
    ///12: Each frame contains 15 data bits
    Fifteen = 12,
    ///13: Each frame contains 16 data bits
    Sixteen = 13,
}
impl From<DATABITS> for u8 {
    #[inline(always)]
    fn from(variant: DATABITS) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for DATABITS {
    type Ux = u8;
}
impl crate::IsEnum for DATABITS {}
///Field `DATABITS` reader - Data-Bit Mode
pub type DatabitsR = crate::FieldReader<DATABITS>;
impl DatabitsR {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> Option<DATABITS> {
        match self.bits {
            1 => Some(DATABITS::Four),
            2 => Some(DATABITS::Five),
            3 => Some(DATABITS::Six),
            4 => Some(DATABITS::Seven),
            5 => Some(DATABITS::Eight),
            6 => Some(DATABITS::Nine),
            7 => Some(DATABITS::Ten),
            8 => Some(DATABITS::Eleven),
            9 => Some(DATABITS::Twelve),
            10 => Some(DATABITS::Thirteen),
            11 => Some(DATABITS::Fourteen),
            12 => Some(DATABITS::Fifteen),
            13 => Some(DATABITS::Sixteen),
            _ => None,
        }
    }
    ///Each frame contains 4 data bits
    #[inline(always)]
    pub fn is_four(&self) -> bool {
        *self == DATABITS::Four
    }
    ///Each frame contains 5 data bits
    #[inline(always)]
    pub fn is_five(&self) -> bool {
        *self == DATABITS::Five
    }
    ///Each frame contains 6 data bits
    #[inline(always)]
    pub fn is_six(&self) -> bool {
        *self == DATABITS::Six
    }
    ///Each frame contains 7 data bits
    #[inline(always)]
    pub fn is_seven(&self) -> bool {
        *self == DATABITS::Seven
    }
    ///Each frame contains 8 data bits
    #[inline(always)]
    pub fn is_eight(&self) -> bool {
        *self == DATABITS::Eight
    }
    ///Each frame contains 9 data bits
    #[inline(always)]
    pub fn is_nine(&self) -> bool {
        *self == DATABITS::Nine
    }
    ///Each frame contains 10 data bits
    #[inline(always)]
    pub fn is_ten(&self) -> bool {
        *self == DATABITS::Ten
    }
    ///Each frame contains 11 data bits
    #[inline(always)]
    pub fn is_eleven(&self) -> bool {
        *self == DATABITS::Eleven
    }
    ///Each frame contains 12 data bits
    #[inline(always)]
    pub fn is_twelve(&self) -> bool {
        *self == DATABITS::Twelve
    }
    ///Each frame contains 13 data bits
    #[inline(always)]
    pub fn is_thirteen(&self) -> bool {
        *self == DATABITS::Thirteen
    }
    ///Each frame contains 14 data bits
    #[inline(always)]
    pub fn is_fourteen(&self) -> bool {
        *self == DATABITS::Fourteen
    }
    ///Each frame contains 15 data bits
    #[inline(always)]
    pub fn is_fifteen(&self) -> bool {
        *self == DATABITS::Fifteen
    }
    ///Each frame contains 16 data bits
    #[inline(always)]
    pub fn is_sixteen(&self) -> bool {
        *self == DATABITS::Sixteen
    }
}
///Field `DATABITS` writer - Data-Bit Mode
pub type DatabitsW<'a, REG> = crate::FieldWriter<'a, REG, 4, DATABITS>;
impl<'a, REG> DatabitsW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    ///Each frame contains 4 data bits
    #[inline(always)]
    pub fn four(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Four)
    }
    ///Each frame contains 5 data bits
    #[inline(always)]
    pub fn five(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Five)
    }
    ///Each frame contains 6 data bits
    #[inline(always)]
    pub fn six(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Six)
    }
    ///Each frame contains 7 data bits
    #[inline(always)]
    pub fn seven(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Seven)
    }
    ///Each frame contains 8 data bits
    #[inline(always)]
    pub fn eight(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Eight)
    }
    ///Each frame contains 9 data bits
    #[inline(always)]
    pub fn nine(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Nine)
    }
    ///Each frame contains 10 data bits
    #[inline(always)]
    pub fn ten(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Ten)
    }
    ///Each frame contains 11 data bits
    #[inline(always)]
    pub fn eleven(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Eleven)
    }
    ///Each frame contains 12 data bits
    #[inline(always)]
    pub fn twelve(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Twelve)
    }
    ///Each frame contains 13 data bits
    #[inline(always)]
    pub fn thirteen(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Thirteen)
    }
    ///Each frame contains 14 data bits
    #[inline(always)]
    pub fn fourteen(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Fourteen)
    }
    ///Each frame contains 15 data bits
    #[inline(always)]
    pub fn fifteen(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Fifteen)
    }
    ///Each frame contains 16 data bits
    #[inline(always)]
    pub fn sixteen(self) -> &'a mut crate::W<REG> {
        self.variant(DATABITS::Sixteen)
    }
}
///Parity-Bit Mode
///
///Value on reset: 0
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum PARITY {
    ///0: Parity bits are not used
    None = 0,
    ///2: Even parity are used. Parity bits are automatically generated and checked by hardware.
    Even = 2,
    ///3: Odd parity is used. Parity bits are automatically generated and checked by hardware.
    Odd = 3,
}
impl From<PARITY> for u8 {
    #[inline(always)]
    fn from(variant: PARITY) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for PARITY {
    type Ux = u8;
}
impl crate::IsEnum for PARITY {}
///Field `PARITY` reader - Parity-Bit Mode
pub type ParityR = crate::FieldReader<PARITY>;
impl ParityR {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> Option<PARITY> {
        match self.bits {
            0 => Some(PARITY::None),
            2 => Some(PARITY::Even),
            3 => Some(PARITY::Odd),
            _ => None,
        }
    }
    ///Parity bits are not used
    #[inline(always)]
    pub fn is_none(&self) -> bool {
        *self == PARITY::None
    }
    ///Even parity are used. Parity bits are automatically generated and checked by hardware.
    #[inline(always)]
    pub fn is_even(&self) -> bool {
        *self == PARITY::Even
    }
    ///Odd parity is used. Parity bits are automatically generated and checked by hardware.
    #[inline(always)]
    pub fn is_odd(&self) -> bool {
        *self == PARITY::Odd
    }
}
///Field `PARITY` writer - Parity-Bit Mode
pub type ParityW<'a, REG> = crate::FieldWriter<'a, REG, 2, PARITY>;
impl<'a, REG> ParityW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    ///Parity bits are not used
    #[inline(always)]
    pub fn none(self) -> &'a mut crate::W<REG> {
        self.variant(PARITY::None)
    }
    ///Even parity are used. Parity bits are automatically generated and checked by hardware.
    #[inline(always)]
    pub fn even(self) -> &'a mut crate::W<REG> {
        self.variant(PARITY::Even)
    }
    ///Odd parity is used. Parity bits are automatically generated and checked by hardware.
    #[inline(always)]
    pub fn odd(self) -> &'a mut crate::W<REG> {
        self.variant(PARITY::Odd)
    }
}
///Stop-Bit Mode
///
///Value on reset: 1
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum STOPBITS {
    ///0: The transmitter generates a half stop bit. Stop-bits are not verified by receiver
    Half = 0,
    ///1: One stop bit is generated and verified
    One = 1,
    ///2: The transmitter generates one and a half stop bit. The receiver verifies the first stop bit
    Oneandahalf = 2,
    ///3: The transmitter generates two stop bits. The receiver checks the first stop-bit only
    Two = 3,
}
impl From<STOPBITS> for u8 {
    #[inline(always)]
    fn from(variant: STOPBITS) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for STOPBITS {
    type Ux = u8;
}
impl crate::IsEnum for STOPBITS {}
///Field `STOPBITS` reader - Stop-Bit Mode
pub type StopbitsR = crate::FieldReader<STOPBITS>;
impl StopbitsR {
    ///Get enumerated values variant
    #[inline(always)]
    pub const fn variant(&self) -> STOPBITS {
        match self.bits {
            0 => STOPBITS::Half,
            1 => STOPBITS::One,
            2 => STOPBITS::Oneandahalf,
            3 => STOPBITS::Two,
            _ => unreachable!(),
        }
    }
    ///The transmitter generates a half stop bit. Stop-bits are not verified by receiver
    #[inline(always)]
    pub fn is_half(&self) -> bool {
        *self == STOPBITS::Half
    }
    ///One stop bit is generated and verified
    #[inline(always)]
    pub fn is_one(&self) -> bool {
        *self == STOPBITS::One
    }
    ///The transmitter generates one and a half stop bit. The receiver verifies the first stop bit
    #[inline(always)]
    pub fn is_oneandahalf(&self) -> bool {
        *self == STOPBITS::Oneandahalf
    }
    ///The transmitter generates two stop bits. The receiver checks the first stop-bit only
    #[inline(always)]
    pub fn is_two(&self) -> bool {
        *self == STOPBITS::Two
    }
}
///Field `STOPBITS` writer - Stop-Bit Mode
pub type StopbitsW<'a, REG> = crate::FieldWriter<'a, REG, 2, STOPBITS, crate::Safe>;
impl<'a, REG> StopbitsW<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    ///The transmitter generates a half stop bit. Stop-bits are not verified by receiver
    #[inline(always)]
    pub fn half(self) -> &'a mut crate::W<REG> {
        self.variant(STOPBITS::Half)
    }
    ///One stop bit is generated and verified
    #[inline(always)]
    pub fn one(self) -> &'a mut crate::W<REG> {
        self.variant(STOPBITS::One)
    }
    ///The transmitter generates one and a half stop bit. The receiver verifies the first stop bit
    #[inline(always)]
    pub fn oneandahalf(self) -> &'a mut crate::W<REG> {
        self.variant(STOPBITS::Oneandahalf)
    }
    ///The transmitter generates two stop bits. The receiver checks the first stop-bit only
    #[inline(always)]
    pub fn two(self) -> &'a mut crate::W<REG> {
        self.variant(STOPBITS::Two)
    }
}
impl R {
    ///Bits 0:3 - Data-Bit Mode
    #[inline(always)]
    pub fn databits(&self) -> DatabitsR {
        DatabitsR::new((self.bits & 0x0f) as u8)
    }
    ///Bits 8:9 - Parity-Bit Mode
    #[inline(always)]
    pub fn parity(&self) -> ParityR {
        ParityR::new(((self.bits >> 8) & 3) as u8)
    }
    ///Bits 12:13 - Stop-Bit Mode
    #[inline(always)]
    pub fn stopbits(&self) -> StopbitsR {
        StopbitsR::new(((self.bits >> 12) & 3) as u8)
    }
}
impl core::fmt::Debug for R {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        f.debug_struct("FRAME")
            .field("databits", &self.databits())
            .field("parity", &self.parity())
            .field("stopbits", &self.stopbits())
            .finish()
    }
}
impl W {
    ///Bits 0:3 - Data-Bit Mode
    #[inline(always)]
    pub fn databits(&mut self) -> DatabitsW<'_, FRAMErs> {
        DatabitsW::new(self, 0)
    }
    ///Bits 8:9 - Parity-Bit Mode
    #[inline(always)]
    pub fn parity(&mut self) -> ParityW<'_, FRAMErs> {
        ParityW::new(self, 8)
    }
    ///Bits 12:13 - Stop-Bit Mode
    #[inline(always)]
    pub fn stopbits(&mut self) -> StopbitsW<'_, FRAMErs> {
        StopbitsW::new(self, 12)
    }
}
///USART Frame Format Register
///
///You can [`read`](crate::Reg::read) this register and get [`frame::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`frame::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
pub struct FRAMErs;
impl crate::RegisterSpec for FRAMErs {
    type Ux = u32;
}
///`read()` method returns [`frame::R`](R) reader structure
impl crate::Readable for FRAMErs {}
///`write(|w| ..)` method takes [`frame::W`](W) writer structure
impl crate::Writable for FRAMErs {
    type Safety = crate::Unsafe;
}
///`reset()` method sets FRAME to value 0x1005
impl crate::Resettable for FRAMErs {
    const RESET_VALUE: u32 = 0x1005;
}