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
//! Low level access to ATmega32U4 registers
#![no_std]
#![feature(asm, const_fn, try_from)]
#![allow(non_camel_case_types)]
#![deny(missing_docs)]

extern crate vcell;
extern crate bare_metal;

pub mod interrupt;

mod peripherals;
pub use peripherals::*;

mod interrupt_macro;

impl Peripherals {
    #[doc = r" Returns all the peripherals *once*"]
    #[inline]
    pub fn take() -> Option<Self> {
        interrupt::free(|_| if unsafe { DEVICE_PERIPHERALS } {
            None
        } else {
            Some(unsafe { Peripherals::steal() })
        })
    }
}