sam3x8e-pac 0.1.6-dev

Peripheral Access Crate (PAC) for the Atmel SAM3X8E.
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
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Chmode {
    #[doc = "Normal mode"]
    NORMAL = 0x0,
    #[doc = "Automatic Echo. Receiver input is connected to the TXD pin."]
    AUTOMATIC = 0x01,
    #[doc = "Local Loopback. Transmitter output is connected to the Receiver Input."]
    LOCAL_LOOPBACK = 0x02,
    #[doc = "Remote Loopback. RXD pin is internally connected to the TXD pin."]
    REMOTE_LOOPBACK = 0x03,
}
impl Chmode {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> Chmode {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for Chmode {
    #[inline(always)]
    fn from(val: u8) -> Chmode {
        Chmode::from_bits(val)
    }
}
impl From<Chmode> for u8 {
    #[inline(always)]
    fn from(val: Chmode) -> u8 {
        Chmode::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MrChrl {
    #[doc = "Character length is 5 bits"]
    _5_BIT = 0x0,
    #[doc = "Character length is 6 bits"]
    _6_BIT = 0x01,
    #[doc = "Character length is 7 bits"]
    _7_BIT = 0x02,
    #[doc = "Character length is 8 bits"]
    _8_BIT = 0x03,
}
impl MrChrl {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> MrChrl {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for MrChrl {
    #[inline(always)]
    fn from(val: u8) -> MrChrl {
        MrChrl::from_bits(val)
    }
}
impl From<MrChrl> for u8 {
    #[inline(always)]
    fn from(val: MrChrl) -> u8 {
        MrChrl::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MrSpiModeChrl {
    _RESERVED_0 = 0x0,
    _RESERVED_1 = 0x01,
    _RESERVED_2 = 0x02,
    #[doc = "Character length is 8 bits"]
    _8_BIT = 0x03,
}
impl MrSpiModeChrl {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> MrSpiModeChrl {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for MrSpiModeChrl {
    #[inline(always)]
    fn from(val: u8) -> MrSpiModeChrl {
        MrSpiModeChrl::from_bits(val)
    }
}
impl From<MrSpiModeChrl> for u8 {
    #[inline(always)]
    fn from(val: MrSpiModeChrl) -> u8 {
        MrSpiModeChrl::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MrSpiModeUsartMode {
    _RESERVED_0 = 0x0,
    _RESERVED_1 = 0x01,
    _RESERVED_2 = 0x02,
    _RESERVED_3 = 0x03,
    _RESERVED_4 = 0x04,
    _RESERVED_5 = 0x05,
    _RESERVED_6 = 0x06,
    _RESERVED_7 = 0x07,
    _RESERVED_8 = 0x08,
    _RESERVED_9 = 0x09,
    _RESERVED_a = 0x0a,
    _RESERVED_b = 0x0b,
    _RESERVED_c = 0x0c,
    _RESERVED_d = 0x0d,
    #[doc = "SPI master"]
    SPI_MASTER = 0x0e,
    #[doc = "SPI Slave"]
    SPI_SLAVE = 0x0f,
}
impl MrSpiModeUsartMode {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> MrSpiModeUsartMode {
        unsafe { core::mem::transmute(val & 0x0f) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for MrSpiModeUsartMode {
    #[inline(always)]
    fn from(val: u8) -> MrSpiModeUsartMode {
        MrSpiModeUsartMode::from_bits(val)
    }
}
impl From<MrSpiModeUsartMode> for u8 {
    #[inline(always)]
    fn from(val: MrSpiModeUsartMode) -> u8 {
        MrSpiModeUsartMode::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MrSpiModeUsclks {
    #[doc = "master Clock MCK is selected"]
    MCK = 0x0,
    #[doc = "Internal Clock Divided MCK/DIV (DIV=8) is selected"]
    DIV = 0x01,
    _RESERVED_2 = 0x02,
    #[doc = "Serial Clock SLK is selected"]
    SCK = 0x03,
}
impl MrSpiModeUsclks {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> MrSpiModeUsclks {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for MrSpiModeUsclks {
    #[inline(always)]
    fn from(val: u8) -> MrSpiModeUsclks {
        MrSpiModeUsclks::from_bits(val)
    }
}
impl From<MrSpiModeUsclks> for u8 {
    #[inline(always)]
    fn from(val: MrSpiModeUsclks) -> u8 {
        MrSpiModeUsclks::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MrUsartMode {
    #[doc = "Normal mode"]
    NORMAL = 0x0,
    #[doc = "RS485"]
    RS485 = 0x01,
    #[doc = "Hardware Handshaking"]
    HW_HANDSHAKING = 0x02,
    _RESERVED_3 = 0x03,
    #[doc = "IS07816 Protocol: T = 0"]
    IS07816_T_0 = 0x04,
    _RESERVED_5 = 0x05,
    #[doc = "IS07816 Protocol: T = 1"]
    IS07816_T_1 = 0x06,
    _RESERVED_7 = 0x07,
    #[doc = "IrDA"]
    IRDA = 0x08,
    _RESERVED_9 = 0x09,
    #[doc = "LIN master"]
    LIN_MASTER = 0x0a,
    #[doc = "LIN Slave"]
    LIN_SLAVE = 0x0b,
    _RESERVED_c = 0x0c,
    _RESERVED_d = 0x0d,
    #[doc = "SPI master"]
    SPI_MASTER = 0x0e,
    #[doc = "SPI Slave"]
    SPI_SLAVE = 0x0f,
}
impl MrUsartMode {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> MrUsartMode {
        unsafe { core::mem::transmute(val & 0x0f) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for MrUsartMode {
    #[inline(always)]
    fn from(val: u8) -> MrUsartMode {
        MrUsartMode::from_bits(val)
    }
}
impl From<MrUsartMode> for u8 {
    #[inline(always)]
    fn from(val: MrUsartMode) -> u8 {
        MrUsartMode::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MrUsclks {
    #[doc = "master Clock MCK is selected"]
    MCK = 0x0,
    #[doc = "Internal Clock Divided MCK/DIV (DIV=8) is selected"]
    DIV = 0x01,
    _RESERVED_2 = 0x02,
    #[doc = "Serial Clock SLK is selected"]
    SCK = 0x03,
}
impl MrUsclks {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> MrUsclks {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for MrUsclks {
    #[inline(always)]
    fn from(val: u8) -> MrUsclks {
        MrUsclks::from_bits(val)
    }
}
impl From<MrUsclks> for u8 {
    #[inline(always)]
    fn from(val: MrUsclks) -> u8 {
        MrUsclks::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Nact {
    #[doc = "The USART transmits the response."]
    PUBLISH = 0x0,
    #[doc = "The USART receives the response."]
    SUBSCRIBE = 0x01,
    #[doc = "The USART does not transmit and does not receive the response."]
    IGNORE = 0x02,
    _RESERVED_3 = 0x03,
}
impl Nact {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> Nact {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for Nact {
    #[inline(always)]
    fn from(val: u8) -> Nact {
        Nact::from_bits(val)
    }
}
impl From<Nact> for u8 {
    #[inline(always)]
    fn from(val: Nact) -> u8 {
        Nact::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Nbstop {
    #[doc = "1 stop bit"]
    _1_BIT = 0x0,
    #[doc = "1.5 stop bit (SYNC = 0) or reserved (SYNC = 1)"]
    _1_5_BIT = 0x01,
    #[doc = "2 stop bits"]
    _2_BIT = 0x02,
    _RESERVED_3 = 0x03,
}
impl Nbstop {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> Nbstop {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for Nbstop {
    #[inline(always)]
    fn from(val: u8) -> Nbstop {
        Nbstop::from_bits(val)
    }
}
impl From<Nbstop> for u8 {
    #[inline(always)]
    fn from(val: Nbstop) -> u8 {
        Nbstop::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Par {
    #[doc = "Even parity"]
    EVEN = 0x0,
    #[doc = "Odd parity"]
    ODD = 0x01,
    #[doc = "Parity forced to 0 (Space)"]
    SPACE = 0x02,
    #[doc = "Parity forced to 1 (Mark)"]
    MARK = 0x03,
    #[doc = "No parity"]
    NO = 0x04,
    _RESERVED_5 = 0x05,
    #[doc = "Multidrop mode"]
    MULTIDROP = 0x06,
    _RESERVED_7 = 0x07,
}
impl Par {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> Par {
        unsafe { core::mem::transmute(val & 0x07) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for Par {
    #[inline(always)]
    fn from(val: u8) -> Par {
        Par::from_bits(val)
    }
}
impl From<Par> for u8 {
    #[inline(always)]
    fn from(val: Par) -> u8 {
        Par::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RxPp {
    #[doc = "The preamble is composed of '1's"]
    ALL_ONE = 0x0,
    #[doc = "The preamble is composed of '0's"]
    ALL_ZERO = 0x01,
    #[doc = "The preamble is composed of '01's"]
    ZERO_ONE = 0x02,
    #[doc = "The preamble is composed of '10's"]
    ONE_ZERO = 0x03,
}
impl RxPp {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> RxPp {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for RxPp {
    #[inline(always)]
    fn from(val: u8) -> RxPp {
        RxPp::from_bits(val)
    }
}
impl From<RxPp> for u8 {
    #[inline(always)]
    fn from(val: RxPp) -> u8 {
        RxPp::to_bits(val)
    }
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TxPp {
    #[doc = "The preamble is composed of '1's"]
    ALL_ONE = 0x0,
    #[doc = "The preamble is composed of '0's"]
    ALL_ZERO = 0x01,
    #[doc = "The preamble is composed of '01's"]
    ZERO_ONE = 0x02,
    #[doc = "The preamble is composed of '10's"]
    ONE_ZERO = 0x03,
}
impl TxPp {
    #[inline(always)]
    pub const fn from_bits(val: u8) -> TxPp {
        unsafe { core::mem::transmute(val & 0x03) }
    }
    #[inline(always)]
    pub const fn to_bits(self) -> u8 {
        unsafe { core::mem::transmute(self) }
    }
}
impl From<u8> for TxPp {
    #[inline(always)]
    fn from(val: u8) -> TxPp {
        TxPp::from_bits(val)
    }
}
impl From<TxPp> for u8 {
    #[inline(always)]
    fn from(val: TxPp) -> u8 {
        TxPp::to_bits(val)
    }
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Wpkey(u32);
impl Wpkey {
    #[doc = "Writing any other value in this field aborts the write operation of the WPEN bit. Always reads as 0."]
    pub const PASSWD: Self = Self(0x0055_5341);
}
impl Wpkey {
    pub const fn from_bits(val: u32) -> Wpkey {
        Self(val & 0x00ff_ffff)
    }
    pub const fn to_bits(self) -> u32 {
        self.0
    }
}
impl core::fmt::Debug for Wpkey {
    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
        match self.0 {
            0x0055_5341 => f.write_str("PASSWD"),
            other => core::write!(f, "0x{:02X}", other),
        }
    }
}
#[cfg(feature = "defmt")]
impl defmt::Format for Wpkey {
    fn format(&self, f: defmt::Formatter) {
        match self.0 {
            0x0055_5341 => defmt::write!(f, "PASSWD"),
            other => defmt::write!(f, "0x{:02X}", other),
        }
    }
}
impl From<u32> for Wpkey {
    #[inline(always)]
    fn from(val: u32) -> Wpkey {
        Wpkey::from_bits(val)
    }
}
impl From<Wpkey> for u32 {
    #[inline(always)]
    fn from(val: Wpkey) -> u32 {
        Wpkey::to_bits(val)
    }
}