esp32s2_ulp/
lib.rs

1#![doc = "Peripheral access API for ESP32-S2-ULP microcontrollers (generated using svd2rust v0.33.4 ( ))\n\nYou can find an overview of the generated API [here].\n\nAPI features to be included in the [next] svd2rust 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.33.4/svd2rust/#peripheral-api\n[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n[repository]: https://github.com/rust-embedded/svd2rust"]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/46717278")]
5#![no_std]
6use core::marker::PhantomData;
7use core::ops::Deref;
8#[doc = r"Number available in the NVIC for configuring priority"]
9pub const NVIC_PRIO_BITS: u8 = 4;
10#[allow(unused_imports)]
11use generic::*;
12#[doc = r"Common register and bit access and modify traits"]
13pub mod generic;
14#[cfg(feature = "rt")]
15extern "C" {
16    fn TOUCH_DONE_INT();
17    fn TOUCH_INACTIVE_INT();
18    fn TOUCH_ACTIVE_INT();
19    fn SARADC1_DONE_INT();
20    fn SARADC2_DONE_INT();
21    fn TSENS_DONE_INT();
22    fn RISCV_START_INT();
23    fn SW_INT();
24    fn SWD_INT();
25}
26#[doc(hidden)]
27#[repr(C)]
28pub union Vector {
29    pub _handler: unsafe extern "C" fn(),
30    pub _reserved: usize,
31}
32#[cfg(feature = "rt")]
33#[doc(hidden)]
34#[link_section = ".rwtext"]
35#[no_mangle]
36pub static __EXTERNAL_INTERRUPTS: [Vector; 9] = [
37    Vector {
38        _handler: TOUCH_DONE_INT,
39    },
40    Vector {
41        _handler: TOUCH_INACTIVE_INT,
42    },
43    Vector {
44        _handler: TOUCH_ACTIVE_INT,
45    },
46    Vector {
47        _handler: SARADC1_DONE_INT,
48    },
49    Vector {
50        _handler: SARADC2_DONE_INT,
51    },
52    Vector {
53        _handler: TSENS_DONE_INT,
54    },
55    Vector {
56        _handler: RISCV_START_INT,
57    },
58    Vector { _handler: SW_INT },
59    Vector { _handler: SWD_INT },
60];
61#[doc(hidden)]
62pub mod interrupt;
63pub use self::interrupt::Interrupt;
64#[doc = "Low-power Input/Output"]
65pub struct RTC_IO {
66    _marker: PhantomData<*const ()>,
67}
68unsafe impl Send for RTC_IO {}
69impl RTC_IO {
70    #[doc = r"Pointer to the register block"]
71    pub const PTR: *const rtc_io::RegisterBlock = 0xa400 as *const _;
72    #[doc = r"Return the pointer to the register block"]
73    #[inline(always)]
74    pub const fn ptr() -> *const rtc_io::RegisterBlock {
75        Self::PTR
76    }
77    #[doc = r" Steal an instance of this peripheral"]
78    #[doc = r""]
79    #[doc = r" # Safety"]
80    #[doc = r""]
81    #[doc = r" Ensure that the new instance of the peripheral cannot be used in a way"]
82    #[doc = r" that may race with any existing instances, for example by only"]
83    #[doc = r" accessing read-only or write-only registers, or by consuming the"]
84    #[doc = r" original peripheral and using critical sections to coordinate"]
85    #[doc = r" access between multiple new instances."]
86    #[doc = r""]
87    #[doc = r" Additionally, other software such as HALs may rely on only one"]
88    #[doc = r" peripheral instance existing to ensure memory safety; ensure"]
89    #[doc = r" no stolen instances are passed to such software."]
90    pub unsafe fn steal() -> Self {
91        Self {
92            _marker: PhantomData,
93        }
94    }
95}
96impl Deref for RTC_IO {
97    type Target = rtc_io::RegisterBlock;
98    #[inline(always)]
99    fn deref(&self) -> &Self::Target {
100        unsafe { &*Self::PTR }
101    }
102}
103impl core::fmt::Debug for RTC_IO {
104    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
105        f.debug_struct("RTC_IO").finish()
106    }
107}
108#[doc = "Low-power Input/Output"]
109pub mod rtc_io;
110#[doc = "Real-Time Clock Control"]
111pub struct RTC_CNTL {
112    _marker: PhantomData<*const ()>,
113}
114unsafe impl Send for RTC_CNTL {}
115impl RTC_CNTL {
116    #[doc = r"Pointer to the register block"]
117    pub const PTR: *const rtc_cntl::RegisterBlock = 0x8000 as *const _;
118    #[doc = r"Return the pointer to the register block"]
119    #[inline(always)]
120    pub const fn ptr() -> *const rtc_cntl::RegisterBlock {
121        Self::PTR
122    }
123    #[doc = r" Steal an instance of this peripheral"]
124    #[doc = r""]
125    #[doc = r" # Safety"]
126    #[doc = r""]
127    #[doc = r" Ensure that the new instance of the peripheral cannot be used in a way"]
128    #[doc = r" that may race with any existing instances, for example by only"]
129    #[doc = r" accessing read-only or write-only registers, or by consuming the"]
130    #[doc = r" original peripheral and using critical sections to coordinate"]
131    #[doc = r" access between multiple new instances."]
132    #[doc = r""]
133    #[doc = r" Additionally, other software such as HALs may rely on only one"]
134    #[doc = r" peripheral instance existing to ensure memory safety; ensure"]
135    #[doc = r" no stolen instances are passed to such software."]
136    pub unsafe fn steal() -> Self {
137        Self {
138            _marker: PhantomData,
139        }
140    }
141}
142impl Deref for RTC_CNTL {
143    type Target = rtc_cntl::RegisterBlock;
144    #[inline(always)]
145    fn deref(&self) -> &Self::Target {
146        unsafe { &*Self::PTR }
147    }
148}
149impl core::fmt::Debug for RTC_CNTL {
150    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
151        f.debug_struct("RTC_CNTL").finish()
152    }
153}
154#[doc = "Real-Time Clock Control"]
155pub mod rtc_cntl;
156#[doc = "Low-power I2C (Inter-Integrated Circuit) Controller"]
157pub struct RTC_I2C {
158    _marker: PhantomData<*const ()>,
159}
160unsafe impl Send for RTC_I2C {}
161impl RTC_I2C {
162    #[doc = r"Pointer to the register block"]
163    pub const PTR: *const rtc_i2c::RegisterBlock = 0xec00 as *const _;
164    #[doc = r"Return the pointer to the register block"]
165    #[inline(always)]
166    pub const fn ptr() -> *const rtc_i2c::RegisterBlock {
167        Self::PTR
168    }
169    #[doc = r" Steal an instance of this peripheral"]
170    #[doc = r""]
171    #[doc = r" # Safety"]
172    #[doc = r""]
173    #[doc = r" Ensure that the new instance of the peripheral cannot be used in a way"]
174    #[doc = r" that may race with any existing instances, for example by only"]
175    #[doc = r" accessing read-only or write-only registers, or by consuming the"]
176    #[doc = r" original peripheral and using critical sections to coordinate"]
177    #[doc = r" access between multiple new instances."]
178    #[doc = r""]
179    #[doc = r" Additionally, other software such as HALs may rely on only one"]
180    #[doc = r" peripheral instance existing to ensure memory safety; ensure"]
181    #[doc = r" no stolen instances are passed to such software."]
182    pub unsafe fn steal() -> Self {
183        Self {
184            _marker: PhantomData,
185        }
186    }
187}
188impl Deref for RTC_I2C {
189    type Target = rtc_i2c::RegisterBlock;
190    #[inline(always)]
191    fn deref(&self) -> &Self::Target {
192        unsafe { &*Self::PTR }
193    }
194}
195impl core::fmt::Debug for RTC_I2C {
196    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
197        f.debug_struct("RTC_I2C").finish()
198    }
199}
200#[doc = "Low-power I2C (Inter-Integrated Circuit) Controller"]
201pub mod rtc_i2c;
202#[doc = "SENS Peripheral"]
203pub struct SENS {
204    _marker: PhantomData<*const ()>,
205}
206unsafe impl Send for SENS {}
207impl SENS {
208    #[doc = r"Pointer to the register block"]
209    pub const PTR: *const sens::RegisterBlock = 0xc800 as *const _;
210    #[doc = r"Return the pointer to the register block"]
211    #[inline(always)]
212    pub const fn ptr() -> *const sens::RegisterBlock {
213        Self::PTR
214    }
215    #[doc = r" Steal an instance of this peripheral"]
216    #[doc = r""]
217    #[doc = r" # Safety"]
218    #[doc = r""]
219    #[doc = r" Ensure that the new instance of the peripheral cannot be used in a way"]
220    #[doc = r" that may race with any existing instances, for example by only"]
221    #[doc = r" accessing read-only or write-only registers, or by consuming the"]
222    #[doc = r" original peripheral and using critical sections to coordinate"]
223    #[doc = r" access between multiple new instances."]
224    #[doc = r""]
225    #[doc = r" Additionally, other software such as HALs may rely on only one"]
226    #[doc = r" peripheral instance existing to ensure memory safety; ensure"]
227    #[doc = r" no stolen instances are passed to such software."]
228    pub unsafe fn steal() -> Self {
229        Self {
230            _marker: PhantomData,
231        }
232    }
233}
234impl Deref for SENS {
235    type Target = sens::RegisterBlock;
236    #[inline(always)]
237    fn deref(&self) -> &Self::Target {
238        unsafe { &*Self::PTR }
239    }
240}
241impl core::fmt::Debug for SENS {
242    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
243        f.debug_struct("SENS").finish()
244    }
245}
246#[doc = "SENS Peripheral"]
247pub mod sens;
248#[no_mangle]
249static mut DEVICE_PERIPHERALS: bool = false;
250#[doc = r" All the peripherals."]
251#[allow(non_snake_case)]
252pub struct Peripherals {
253    #[doc = "RTC_IO"]
254    pub RTC_IO: RTC_IO,
255    #[doc = "RTC_CNTL"]
256    pub RTC_CNTL: RTC_CNTL,
257    #[doc = "RTC_I2C"]
258    pub RTC_I2C: RTC_I2C,
259    #[doc = "SENS"]
260    pub SENS: SENS,
261}
262impl Peripherals {
263    #[doc = r" Returns all the peripherals *once*."]
264    #[cfg(feature = "critical-section")]
265    #[inline]
266    pub fn take() -> Option<Self> {
267        critical_section::with(|_| {
268            if unsafe { DEVICE_PERIPHERALS } {
269                return None;
270            }
271            Some(unsafe { Peripherals::steal() })
272        })
273    }
274    #[doc = r" Unchecked version of `Peripherals::take`."]
275    #[doc = r""]
276    #[doc = r" # Safety"]
277    #[doc = r""]
278    #[doc = r" Each of the returned peripherals must be used at most once."]
279    #[inline]
280    pub unsafe fn steal() -> Self {
281        DEVICE_PERIPHERALS = true;
282        Peripherals {
283            RTC_IO: RTC_IO::steal(),
284            RTC_CNTL: RTC_CNTL::steal(),
285            RTC_I2C: RTC_I2C::steal(),
286            SENS: SENS::steal(),
287        }
288    }
289}