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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
#![doc = "Peripheral access API for BETRUSTED SOC microcontrollers (generated using svd2rust v0.17.0)\n\nYou can find an overview of the API [here].\n\n[here]: https://docs.rs/svd2rust/0.17.0/svd2rust/#peripheral-api"]
#![deny(const_err)]
#![deny(dead_code)]
#![deny(improper_ctypes)]
#![deny(legacy_directory_ownership)]
#![deny(missing_docs)]
#![deny(no_mangle_generic_items)]
#![deny(non_shorthand_field_patterns)]
#![deny(overflowing_literals)]
#![deny(path_statements)]
#![deny(patterns_in_fns_without_body)]
#![deny(plugin_as_library)]
#![deny(private_in_public)]
#![deny(safe_extern_statics)]
#![deny(unconditional_recursion)]
#![deny(unions_with_drop_fields)]
#![deny(unused_allocation)]
#![deny(unused_comparisons)]
#![deny(unused_parens)]
#![deny(while_true)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![no_std]
extern crate bare_metal;
extern crate riscv;
#[cfg(feature = "rt")]
extern crate riscv_rt;
extern crate vcell;
use core::marker::PhantomData;
use core::ops::Deref;
#[doc(hidden)]
pub mod interrupt;
pub use self::interrupt::Interrupt;
#[allow(unused_imports)]
use generic::*;
#[doc = r"Common register and bit access and modify traits"]
pub mod generic;
#[doc = "CTRL"]
pub struct CTRL {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for CTRL {}
impl CTRL {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const ctrl::RegisterBlock {
        0xf000_0000 as *const _
    }
}
impl Deref for CTRL {
    type Target = ctrl::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*CTRL::ptr() }
    }
}
#[doc = "CTRL"]
pub mod ctrl;
#[doc = "UART_PHY"]
pub struct UART_PHY {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for UART_PHY {}
impl UART_PHY {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const uart_phy::RegisterBlock {
        0xf000_1000 as *const _
    }
}
impl Deref for UART_PHY {
    type Target = uart_phy::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*UART_PHY::ptr() }
    }
}
#[doc = "UART_PHY"]
pub mod uart_phy;
#[doc = "UART"]
pub struct UART {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for UART {}
impl UART {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const uart::RegisterBlock {
        0xf000_1800 as *const _
    }
}
impl Deref for UART {
    type Target = uart::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*UART::ptr() }
    }
}
#[doc = "UART"]
pub mod uart;
#[doc = "IDENTIFIER_MEM"]
pub struct IDENTIFIER_MEM {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for IDENTIFIER_MEM {}
impl IDENTIFIER_MEM {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const identifier_mem::RegisterBlock {
        0xf000_2000 as *const _
    }
}
impl Deref for IDENTIFIER_MEM {
    type Target = identifier_mem::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*IDENTIFIER_MEM::ptr() }
    }
}
#[doc = "IDENTIFIER_MEM"]
pub mod identifier_mem;
#[doc = "TIMER0"]
pub struct TIMER0 {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for TIMER0 {}
impl TIMER0 {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const timer0::RegisterBlock {
        0xf000_2800 as *const _
    }
}
impl Deref for TIMER0 {
    type Target = timer0::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*TIMER0::ptr() }
    }
}
#[doc = "TIMER0"]
pub mod timer0;
#[doc = "REBOOT"]
pub struct REBOOT {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for REBOOT {}
impl REBOOT {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const reboot::RegisterBlock {
        0xf000_3000 as *const _
    }
}
impl Deref for REBOOT {
    type Target = reboot::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*REBOOT::ptr() }
    }
}
#[doc = "REBOOT"]
pub mod reboot;
#[doc = "CRG"]
pub struct CRG {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for CRG {}
impl CRG {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const crg::RegisterBlock {
        0xf000_3800 as *const _
    }
}
impl Deref for CRG {
    type Target = crg::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*CRG::ptr() }
    }
}
#[doc = "CRG"]
pub mod crg;
#[doc = "INFO"]
pub struct INFO {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for INFO {}
impl INFO {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const info::RegisterBlock {
        0xf000_4000 as *const _
    }
}
impl Deref for INFO {
    type Target = info::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*INFO::ptr() }
    }
}
#[doc = "INFO"]
pub mod info;
#[doc = "SRAM_EXT"]
pub struct SRAM_EXT {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for SRAM_EXT {}
impl SRAM_EXT {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const sram_ext::RegisterBlock {
        0xf000_4800 as *const _
    }
}
impl Deref for SRAM_EXT {
    type Target = sram_ext::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*SRAM_EXT::ptr() }
    }
}
#[doc = "SRAM_EXT"]
pub mod sram_ext;
#[doc = "MEMLCD"]
pub struct MEMLCD {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for MEMLCD {}
impl MEMLCD {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const memlcd::RegisterBlock {
        0xf000_5000 as *const _
    }
}
impl Deref for MEMLCD {
    type Target = memlcd::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*MEMLCD::ptr() }
    }
}
#[doc = "MEMLCD"]
pub mod memlcd;
#[doc = "COM"]
pub struct COM {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for COM {}
impl COM {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const com::RegisterBlock {
        0xf000_5800 as *const _
    }
}
impl Deref for COM {
    type Target = com::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*COM::ptr() }
    }
}
#[doc = "COM"]
pub mod com;
#[doc = "I2C"]
pub struct I2C {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for I2C {}
impl I2C {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const i2c::RegisterBlock {
        0xf000_6000 as *const _
    }
}
impl Deref for I2C {
    type Target = i2c::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*I2C::ptr() }
    }
}
#[doc = "I2C"]
pub mod i2c;
#[doc = "BTEVENTS"]
pub struct BTEVENTS {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for BTEVENTS {}
impl BTEVENTS {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const btevents::RegisterBlock {
        0xf000_6800 as *const _
    }
}
impl Deref for BTEVENTS {
    type Target = btevents::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*BTEVENTS::ptr() }
    }
}
#[doc = "BTEVENTS"]
pub mod btevents;
#[doc = "MESSIBLE"]
pub struct MESSIBLE {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for MESSIBLE {}
impl MESSIBLE {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const messible::RegisterBlock {
        0xf000_7000 as *const _
    }
}
impl Deref for MESSIBLE {
    type Target = messible::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*MESSIBLE::ptr() }
    }
}
#[doc = "MESSIBLE"]
pub mod messible;
#[doc = "TICKTIMER"]
pub struct TICKTIMER {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for TICKTIMER {}
impl TICKTIMER {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const ticktimer::RegisterBlock {
        0xf000_7800 as *const _
    }
}
impl Deref for TICKTIMER {
    type Target = ticktimer::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*TICKTIMER::ptr() }
    }
}
#[doc = "TICKTIMER"]
pub mod ticktimer;
#[doc = "POWER"]
pub struct POWER {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for POWER {}
impl POWER {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const power::RegisterBlock {
        0xf000_8000 as *const _
    }
}
impl Deref for POWER {
    type Target = power::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*POWER::ptr() }
    }
}
#[doc = "POWER"]
pub mod power;
#[doc = "SPINOR"]
pub struct SPINOR {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for SPINOR {}
impl SPINOR {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const spinor::RegisterBlock {
        0xf000_8800 as *const _
    }
}
impl Deref for SPINOR {
    type Target = spinor::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*SPINOR::ptr() }
    }
}
#[doc = "SPINOR"]
pub mod spinor;
#[doc = "KEYBOARD"]
pub struct KEYBOARD {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for KEYBOARD {}
impl KEYBOARD {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const keyboard::RegisterBlock {
        0xf000_9000 as *const _
    }
}
impl Deref for KEYBOARD {
    type Target = keyboard::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*KEYBOARD::ptr() }
    }
}
#[doc = "KEYBOARD"]
pub mod keyboard;
#[doc = "GPIO"]
pub struct GPIO {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for GPIO {}
impl GPIO {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const gpio::RegisterBlock {
        0xf000_9800 as *const _
    }
}
impl Deref for GPIO {
    type Target = gpio::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*GPIO::ptr() }
    }
}
#[doc = "GPIO"]
pub mod gpio;
#[doc = "SEED"]
pub struct SEED {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for SEED {}
impl SEED {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const seed::RegisterBlock {
        0xf000_a000 as *const _
    }
}
impl Deref for SEED {
    type Target = seed::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*SEED::ptr() }
    }
}
#[doc = "SEED"]
pub mod seed;
#[doc = "ROMTEST"]
pub struct ROMTEST {
    _marker: PhantomData<*const ()>,
}
unsafe impl Send for ROMTEST {}
impl ROMTEST {
    #[doc = r"Returns a pointer to the register block"]
    #[inline(always)]
    pub const fn ptr() -> *const romtest::RegisterBlock {
        0xf000_a800 as *const _
    }
}
impl Deref for ROMTEST {
    type Target = romtest::RegisterBlock;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { &*ROMTEST::ptr() }
    }
}
#[doc = "ROMTEST"]
pub mod romtest;
#[no_mangle]
static mut DEVICE_PERIPHERALS: bool = false;
#[doc = r"All the peripherals"]
#[allow(non_snake_case)]
pub struct Peripherals {
    #[doc = "CTRL"]
    pub CTRL: CTRL,
    #[doc = "UART_PHY"]
    pub UART_PHY: UART_PHY,
    #[doc = "UART"]
    pub UART: UART,
    #[doc = "IDENTIFIER_MEM"]
    pub IDENTIFIER_MEM: IDENTIFIER_MEM,
    #[doc = "TIMER0"]
    pub TIMER0: TIMER0,
    #[doc = "REBOOT"]
    pub REBOOT: REBOOT,
    #[doc = "CRG"]
    pub CRG: CRG,
    #[doc = "INFO"]
    pub INFO: INFO,
    #[doc = "SRAM_EXT"]
    pub SRAM_EXT: SRAM_EXT,
    #[doc = "MEMLCD"]
    pub MEMLCD: MEMLCD,
    #[doc = "COM"]
    pub COM: COM,
    #[doc = "I2C"]
    pub I2C: I2C,
    #[doc = "BTEVENTS"]
    pub BTEVENTS: BTEVENTS,
    #[doc = "MESSIBLE"]
    pub MESSIBLE: MESSIBLE,
    #[doc = "TICKTIMER"]
    pub TICKTIMER: TICKTIMER,
    #[doc = "POWER"]
    pub POWER: POWER,
    #[doc = "SPINOR"]
    pub SPINOR: SPINOR,
    #[doc = "KEYBOARD"]
    pub KEYBOARD: KEYBOARD,
    #[doc = "GPIO"]
    pub GPIO: GPIO,
    #[doc = "SEED"]
    pub SEED: SEED,
    #[doc = "ROMTEST"]
    pub ROMTEST: ROMTEST,
}
impl Peripherals {
    #[doc = r"Returns all the peripherals *once*"]
    #[inline]
    pub fn take() -> Option<Self> {
        riscv::interrupt::free(|_| {
            if unsafe { DEVICE_PERIPHERALS } {
                None
            } else {
                Some(unsafe { Peripherals::steal() })
            }
        })
    }
    #[doc = r"Unchecked version of `Peripherals::take`"]
    #[inline]
    pub unsafe fn steal() -> Self {
        DEVICE_PERIPHERALS = true;
        Peripherals {
            CTRL: CTRL {
                _marker: PhantomData,
            },
            UART_PHY: UART_PHY {
                _marker: PhantomData,
            },
            UART: UART {
                _marker: PhantomData,
            },
            IDENTIFIER_MEM: IDENTIFIER_MEM {
                _marker: PhantomData,
            },
            TIMER0: TIMER0 {
                _marker: PhantomData,
            },
            REBOOT: REBOOT {
                _marker: PhantomData,
            },
            CRG: CRG {
                _marker: PhantomData,
            },
            INFO: INFO {
                _marker: PhantomData,
            },
            SRAM_EXT: SRAM_EXT {
                _marker: PhantomData,
            },
            MEMLCD: MEMLCD {
                _marker: PhantomData,
            },
            COM: COM {
                _marker: PhantomData,
            },
            I2C: I2C {
                _marker: PhantomData,
            },
            BTEVENTS: BTEVENTS {
                _marker: PhantomData,
            },
            MESSIBLE: MESSIBLE {
                _marker: PhantomData,
            },
            TICKTIMER: TICKTIMER {
                _marker: PhantomData,
            },
            POWER: POWER {
                _marker: PhantomData,
            },
            SPINOR: SPINOR {
                _marker: PhantomData,
            },
            KEYBOARD: KEYBOARD {
                _marker: PhantomData,
            },
            GPIO: GPIO {
                _marker: PhantomData,
            },
            SEED: SEED {
                _marker: PhantomData,
            },
            ROMTEST: ROMTEST {
                _marker: PhantomData,
            },
        }
    }
}