Skip to main content

betrusted_pac/
lib.rs

1#![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"]
2#![deny(const_err)]
3#![deny(dead_code)]
4#![deny(improper_ctypes)]
5#![deny(legacy_directory_ownership)]
6#![deny(missing_docs)]
7#![deny(no_mangle_generic_items)]
8#![deny(non_shorthand_field_patterns)]
9#![deny(overflowing_literals)]
10#![deny(path_statements)]
11#![deny(patterns_in_fns_without_body)]
12#![deny(plugin_as_library)]
13#![deny(private_in_public)]
14#![deny(safe_extern_statics)]
15#![deny(unconditional_recursion)]
16#![deny(unions_with_drop_fields)]
17#![deny(unused_allocation)]
18#![deny(unused_comparisons)]
19#![deny(unused_parens)]
20#![deny(while_true)]
21#![allow(non_camel_case_types)]
22#![allow(non_snake_case)]
23#![no_std]
24extern crate bare_metal;
25extern crate riscv;
26#[cfg(feature = "rt")]
27extern crate riscv_rt;
28extern crate vcell;
29use core::marker::PhantomData;
30use core::ops::Deref;
31#[doc(hidden)]
32pub mod interrupt;
33pub use self::interrupt::Interrupt;
34#[allow(unused_imports)]
35use generic::*;
36#[doc = r"Common register and bit access and modify traits"]
37pub mod generic;
38#[doc = "CTRL"]
39pub struct CTRL {
40    _marker: PhantomData<*const ()>,
41}
42unsafe impl Send for CTRL {}
43impl CTRL {
44    #[doc = r"Returns a pointer to the register block"]
45    #[inline(always)]
46    pub const fn ptr() -> *const ctrl::RegisterBlock {
47        0xf000_0000 as *const _
48    }
49}
50impl Deref for CTRL {
51    type Target = ctrl::RegisterBlock;
52    #[inline(always)]
53    fn deref(&self) -> &Self::Target {
54        unsafe { &*CTRL::ptr() }
55    }
56}
57#[doc = "CTRL"]
58pub mod ctrl;
59#[doc = "UART_PHY"]
60pub struct UART_PHY {
61    _marker: PhantomData<*const ()>,
62}
63unsafe impl Send for UART_PHY {}
64impl UART_PHY {
65    #[doc = r"Returns a pointer to the register block"]
66    #[inline(always)]
67    pub const fn ptr() -> *const uart_phy::RegisterBlock {
68        0xf000_1000 as *const _
69    }
70}
71impl Deref for UART_PHY {
72    type Target = uart_phy::RegisterBlock;
73    #[inline(always)]
74    fn deref(&self) -> &Self::Target {
75        unsafe { &*UART_PHY::ptr() }
76    }
77}
78#[doc = "UART_PHY"]
79pub mod uart_phy;
80#[doc = "UART"]
81pub struct UART {
82    _marker: PhantomData<*const ()>,
83}
84unsafe impl Send for UART {}
85impl UART {
86    #[doc = r"Returns a pointer to the register block"]
87    #[inline(always)]
88    pub const fn ptr() -> *const uart::RegisterBlock {
89        0xf000_1800 as *const _
90    }
91}
92impl Deref for UART {
93    type Target = uart::RegisterBlock;
94    #[inline(always)]
95    fn deref(&self) -> &Self::Target {
96        unsafe { &*UART::ptr() }
97    }
98}
99#[doc = "UART"]
100pub mod uart;
101#[doc = "IDENTIFIER_MEM"]
102pub struct IDENTIFIER_MEM {
103    _marker: PhantomData<*const ()>,
104}
105unsafe impl Send for IDENTIFIER_MEM {}
106impl IDENTIFIER_MEM {
107    #[doc = r"Returns a pointer to the register block"]
108    #[inline(always)]
109    pub const fn ptr() -> *const identifier_mem::RegisterBlock {
110        0xf000_2000 as *const _
111    }
112}
113impl Deref for IDENTIFIER_MEM {
114    type Target = identifier_mem::RegisterBlock;
115    #[inline(always)]
116    fn deref(&self) -> &Self::Target {
117        unsafe { &*IDENTIFIER_MEM::ptr() }
118    }
119}
120#[doc = "IDENTIFIER_MEM"]
121pub mod identifier_mem;
122#[doc = "TIMER0"]
123pub struct TIMER0 {
124    _marker: PhantomData<*const ()>,
125}
126unsafe impl Send for TIMER0 {}
127impl TIMER0 {
128    #[doc = r"Returns a pointer to the register block"]
129    #[inline(always)]
130    pub const fn ptr() -> *const timer0::RegisterBlock {
131        0xf000_2800 as *const _
132    }
133}
134impl Deref for TIMER0 {
135    type Target = timer0::RegisterBlock;
136    #[inline(always)]
137    fn deref(&self) -> &Self::Target {
138        unsafe { &*TIMER0::ptr() }
139    }
140}
141#[doc = "TIMER0"]
142pub mod timer0;
143#[doc = "REBOOT"]
144pub struct REBOOT {
145    _marker: PhantomData<*const ()>,
146}
147unsafe impl Send for REBOOT {}
148impl REBOOT {
149    #[doc = r"Returns a pointer to the register block"]
150    #[inline(always)]
151    pub const fn ptr() -> *const reboot::RegisterBlock {
152        0xf000_3000 as *const _
153    }
154}
155impl Deref for REBOOT {
156    type Target = reboot::RegisterBlock;
157    #[inline(always)]
158    fn deref(&self) -> &Self::Target {
159        unsafe { &*REBOOT::ptr() }
160    }
161}
162#[doc = "REBOOT"]
163pub mod reboot;
164#[doc = "CRG"]
165pub struct CRG {
166    _marker: PhantomData<*const ()>,
167}
168unsafe impl Send for CRG {}
169impl CRG {
170    #[doc = r"Returns a pointer to the register block"]
171    #[inline(always)]
172    pub const fn ptr() -> *const crg::RegisterBlock {
173        0xf000_3800 as *const _
174    }
175}
176impl Deref for CRG {
177    type Target = crg::RegisterBlock;
178    #[inline(always)]
179    fn deref(&self) -> &Self::Target {
180        unsafe { &*CRG::ptr() }
181    }
182}
183#[doc = "CRG"]
184pub mod crg;
185#[doc = "INFO"]
186pub struct INFO {
187    _marker: PhantomData<*const ()>,
188}
189unsafe impl Send for INFO {}
190impl INFO {
191    #[doc = r"Returns a pointer to the register block"]
192    #[inline(always)]
193    pub const fn ptr() -> *const info::RegisterBlock {
194        0xf000_4000 as *const _
195    }
196}
197impl Deref for INFO {
198    type Target = info::RegisterBlock;
199    #[inline(always)]
200    fn deref(&self) -> &Self::Target {
201        unsafe { &*INFO::ptr() }
202    }
203}
204#[doc = "INFO"]
205pub mod info;
206#[doc = "SRAM_EXT"]
207pub struct SRAM_EXT {
208    _marker: PhantomData<*const ()>,
209}
210unsafe impl Send for SRAM_EXT {}
211impl SRAM_EXT {
212    #[doc = r"Returns a pointer to the register block"]
213    #[inline(always)]
214    pub const fn ptr() -> *const sram_ext::RegisterBlock {
215        0xf000_4800 as *const _
216    }
217}
218impl Deref for SRAM_EXT {
219    type Target = sram_ext::RegisterBlock;
220    #[inline(always)]
221    fn deref(&self) -> &Self::Target {
222        unsafe { &*SRAM_EXT::ptr() }
223    }
224}
225#[doc = "SRAM_EXT"]
226pub mod sram_ext;
227#[doc = "MEMLCD"]
228pub struct MEMLCD {
229    _marker: PhantomData<*const ()>,
230}
231unsafe impl Send for MEMLCD {}
232impl MEMLCD {
233    #[doc = r"Returns a pointer to the register block"]
234    #[inline(always)]
235    pub const fn ptr() -> *const memlcd::RegisterBlock {
236        0xf000_5000 as *const _
237    }
238}
239impl Deref for MEMLCD {
240    type Target = memlcd::RegisterBlock;
241    #[inline(always)]
242    fn deref(&self) -> &Self::Target {
243        unsafe { &*MEMLCD::ptr() }
244    }
245}
246#[doc = "MEMLCD"]
247pub mod memlcd;
248#[doc = "COM"]
249pub struct COM {
250    _marker: PhantomData<*const ()>,
251}
252unsafe impl Send for COM {}
253impl COM {
254    #[doc = r"Returns a pointer to the register block"]
255    #[inline(always)]
256    pub const fn ptr() -> *const com::RegisterBlock {
257        0xf000_5800 as *const _
258    }
259}
260impl Deref for COM {
261    type Target = com::RegisterBlock;
262    #[inline(always)]
263    fn deref(&self) -> &Self::Target {
264        unsafe { &*COM::ptr() }
265    }
266}
267#[doc = "COM"]
268pub mod com;
269#[doc = "I2C"]
270pub struct I2C {
271    _marker: PhantomData<*const ()>,
272}
273unsafe impl Send for I2C {}
274impl I2C {
275    #[doc = r"Returns a pointer to the register block"]
276    #[inline(always)]
277    pub const fn ptr() -> *const i2c::RegisterBlock {
278        0xf000_6000 as *const _
279    }
280}
281impl Deref for I2C {
282    type Target = i2c::RegisterBlock;
283    #[inline(always)]
284    fn deref(&self) -> &Self::Target {
285        unsafe { &*I2C::ptr() }
286    }
287}
288#[doc = "I2C"]
289pub mod i2c;
290#[doc = "BTEVENTS"]
291pub struct BTEVENTS {
292    _marker: PhantomData<*const ()>,
293}
294unsafe impl Send for BTEVENTS {}
295impl BTEVENTS {
296    #[doc = r"Returns a pointer to the register block"]
297    #[inline(always)]
298    pub const fn ptr() -> *const btevents::RegisterBlock {
299        0xf000_6800 as *const _
300    }
301}
302impl Deref for BTEVENTS {
303    type Target = btevents::RegisterBlock;
304    #[inline(always)]
305    fn deref(&self) -> &Self::Target {
306        unsafe { &*BTEVENTS::ptr() }
307    }
308}
309#[doc = "BTEVENTS"]
310pub mod btevents;
311#[doc = "MESSIBLE"]
312pub struct MESSIBLE {
313    _marker: PhantomData<*const ()>,
314}
315unsafe impl Send for MESSIBLE {}
316impl MESSIBLE {
317    #[doc = r"Returns a pointer to the register block"]
318    #[inline(always)]
319    pub const fn ptr() -> *const messible::RegisterBlock {
320        0xf000_7000 as *const _
321    }
322}
323impl Deref for MESSIBLE {
324    type Target = messible::RegisterBlock;
325    #[inline(always)]
326    fn deref(&self) -> &Self::Target {
327        unsafe { &*MESSIBLE::ptr() }
328    }
329}
330#[doc = "MESSIBLE"]
331pub mod messible;
332#[doc = "TICKTIMER"]
333pub struct TICKTIMER {
334    _marker: PhantomData<*const ()>,
335}
336unsafe impl Send for TICKTIMER {}
337impl TICKTIMER {
338    #[doc = r"Returns a pointer to the register block"]
339    #[inline(always)]
340    pub const fn ptr() -> *const ticktimer::RegisterBlock {
341        0xf000_7800 as *const _
342    }
343}
344impl Deref for TICKTIMER {
345    type Target = ticktimer::RegisterBlock;
346    #[inline(always)]
347    fn deref(&self) -> &Self::Target {
348        unsafe { &*TICKTIMER::ptr() }
349    }
350}
351#[doc = "TICKTIMER"]
352pub mod ticktimer;
353#[doc = "POWER"]
354pub struct POWER {
355    _marker: PhantomData<*const ()>,
356}
357unsafe impl Send for POWER {}
358impl POWER {
359    #[doc = r"Returns a pointer to the register block"]
360    #[inline(always)]
361    pub const fn ptr() -> *const power::RegisterBlock {
362        0xf000_8000 as *const _
363    }
364}
365impl Deref for POWER {
366    type Target = power::RegisterBlock;
367    #[inline(always)]
368    fn deref(&self) -> &Self::Target {
369        unsafe { &*POWER::ptr() }
370    }
371}
372#[doc = "POWER"]
373pub mod power;
374#[doc = "SPINOR"]
375pub struct SPINOR {
376    _marker: PhantomData<*const ()>,
377}
378unsafe impl Send for SPINOR {}
379impl SPINOR {
380    #[doc = r"Returns a pointer to the register block"]
381    #[inline(always)]
382    pub const fn ptr() -> *const spinor::RegisterBlock {
383        0xf000_8800 as *const _
384    }
385}
386impl Deref for SPINOR {
387    type Target = spinor::RegisterBlock;
388    #[inline(always)]
389    fn deref(&self) -> &Self::Target {
390        unsafe { &*SPINOR::ptr() }
391    }
392}
393#[doc = "SPINOR"]
394pub mod spinor;
395#[doc = "KEYBOARD"]
396pub struct KEYBOARD {
397    _marker: PhantomData<*const ()>,
398}
399unsafe impl Send for KEYBOARD {}
400impl KEYBOARD {
401    #[doc = r"Returns a pointer to the register block"]
402    #[inline(always)]
403    pub const fn ptr() -> *const keyboard::RegisterBlock {
404        0xf000_9000 as *const _
405    }
406}
407impl Deref for KEYBOARD {
408    type Target = keyboard::RegisterBlock;
409    #[inline(always)]
410    fn deref(&self) -> &Self::Target {
411        unsafe { &*KEYBOARD::ptr() }
412    }
413}
414#[doc = "KEYBOARD"]
415pub mod keyboard;
416#[doc = "GPIO"]
417pub struct GPIO {
418    _marker: PhantomData<*const ()>,
419}
420unsafe impl Send for GPIO {}
421impl GPIO {
422    #[doc = r"Returns a pointer to the register block"]
423    #[inline(always)]
424    pub const fn ptr() -> *const gpio::RegisterBlock {
425        0xf000_9800 as *const _
426    }
427}
428impl Deref for GPIO {
429    type Target = gpio::RegisterBlock;
430    #[inline(always)]
431    fn deref(&self) -> &Self::Target {
432        unsafe { &*GPIO::ptr() }
433    }
434}
435#[doc = "GPIO"]
436pub mod gpio;
437#[doc = "SEED"]
438pub struct SEED {
439    _marker: PhantomData<*const ()>,
440}
441unsafe impl Send for SEED {}
442impl SEED {
443    #[doc = r"Returns a pointer to the register block"]
444    #[inline(always)]
445    pub const fn ptr() -> *const seed::RegisterBlock {
446        0xf000_a000 as *const _
447    }
448}
449impl Deref for SEED {
450    type Target = seed::RegisterBlock;
451    #[inline(always)]
452    fn deref(&self) -> &Self::Target {
453        unsafe { &*SEED::ptr() }
454    }
455}
456#[doc = "SEED"]
457pub mod seed;
458#[doc = "ROMTEST"]
459pub struct ROMTEST {
460    _marker: PhantomData<*const ()>,
461}
462unsafe impl Send for ROMTEST {}
463impl ROMTEST {
464    #[doc = r"Returns a pointer to the register block"]
465    #[inline(always)]
466    pub const fn ptr() -> *const romtest::RegisterBlock {
467        0xf000_a800 as *const _
468    }
469}
470impl Deref for ROMTEST {
471    type Target = romtest::RegisterBlock;
472    #[inline(always)]
473    fn deref(&self) -> &Self::Target {
474        unsafe { &*ROMTEST::ptr() }
475    }
476}
477#[doc = "ROMTEST"]
478pub mod romtest;
479#[no_mangle]
480static mut DEVICE_PERIPHERALS: bool = false;
481#[doc = r"All the peripherals"]
482#[allow(non_snake_case)]
483pub struct Peripherals {
484    #[doc = "CTRL"]
485    pub CTRL: CTRL,
486    #[doc = "UART_PHY"]
487    pub UART_PHY: UART_PHY,
488    #[doc = "UART"]
489    pub UART: UART,
490    #[doc = "IDENTIFIER_MEM"]
491    pub IDENTIFIER_MEM: IDENTIFIER_MEM,
492    #[doc = "TIMER0"]
493    pub TIMER0: TIMER0,
494    #[doc = "REBOOT"]
495    pub REBOOT: REBOOT,
496    #[doc = "CRG"]
497    pub CRG: CRG,
498    #[doc = "INFO"]
499    pub INFO: INFO,
500    #[doc = "SRAM_EXT"]
501    pub SRAM_EXT: SRAM_EXT,
502    #[doc = "MEMLCD"]
503    pub MEMLCD: MEMLCD,
504    #[doc = "COM"]
505    pub COM: COM,
506    #[doc = "I2C"]
507    pub I2C: I2C,
508    #[doc = "BTEVENTS"]
509    pub BTEVENTS: BTEVENTS,
510    #[doc = "MESSIBLE"]
511    pub MESSIBLE: MESSIBLE,
512    #[doc = "TICKTIMER"]
513    pub TICKTIMER: TICKTIMER,
514    #[doc = "POWER"]
515    pub POWER: POWER,
516    #[doc = "SPINOR"]
517    pub SPINOR: SPINOR,
518    #[doc = "KEYBOARD"]
519    pub KEYBOARD: KEYBOARD,
520    #[doc = "GPIO"]
521    pub GPIO: GPIO,
522    #[doc = "SEED"]
523    pub SEED: SEED,
524    #[doc = "ROMTEST"]
525    pub ROMTEST: ROMTEST,
526}
527impl Peripherals {
528    #[doc = r"Returns all the peripherals *once*"]
529    #[inline]
530    pub fn take() -> Option<Self> {
531        riscv::interrupt::free(|_| {
532            if unsafe { DEVICE_PERIPHERALS } {
533                None
534            } else {
535                Some(unsafe { Peripherals::steal() })
536            }
537        })
538    }
539    #[doc = r"Unchecked version of `Peripherals::take`"]
540    #[inline]
541    pub unsafe fn steal() -> Self {
542        DEVICE_PERIPHERALS = true;
543        Peripherals {
544            CTRL: CTRL {
545                _marker: PhantomData,
546            },
547            UART_PHY: UART_PHY {
548                _marker: PhantomData,
549            },
550            UART: UART {
551                _marker: PhantomData,
552            },
553            IDENTIFIER_MEM: IDENTIFIER_MEM {
554                _marker: PhantomData,
555            },
556            TIMER0: TIMER0 {
557                _marker: PhantomData,
558            },
559            REBOOT: REBOOT {
560                _marker: PhantomData,
561            },
562            CRG: CRG {
563                _marker: PhantomData,
564            },
565            INFO: INFO {
566                _marker: PhantomData,
567            },
568            SRAM_EXT: SRAM_EXT {
569                _marker: PhantomData,
570            },
571            MEMLCD: MEMLCD {
572                _marker: PhantomData,
573            },
574            COM: COM {
575                _marker: PhantomData,
576            },
577            I2C: I2C {
578                _marker: PhantomData,
579            },
580            BTEVENTS: BTEVENTS {
581                _marker: PhantomData,
582            },
583            MESSIBLE: MESSIBLE {
584                _marker: PhantomData,
585            },
586            TICKTIMER: TICKTIMER {
587                _marker: PhantomData,
588            },
589            POWER: POWER {
590                _marker: PhantomData,
591            },
592            SPINOR: SPINOR {
593                _marker: PhantomData,
594            },
595            KEYBOARD: KEYBOARD {
596                _marker: PhantomData,
597            },
598            GPIO: GPIO {
599                _marker: PhantomData,
600            },
601            SEED: SEED {
602                _marker: PhantomData,
603            },
604            ROMTEST: ROMTEST {
605                _marker: PhantomData,
606            },
607        }
608    }
609}