k510_pac/
lib.rs

1#![doc = "Peripheral access API for K510 microcontrollers (generated using svd2rust v0.24.0 ( ))\n\nYou can find an overview of the generated API [here].\n\nAPI features to be included in the [next]
2svd2rust release can be generated by cloning the svd2rust [repository], checking out the above commit, and running `cargo doc --open`.\n\n[here]: https://docs.rs/svd2rust/0.24.0/svd2rust/#peripheral-api\n[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n[repository]: https://github.com/rust-embedded/svd2rust"]
3#![deny(const_err)]
4#![deny(dead_code)]
5#![deny(improper_ctypes)]
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(private_in_public)]
13#![deny(unconditional_recursion)]
14#![deny(unused_allocation)]
15#![deny(unused_comparisons)]
16#![deny(unused_parens)]
17#![deny(while_true)]
18#![allow(non_camel_case_types)]
19#![allow(non_snake_case)]
20#![no_std]
21use core::marker::PhantomData;
22use core::ops::Deref;
23#[allow(unused_imports)]
24use generic::*;
25#[doc = r"Common register and bit access and modify traits"]
26pub mod generic;
27#[cfg(feature = "rt")]
28extern "C" {
29    fn UART0();
30    fn UART1();
31    fn UART2();
32    fn UART3();
33    fn GPIO();
34    fn SYSCTL();
35}
36#[doc(hidden)]
37pub union Vector {
38    pub _handler: unsafe extern "C" fn(),
39    pub _reserved: usize,
40}
41#[cfg(feature = "rt")]
42#[doc(hidden)]
43#[no_mangle]
44pub static __EXTERNAL_INTERRUPTS: [Vector; 21] = [
45    Vector { _reserved: 0 },
46    Vector { _handler: UART0 },
47    Vector { _handler: UART1 },
48    Vector { _handler: UART2 },
49    Vector { _handler: UART3 },
50    Vector { _reserved: 0 },
51    Vector { _reserved: 0 },
52    Vector { _reserved: 0 },
53    Vector { _reserved: 0 },
54    Vector { _reserved: 0 },
55    Vector { _reserved: 0 },
56    Vector { _reserved: 0 },
57    Vector { _reserved: 0 },
58    Vector { _reserved: 0 },
59    Vector { _reserved: 0 },
60    Vector { _reserved: 0 },
61    Vector { _reserved: 0 },
62    Vector { _reserved: 0 },
63    Vector { _reserved: 0 },
64    Vector { _handler: GPIO },
65    Vector { _handler: SYSCTL },
66];
67#[doc(hidden)]
68pub mod interrupt;
69pub use self::interrupt::Interrupt;
70#[doc = "System Control"]
71pub struct SYSCTL {
72    _marker: PhantomData<*const ()>,
73}
74unsafe impl Send for SYSCTL {}
75impl SYSCTL {
76    #[doc = r"Pointer to the register block"]
77    pub const PTR: *const sysctl::RegisterBlock = 0x9700_0000 as *const _;
78    #[doc = r"Return the pointer to the register block"]
79    #[inline(always)]
80    pub const fn ptr() -> *const sysctl::RegisterBlock {
81        Self::PTR
82    }
83}
84impl Deref for SYSCTL {
85    type Target = sysctl::RegisterBlock;
86    #[inline(always)]
87    fn deref(&self) -> &Self::Target {
88        unsafe { &*Self::PTR }
89    }
90}
91impl core::fmt::Debug for SYSCTL {
92    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
93        f.debug_struct("SYSCTL").finish()
94    }
95}
96#[doc = "System Control"]
97pub mod sysctl;
98#[doc = "Universal Asynchronous Receivers/Transmitters"]
99pub struct UART0 {
100    _marker: PhantomData<*const ()>,
101}
102unsafe impl Send for UART0 {}
103impl UART0 {
104    #[doc = r"Pointer to the register block"]
105    pub const PTR: *const uart::RegisterBlock = 0x9600_0000 as *const _;
106    #[doc = r"Return the pointer to the register block"]
107    #[inline(always)]
108    pub const fn ptr() -> *const uart::RegisterBlock {
109        Self::PTR
110    }
111}
112impl Deref for UART0 {
113    type Target = uart::RegisterBlock;
114    #[inline(always)]
115    fn deref(&self) -> &Self::Target {
116        unsafe { &*Self::PTR }
117    }
118}
119impl core::fmt::Debug for UART0 {
120    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
121        f.debug_struct("UART0").finish()
122    }
123}
124#[doc = "Universal Asynchronous Receivers/Transmitters"]
125pub struct UART1 {
126    _marker: PhantomData<*const ()>,
127}
128unsafe impl Send for UART1 {}
129impl UART1 {
130    #[doc = r"Pointer to the register block"]
131    pub const PTR: *const uart::RegisterBlock = 0x9601_0000 as *const _;
132    #[doc = r"Return the pointer to the register block"]
133    #[inline(always)]
134    pub const fn ptr() -> *const uart::RegisterBlock {
135        Self::PTR
136    }
137}
138impl Deref for UART1 {
139    type Target = uart::RegisterBlock;
140    #[inline(always)]
141    fn deref(&self) -> &Self::Target {
142        unsafe { &*Self::PTR }
143    }
144}
145impl core::fmt::Debug for UART1 {
146    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
147        f.debug_struct("UART1").finish()
148    }
149}
150#[doc = "Universal Asynchronous Receivers/Transmitters"]
151pub struct UART2 {
152    _marker: PhantomData<*const ()>,
153}
154unsafe impl Send for UART2 {}
155impl UART2 {
156    #[doc = r"Pointer to the register block"]
157    pub const PTR: *const uart::RegisterBlock = 0x9602_0000 as *const _;
158    #[doc = r"Return the pointer to the register block"]
159    #[inline(always)]
160    pub const fn ptr() -> *const uart::RegisterBlock {
161        Self::PTR
162    }
163}
164impl Deref for UART2 {
165    type Target = uart::RegisterBlock;
166    #[inline(always)]
167    fn deref(&self) -> &Self::Target {
168        unsafe { &*Self::PTR }
169    }
170}
171impl core::fmt::Debug for UART2 {
172    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
173        f.debug_struct("UART2").finish()
174    }
175}
176#[doc = "Universal Asynchronous Receivers/Transmitters"]
177pub struct UART3 {
178    _marker: PhantomData<*const ()>,
179}
180unsafe impl Send for UART3 {}
181impl UART3 {
182    #[doc = r"Pointer to the register block"]
183    pub const PTR: *const uart::RegisterBlock = 0x9603_0000 as *const _;
184    #[doc = r"Return the pointer to the register block"]
185    #[inline(always)]
186    pub const fn ptr() -> *const uart::RegisterBlock {
187        Self::PTR
188    }
189}
190impl Deref for UART3 {
191    type Target = uart::RegisterBlock;
192    #[inline(always)]
193    fn deref(&self) -> &Self::Target {
194        unsafe { &*Self::PTR }
195    }
196}
197impl core::fmt::Debug for UART3 {
198    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
199        f.debug_struct("UART3").finish()
200    }
201}
202#[doc = "Universal Asynchronous Receivers/Transmitters"]
203pub mod uart;
204#[doc = "General Purpose I/O"]
205pub struct GPIO {
206    _marker: PhantomData<*const ()>,
207}
208unsafe impl Send for GPIO {}
209impl GPIO {
210    #[doc = r"Pointer to the register block"]
211    pub const PTR: *const gpio::RegisterBlock = 0x9705_0000 as *const _;
212    #[doc = r"Return the pointer to the register block"]
213    #[inline(always)]
214    pub const fn ptr() -> *const gpio::RegisterBlock {
215        Self::PTR
216    }
217}
218impl Deref for GPIO {
219    type Target = gpio::RegisterBlock;
220    #[inline(always)]
221    fn deref(&self) -> &Self::Target {
222        unsafe { &*Self::PTR }
223    }
224}
225impl core::fmt::Debug for GPIO {
226    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
227        f.debug_struct("GPIO").finish()
228    }
229}
230#[doc = "General Purpose I/O"]
231pub mod gpio;
232#[no_mangle]
233static mut DEVICE_PERIPHERALS: bool = false;
234#[doc = r"All the peripherals"]
235#[allow(non_snake_case)]
236pub struct Peripherals {
237    #[doc = "SYSCTL"]
238    pub SYSCTL: SYSCTL,
239    #[doc = "UART0"]
240    pub UART0: UART0,
241    #[doc = "UART1"]
242    pub UART1: UART1,
243    #[doc = "UART2"]
244    pub UART2: UART2,
245    #[doc = "UART3"]
246    pub UART3: UART3,
247    #[doc = "GPIO"]
248    pub GPIO: GPIO,
249}
250impl Peripherals {
251    #[doc = r"Returns all the peripherals *once*"]
252    #[inline]
253    pub fn take() -> Option<Self> {
254        riscv::interrupt::free(|_| {
255            if unsafe { DEVICE_PERIPHERALS } {
256                None
257            } else {
258                Some(unsafe { Peripherals::steal() })
259            }
260        })
261    }
262    #[doc = r"Unchecked version of `Peripherals::take`"]
263    #[inline]
264    pub unsafe fn steal() -> Self {
265        DEVICE_PERIPHERALS = true;
266        Peripherals {
267            SYSCTL: SYSCTL {
268                _marker: PhantomData,
269            },
270            UART0: UART0 {
271                _marker: PhantomData,
272            },
273            UART1: UART1 {
274                _marker: PhantomData,
275            },
276            UART2: UART2 {
277                _marker: PhantomData,
278            },
279            UART3: UART3 {
280                _marker: PhantomData,
281            },
282            GPIO: GPIO {
283                _marker: PhantomData,
284            },
285        }
286    }
287}