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 @@ -273,3 +273,24 @@ pub use crate::devices::attiny85;
273
273
pub use crate :: devices:: attiny861;
274
274
#[ cfg( feature = "attiny88" ) ]
275
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
+ }
You can’t perform that action at this time.
0 commit comments