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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#![no_std]

pub use embedded_hal as ehal;
pub use fugit;
pub use paste;
pub mod typelevel;

#[cfg(not(any(feature = "library", feature = "device")))]
compile_error!(
    "The HAL is usually built for a specific target device, selected using a \
    feature.  If atsamd-hal is being built as a library, bypass this check by \
    specifying the `library` feature"
);

#[cfg(all(feature = "library", feature = "device"))]
compile_error!("Cannot combine `library` and `device` features");

macro_rules! define_pac {
    ( $( ($pac:ident, $feat:literal)),+ ) => {
        $(
            #[cfg(feature = $feat)]
            pub use $pac as pac;
        )+
    };
}

define_pac!(
    (atsamd11c, "atsamd11c"),
    (atsamd11d, "atsamd11d"),
    (atsamd21e, "atsamd21e"),
    (atsamd21g, "atsamd21g"),
    (atsamd21j, "atsamd21j"),
    (atsamd51g, "atsamd51g"),
    (atsamd51j, "atsamd51j"),
    (atsamd51n, "atsamd51n"),
    (atsamd51p, "atsamd51p"),
    (atsame51g, "atsame51g"),
    (atsame51j, "atsame51j"),
    (atsame51n, "atsame51n"),
    (atsame53j, "atsame53j"),
    (atsame53n, "atsame53n"),
    (atsame54n, "atsame54n"),
    (atsame54p, "atsame54p")
);

#[cfg(feature = "use_rtt")]
pub use jlink_rtt;

#[cfg(feature = "use_rtt")]
#[macro_export]
macro_rules! dbgprint {
    ($($arg:tt)*) => {
        {
            use core::fmt::Write;
            let mut out = $crate::jlink_rtt::NonBlockingOutput::new();
            writeln!(out, $($arg)*).ok();
        }
    };
}

#[cfg(not(feature = "use_rtt"))]
#[macro_export]
macro_rules! dbgprint {
    ($($arg:tt)*) => {{}};
}

#[cfg(feature = "device")]
pub mod delay;
#[cfg(feature = "device")]
pub mod gpio;
#[cfg(feature = "device")]
pub mod prelude;
#[cfg(feature = "device")]
pub mod rtc;
#[cfg(feature = "device")]
pub mod sercom;
pub mod sleeping_delay;
pub mod time;
pub mod timer_params;
pub mod timer_traits;

#[cfg(feature = "dma")]
pub mod dmac;

#[cfg(all(feature = "usb", feature = "device", not(feature = "has-usb")))]
compile_error!("The 'usb' feature is enabled, but this chip does not support USB");

#[cfg(feature = "thumbv6")]
#[doc(hidden)]
pub mod thumbv6m;
#[cfg(feature = "thumbv6")]
#[doc(inline)]
pub use crate::thumbv6m::*;

#[cfg(feature = "thumbv7")]
#[doc(hidden)]
pub mod thumbv7em;
#[cfg(feature = "thumbv7")]
#[doc(inline)]
pub use crate::thumbv7em::*;

#[macro_use]
mod bsp_peripherals_macro;
pub use bsp_peripherals_macro::*;