You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, it is not convenient to share data with an interrupt using safe Rust. Because interrupt handlers are functions that take no arguments, all data consumed by interrupts must either be local `static` variables, or global `static` variables.
40
+
41
+
Global variables are not great in Rust, because:
42
+
43
+
* All mutable access must be `unsafe`
44
+
* Not all data can be initialized in a `const` context, so it's often necessary to use an `Option<T>`
45
+
* Global variables aren't typically idiomatic Rust.
46
+
47
+
Tools like [cortex-m-rtfm] achieve this in a zero cost fashion by using a Domain Specific Language to automatically provide safe access to shared resources between tasks and interrupts, however these tools can not be used by applications not using RTFM, or by libraries such as HAL or BSP crates.
48
+
49
+
**Useful Links**
50
+
51
+
*[wg#294] - An Embedded-WG issue discussing this topic
52
+
*[bare-metal#15] - One proposed solution hiding the un-idiomatic syntax
0 commit comments