We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bfccae0 commit 6a73d56Copy full SHA for 6a73d56
1 file changed
src/lib.rs
@@ -273,3 +273,24 @@ pub use crate::devices::attiny85;
273
pub use crate::devices::attiny861;
274
#[cfg(feature = "attiny88")]
275
pub use crate::devices::attiny88;
276
+
277
+/// Safely retrieve an instance of the device's `struct Peripherals` once.
278
+///
279
+/// This macro can only be used once in the whole program.
280
+/// Multiple uses will result in a linker abort.
281
+#[macro_export]
282
+macro_rules! peripherals {
283
+ ($device_name: ident) => {
284
+ {
285
286
+ #[no_mangle]
287
+ #[link_section=".__peripherals_usage_restriction__"]
288
+ #[export_name="__ERROR__avr_device__peripherals__macro_must_only_be_used_once__"]
289
+ static _x: () = ();
290
+ }
291
+ unsafe {
292
+ avr_device::$device_name::Peripherals::steal()
293
294
295
296
+}
0 commit comments