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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! Utility macros for the WS63 HAL.
// ── Stable/unstable gating (crate-local, esp-hal pattern) ───────────────────
// `#[instability::unstable]` cannot be applied to inline `pub mod foo;` declarations
// (rust-lang/rust#54727 — only the semicolon/external-file form is affected; inline
// mods WITH bodies work). These macros wrap a `pub mod foo;` declaration so the
// module is `pub` when `unstable` is on, `pub(crate)` when off (soft-gate) — keeping
// the module compiling in-crate (so a missed stable→unstable reference stays valid)
// while hiding it from external consumers without the feature. NO `#[macro_export]`
// — these are crate-internal helpers (esp-hal's are crate-private too, brought into
// scope via `pub(crate) use` and invoked as `crate::unstable_module!`). The
// `$(#[$meta])*` forwarding (incl. `#[path = "..."]`) is emitted on BOTH cfg branches
// so a `#[path]`-aliased module resolves on whichever copy survives.
/// Soft-gate a `pub mod foo;` declaration behind the `unstable` feature:
/// `pub mod foo;` when on, `pub(crate) mod foo;` when off. Use for modules the
/// crate's own stable code may reference (so the reference stays compiling as
/// `pub(crate)`). Both branches get `#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]`
/// so docs.rs marks the module "requires unstable".
;
}
/// Hard-gate a `pub mod foo;` declaration behind the `unstable` feature: the module
/// is `pub` when on, **absent** when off (no `pub(crate)` fallback — the module is
/// not compiled at all). Use for standalone drivers that nothing stable depends on
/// (saves flash + guarantees no stable code reaches them).
;
}
// The macros are made crate-visible by `#[macro_use]` on `mod macros;` in lib.rs —
// invoke them by bare name (`unstable_module! { ... }`) from any submodule.
/// Create a type-erased enum for a peripheral type.
/// Example:
/// ```ignore
/// any_peripheral! {
/// pub peripheral AnySpi<'d> {
/// Spi0(crate::peripherals::Spi0<'d>),
/// Spi1(crate::peripherals::Spi1<'d>),
/// }
/// }
/// ```
) => ;
}
/// Infallible conversion — used when a conversion cannot fail.