esp8266/
lib.rs

1#![doc = "Peripheral access API for ESP8266 microcontrollers (generated using svd2rust v0.22.2 ( ))\n\nYou can find an overview of the generated API [here]
2.\n\nAPI features to be included in the [next]
3 svd2rust release can be generated by cloning the svd2rust [repository]
4, checking out the above commit, and running `cargo doc --open`.\n\n[here]
5: https://docs.rs/svd2rust/0.22.2/svd2rust/#peripheral-api\n[next]
6: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n[repository]
7: https://github.com/rust-embedded/svd2rust"]
8#![deny(const_err)]
9#![deny(dead_code)]
10#![deny(improper_ctypes)]
11#![deny(missing_docs)]
12#![deny(no_mangle_generic_items)]
13#![deny(non_shorthand_field_patterns)]
14#![deny(overflowing_literals)]
15#![deny(path_statements)]
16#![deny(patterns_in_fns_without_body)]
17#![deny(private_in_public)]
18#![deny(unconditional_recursion)]
19#![deny(unused_allocation)]
20#![deny(unused_comparisons)]
21#![deny(unused_parens)]
22#![deny(while_true)]
23#![allow(non_camel_case_types)]
24#![allow(non_snake_case)]
25#![no_std]
26use core::marker::PhantomData;
27use core::ops::Deref;
28#[doc = r"Number available in the NVIC for configuring priority"]
29pub const NVIC_PRIO_BITS: u8 = 3;
30#[allow(unused_imports)]
31use generic::*;
32#[doc = r"Common register and bit access and modify traits"]
33pub mod generic;
34#[cfg(feature = "rt")]
35extern "C" {}
36#[doc(hidden)]
37pub union Vector {
38    pub _handler: unsafe extern "C" fn(),
39    _reserved: u32,
40}
41#[cfg(feature = "rt")]
42#[doc(hidden)]
43pub static __INTERRUPTS: [Vector; 0] = [];
44#[doc = r"Enumeration of all the interrupts."]
45#[derive(Copy, Clone, Debug, PartialEq, Eq)]
46pub enum Interrupt {}
47unsafe impl xtensa_lx::interrupt::InterruptNumber for Interrupt {
48    #[inline(always)]
49    fn number(self) -> u16 {
50        match self {}
51    }
52}
53#[doc = r" TryFromInterruptError"]
54#[derive(Debug, Copy, Clone)]
55pub struct TryFromInterruptError(());
56impl Interrupt {
57    #[doc = r" Attempt to convert a given value into an `Interrupt`"]
58    #[inline]
59    pub fn try_from(value: u16) -> Result<Self, TryFromInterruptError> {
60        match value {
61            _ => Err(TryFromInterruptError(())),
62        }
63    }
64}
65#[doc = "DPORT"]
66pub struct DPORT {
67    _marker: PhantomData<*const ()>,
68}
69unsafe impl Send for DPORT {}
70impl DPORT {
71    #[doc = r"Pointer to the register block"]
72    pub const PTR: *const dport::RegisterBlock = 0x3ff0_0000 as *const _;
73    #[doc = r"Return the pointer to the register block"]
74    #[inline(always)]
75    pub const fn ptr() -> *const dport::RegisterBlock {
76        Self::PTR
77    }
78}
79impl Deref for DPORT {
80    type Target = dport::RegisterBlock;
81    #[inline(always)]
82    fn deref(&self) -> &Self::Target {
83        unsafe { &*Self::PTR }
84    }
85}
86impl core::fmt::Debug for DPORT {
87    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
88        f.debug_struct("DPORT").finish()
89    }
90}
91#[doc = "DPORT"]
92pub mod dport;
93#[doc = "EFUSE"]
94pub struct EFUSE {
95    _marker: PhantomData<*const ()>,
96}
97unsafe impl Send for EFUSE {}
98impl EFUSE {
99    #[doc = r"Pointer to the register block"]
100    pub const PTR: *const efuse::RegisterBlock = 0x3ff0_0050 as *const _;
101    #[doc = r"Return the pointer to the register block"]
102    #[inline(always)]
103    pub const fn ptr() -> *const efuse::RegisterBlock {
104        Self::PTR
105    }
106}
107impl Deref for EFUSE {
108    type Target = efuse::RegisterBlock;
109    #[inline(always)]
110    fn deref(&self) -> &Self::Target {
111        unsafe { &*Self::PTR }
112    }
113}
114impl core::fmt::Debug for EFUSE {
115    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
116        f.debug_struct("EFUSE").finish()
117    }
118}
119#[doc = "EFUSE"]
120pub mod efuse;
121#[doc = "GPIO"]
122pub struct GPIO {
123    _marker: PhantomData<*const ()>,
124}
125unsafe impl Send for GPIO {}
126impl GPIO {
127    #[doc = r"Pointer to the register block"]
128    pub const PTR: *const gpio::RegisterBlock = 0x6000_0300 as *const _;
129    #[doc = r"Return the pointer to the register block"]
130    #[inline(always)]
131    pub const fn ptr() -> *const gpio::RegisterBlock {
132        Self::PTR
133    }
134}
135impl Deref for GPIO {
136    type Target = gpio::RegisterBlock;
137    #[inline(always)]
138    fn deref(&self) -> &Self::Target {
139        unsafe { &*Self::PTR }
140    }
141}
142impl core::fmt::Debug for GPIO {
143    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
144        f.debug_struct("GPIO").finish()
145    }
146}
147#[doc = "GPIO"]
148pub mod gpio;
149#[doc = "I2S"]
150pub struct I2S {
151    _marker: PhantomData<*const ()>,
152}
153unsafe impl Send for I2S {}
154impl I2S {
155    #[doc = r"Pointer to the register block"]
156    pub const PTR: *const i2s::RegisterBlock = 0x6000_0e00 as *const _;
157    #[doc = r"Return the pointer to the register block"]
158    #[inline(always)]
159    pub const fn ptr() -> *const i2s::RegisterBlock {
160        Self::PTR
161    }
162}
163impl Deref for I2S {
164    type Target = i2s::RegisterBlock;
165    #[inline(always)]
166    fn deref(&self) -> &Self::Target {
167        unsafe { &*Self::PTR }
168    }
169}
170impl core::fmt::Debug for I2S {
171    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
172        f.debug_struct("I2S").finish()
173    }
174}
175#[doc = "I2S"]
176pub mod i2s;
177#[doc = "IO_MUX"]
178pub struct IO_MUX {
179    _marker: PhantomData<*const ()>,
180}
181unsafe impl Send for IO_MUX {}
182impl IO_MUX {
183    #[doc = r"Pointer to the register block"]
184    pub const PTR: *const io_mux::RegisterBlock = 0x6000_0800 as *const _;
185    #[doc = r"Return the pointer to the register block"]
186    #[inline(always)]
187    pub const fn ptr() -> *const io_mux::RegisterBlock {
188        Self::PTR
189    }
190}
191impl Deref for IO_MUX {
192    type Target = io_mux::RegisterBlock;
193    #[inline(always)]
194    fn deref(&self) -> &Self::Target {
195        unsafe { &*Self::PTR }
196    }
197}
198impl core::fmt::Debug for IO_MUX {
199    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
200        f.debug_struct("IO_MUX").finish()
201    }
202}
203#[doc = "IO_MUX"]
204pub mod io_mux;
205#[doc = "RTC"]
206pub struct RTC {
207    _marker: PhantomData<*const ()>,
208}
209unsafe impl Send for RTC {}
210impl RTC {
211    #[doc = r"Pointer to the register block"]
212    pub const PTR: *const rtc::RegisterBlock = 0x6000_0700 as *const _;
213    #[doc = r"Return the pointer to the register block"]
214    #[inline(always)]
215    pub const fn ptr() -> *const rtc::RegisterBlock {
216        Self::PTR
217    }
218}
219impl Deref for RTC {
220    type Target = rtc::RegisterBlock;
221    #[inline(always)]
222    fn deref(&self) -> &Self::Target {
223        unsafe { &*Self::PTR }
224    }
225}
226impl core::fmt::Debug for RTC {
227    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
228        f.debug_struct("RTC").finish()
229    }
230}
231#[doc = "RTC"]
232pub mod rtc;
233#[doc = "SLC"]
234pub struct SLC {
235    _marker: PhantomData<*const ()>,
236}
237unsafe impl Send for SLC {}
238impl SLC {
239    #[doc = r"Pointer to the register block"]
240    pub const PTR: *const slc::RegisterBlock = 0x6000_0b00 as *const _;
241    #[doc = r"Return the pointer to the register block"]
242    #[inline(always)]
243    pub const fn ptr() -> *const slc::RegisterBlock {
244        Self::PTR
245    }
246}
247impl Deref for SLC {
248    type Target = slc::RegisterBlock;
249    #[inline(always)]
250    fn deref(&self) -> &Self::Target {
251        unsafe { &*Self::PTR }
252    }
253}
254impl core::fmt::Debug for SLC {
255    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
256        f.debug_struct("SLC").finish()
257    }
258}
259#[doc = "SLC"]
260pub mod slc;
261#[doc = "SPI0"]
262pub struct SPI0 {
263    _marker: PhantomData<*const ()>,
264}
265unsafe impl Send for SPI0 {}
266impl SPI0 {
267    #[doc = r"Pointer to the register block"]
268    pub const PTR: *const spi0::RegisterBlock = 0x6000_0200 as *const _;
269    #[doc = r"Return the pointer to the register block"]
270    #[inline(always)]
271    pub const fn ptr() -> *const spi0::RegisterBlock {
272        Self::PTR
273    }
274}
275impl Deref for SPI0 {
276    type Target = spi0::RegisterBlock;
277    #[inline(always)]
278    fn deref(&self) -> &Self::Target {
279        unsafe { &*Self::PTR }
280    }
281}
282impl core::fmt::Debug for SPI0 {
283    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
284        f.debug_struct("SPI0").finish()
285    }
286}
287#[doc = "SPI0"]
288pub mod spi0;
289#[doc = "SPI1"]
290pub struct SPI1 {
291    _marker: PhantomData<*const ()>,
292}
293unsafe impl Send for SPI1 {}
294impl SPI1 {
295    #[doc = r"Pointer to the register block"]
296    pub const PTR: *const spi1::RegisterBlock = 0x6000_0100 as *const _;
297    #[doc = r"Return the pointer to the register block"]
298    #[inline(always)]
299    pub const fn ptr() -> *const spi1::RegisterBlock {
300        Self::PTR
301    }
302}
303impl Deref for SPI1 {
304    type Target = spi1::RegisterBlock;
305    #[inline(always)]
306    fn deref(&self) -> &Self::Target {
307        unsafe { &*Self::PTR }
308    }
309}
310impl core::fmt::Debug for SPI1 {
311    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
312        f.debug_struct("SPI1").finish()
313    }
314}
315#[doc = "SPI1"]
316pub mod spi1;
317#[doc = "TIMER"]
318pub struct TIMER {
319    _marker: PhantomData<*const ()>,
320}
321unsafe impl Send for TIMER {}
322impl TIMER {
323    #[doc = r"Pointer to the register block"]
324    pub const PTR: *const timer::RegisterBlock = 0x6000_0600 as *const _;
325    #[doc = r"Return the pointer to the register block"]
326    #[inline(always)]
327    pub const fn ptr() -> *const timer::RegisterBlock {
328        Self::PTR
329    }
330}
331impl Deref for TIMER {
332    type Target = timer::RegisterBlock;
333    #[inline(always)]
334    fn deref(&self) -> &Self::Target {
335        unsafe { &*Self::PTR }
336    }
337}
338impl core::fmt::Debug for TIMER {
339    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
340        f.debug_struct("TIMER").finish()
341    }
342}
343#[doc = "TIMER"]
344pub mod timer;
345#[doc = "UART0"]
346pub struct UART0 {
347    _marker: PhantomData<*const ()>,
348}
349unsafe impl Send for UART0 {}
350impl UART0 {
351    #[doc = r"Pointer to the register block"]
352    pub const PTR: *const uart0::RegisterBlock = 0x6000_0000 as *const _;
353    #[doc = r"Return the pointer to the register block"]
354    #[inline(always)]
355    pub const fn ptr() -> *const uart0::RegisterBlock {
356        Self::PTR
357    }
358}
359impl Deref for UART0 {
360    type Target = uart0::RegisterBlock;
361    #[inline(always)]
362    fn deref(&self) -> &Self::Target {
363        unsafe { &*Self::PTR }
364    }
365}
366impl core::fmt::Debug for UART0 {
367    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
368        f.debug_struct("UART0").finish()
369    }
370}
371#[doc = "UART0"]
372pub mod uart0;
373#[doc = "UART1"]
374pub struct UART1 {
375    _marker: PhantomData<*const ()>,
376}
377unsafe impl Send for UART1 {}
378impl UART1 {
379    #[doc = r"Pointer to the register block"]
380    pub const PTR: *const uart1::RegisterBlock = 0x6000_0f00 as *const _;
381    #[doc = r"Return the pointer to the register block"]
382    #[inline(always)]
383    pub const fn ptr() -> *const uart1::RegisterBlock {
384        Self::PTR
385    }
386}
387impl Deref for UART1 {
388    type Target = uart1::RegisterBlock;
389    #[inline(always)]
390    fn deref(&self) -> &Self::Target {
391        unsafe { &*Self::PTR }
392    }
393}
394impl core::fmt::Debug for UART1 {
395    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
396        f.debug_struct("UART1").finish()
397    }
398}
399#[doc = "UART1"]
400pub mod uart1;
401#[doc = "WDT"]
402pub struct WDT {
403    _marker: PhantomData<*const ()>,
404}
405unsafe impl Send for WDT {}
406impl WDT {
407    #[doc = r"Pointer to the register block"]
408    pub const PTR: *const wdt::RegisterBlock = 0x6000_0900 as *const _;
409    #[doc = r"Return the pointer to the register block"]
410    #[inline(always)]
411    pub const fn ptr() -> *const wdt::RegisterBlock {
412        Self::PTR
413    }
414}
415impl Deref for WDT {
416    type Target = wdt::RegisterBlock;
417    #[inline(always)]
418    fn deref(&self) -> &Self::Target {
419        unsafe { &*Self::PTR }
420    }
421}
422impl core::fmt::Debug for WDT {
423    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
424        f.debug_struct("WDT").finish()
425    }
426}
427#[doc = "WDT"]
428pub mod wdt;
429#[doc = "RNG register"]
430pub struct RNG {
431    _marker: PhantomData<*const ()>,
432}
433unsafe impl Send for RNG {}
434impl RNG {
435    #[doc = r"Pointer to the register block"]
436    pub const PTR: *const rng::RegisterBlock = 0x3ff2_0e44 as *const _;
437    #[doc = r"Return the pointer to the register block"]
438    #[inline(always)]
439    pub const fn ptr() -> *const rng::RegisterBlock {
440        Self::PTR
441    }
442}
443impl Deref for RNG {
444    type Target = rng::RegisterBlock;
445    #[inline(always)]
446    fn deref(&self) -> &Self::Target {
447        unsafe { &*Self::PTR }
448    }
449}
450impl core::fmt::Debug for RNG {
451    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
452        f.debug_struct("RNG").finish()
453    }
454}
455#[doc = "RNG register"]
456pub mod rng;
457#[doc = "Internal I2C registers"]
458pub struct RTCCNTL {
459    _marker: PhantomData<*const ()>,
460}
461unsafe impl Send for RTCCNTL {}
462impl RTCCNTL {
463    #[doc = r"Pointer to the register block"]
464    pub const PTR: *const rtccntl::RegisterBlock = 0x6000_0d00 as *const _;
465    #[doc = r"Return the pointer to the register block"]
466    #[inline(always)]
467    pub const fn ptr() -> *const rtccntl::RegisterBlock {
468        Self::PTR
469    }
470}
471impl Deref for RTCCNTL {
472    type Target = rtccntl::RegisterBlock;
473    #[inline(always)]
474    fn deref(&self) -> &Self::Target {
475        unsafe { &*Self::PTR }
476    }
477}
478impl core::fmt::Debug for RTCCNTL {
479    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
480        f.debug_struct("RTCCNTL").finish()
481    }
482}
483#[doc = "Internal I2C registers"]
484pub mod rtccntl;
485#[no_mangle]
486static mut DEVICE_PERIPHERALS: bool = false;
487#[doc = r"All the peripherals"]
488#[allow(non_snake_case)]
489pub struct Peripherals {
490    #[doc = "DPORT"]
491    pub DPORT: DPORT,
492    #[doc = "EFUSE"]
493    pub EFUSE: EFUSE,
494    #[doc = "GPIO"]
495    pub GPIO: GPIO,
496    #[doc = "I2S"]
497    pub I2S: I2S,
498    #[doc = "IO_MUX"]
499    pub IO_MUX: IO_MUX,
500    #[doc = "RTC"]
501    pub RTC: RTC,
502    #[doc = "SLC"]
503    pub SLC: SLC,
504    #[doc = "SPI0"]
505    pub SPI0: SPI0,
506    #[doc = "SPI1"]
507    pub SPI1: SPI1,
508    #[doc = "TIMER"]
509    pub TIMER: TIMER,
510    #[doc = "UART0"]
511    pub UART0: UART0,
512    #[doc = "UART1"]
513    pub UART1: UART1,
514    #[doc = "WDT"]
515    pub WDT: WDT,
516    #[doc = "RNG"]
517    pub RNG: RNG,
518    #[doc = "RTCCNTL"]
519    pub RTCCNTL: RTCCNTL,
520}
521impl Peripherals {
522    #[doc = r"Returns all the peripherals *once*"]
523    #[inline]
524    pub fn take() -> Option<Self> {
525        xtensa_lx::interrupt::free(|_| {
526            if unsafe { DEVICE_PERIPHERALS } {
527                None
528            } else {
529                Some(unsafe { Peripherals::steal() })
530            }
531        })
532    }
533    #[doc = r"Unchecked version of `Peripherals::take`"]
534    #[inline]
535    pub unsafe fn steal() -> Self {
536        DEVICE_PERIPHERALS = true;
537        Peripherals {
538            DPORT: DPORT {
539                _marker: PhantomData,
540            },
541            EFUSE: EFUSE {
542                _marker: PhantomData,
543            },
544            GPIO: GPIO {
545                _marker: PhantomData,
546            },
547            I2S: I2S {
548                _marker: PhantomData,
549            },
550            IO_MUX: IO_MUX {
551                _marker: PhantomData,
552            },
553            RTC: RTC {
554                _marker: PhantomData,
555            },
556            SLC: SLC {
557                _marker: PhantomData,
558            },
559            SPI0: SPI0 {
560                _marker: PhantomData,
561            },
562            SPI1: SPI1 {
563                _marker: PhantomData,
564            },
565            TIMER: TIMER {
566                _marker: PhantomData,
567            },
568            UART0: UART0 {
569                _marker: PhantomData,
570            },
571            UART1: UART1 {
572                _marker: PhantomData,
573            },
574            WDT: WDT {
575                _marker: PhantomData,
576            },
577            RNG: RNG {
578                _marker: PhantomData,
579            },
580            RTCCNTL: RTCCNTL {
581                _marker: PhantomData,
582            },
583        }
584    }
585}