File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -274,3 +274,24 @@ pub use crate::devices::attiny85;
274
274
pub use crate :: devices:: attiny861;
275
275
#[ cfg( feature = "attiny88" ) ]
276
276
pub use crate :: devices:: attiny88;
277
+
278
+ /// Safely retrieve an instance of the device's `struct Peripherals` once.
279
+ ///
280
+ /// This macro can only be used once in the whole program.
281
+ /// Multiple uses will result in a linker abort.
282
+ #[ macro_export]
283
+ macro_rules! peripherals {
284
+ ( $device_name: ident) => {
285
+ {
286
+ {
287
+ #[ no_mangle]
288
+ #[ link_section=".__peripherals_usage_restriction__" ]
289
+ #[ export_name="__ERROR__avr_device__peripherals__macro_must_only_be_used_once__" ]
290
+ static _x: ( ) = ( ) ;
291
+ }
292
+ unsafe {
293
+ avr_device:: $device_name:: Peripherals :: steal( )
294
+ }
295
+ }
296
+ }
297
+ }
You can’t perform that action at this time.
0 commit comments