~ruther/avr-device

ref: fb9d2d977794274b9e4eebc8faa5ef0928628564 avr-device/src/lib.rs -rw-r--r-- 1.1 KiB
fb9d2d97 — Rahix Enable CI 5 years ago
                                                                                
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#![no_std]
#![feature(asm)]

#[allow(non_camel_case_types, unused_attributes)]
mod devices;

pub mod interrupt;

cfg_if::cfg_if! {
    if #[cfg(feature= "atmega1280")] {
        pub use crate::devices::atmega1280::*;
    } else if #[cfg(feature = "atmega8")] {
        pub use crate::devices::atmega8::*;
    } else if #[cfg(feature = "atmega328p")] {
        pub use crate::devices::atmega328p::*;
    } else if #[cfg(feature = "atmega32u4")] {
        pub use crate::devices::atmega32u4::*;
    } else if #[cfg(feature = "attiny85")] {
        pub use crate::devices::attiny85::*;
    } else {
        compile_error!("You need to select exactly one chip as a feature!");
    }
}

#[cfg(any(
    feature = "atmega1280",
    feature = "atmega8",
    feature = "atmega328p",
    feature = "atmega32u4",
    feature = "attiny85",
))]
impl Peripherals {
    /// Returns all the peripherals *once*
    #[inline]
    pub fn take() -> Option<Self> {
        interrupt::free(|_| {
            if unsafe { DEVICE_PERIPHERALS } {
                None
            } else {
                Some(unsafe { Peripherals::steal() })
            }
        })
    }
}
Do not follow this link