Skip to content

Commit 286568a

Browse files
author
James Munns
committed
Add Sharing Data with Interrupts
1 parent d417421 commit 286568a

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

README.md

+40-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,50 @@ And don't forget to check our [Awesome Embedded Rust][aer] list! The thing you a
2626

2727
* Useful Links
2828
* [Contributing Guide]
29-
* [Item Template](https://github.com/rust-embedded/not-yet-awesome-embedded-rust#not-yet-awesome-item-template)
29+
* [Item Template](#not-yet-awesome-item-template)
3030
* Not Yet Awesome List
31-
* [nothing yet...](#)
31+
* [nothing yet...](#sharing-data-with-interrupts)
3232

3333
# The List
3434

35-
Nothing here yet...
35+
## Sharing Data With Interrupts
36+
37+
### Background
38+
39+
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
53+
54+
[wg#294]: https://github.com/rust-embedded/wg/issues/294
55+
[bare-metal#15]: https://github.com/japaric/bare-metal/pull/15
56+
[cortex-m-rtfm]: https://github.com/japaric/cortex-m-rtfm
57+
58+
### Success Criteria
59+
60+
Ideally, we would be able to support all of the following use cases:
61+
62+
1. Sharing a variable between the main thread and only one interrupt handler
63+
2. Sharing a variable between the main thread and one or more interrupt handlers
64+
3. Moving a variable from the main thread to one interrupt handler
65+
66+
We should be able to serve the three use cases listed above, while:
67+
68+
* Using only safe Rust (at least as a user of the library)
69+
* Add only minimal overhead, if not "zero cost"
70+
71+
<! -- TODO: Uncomment when there is work in progress -->
72+
<! -- ### Work in progress -- >
3673

3774
# Not Yet Awesome Item Template
3875

0 commit comments

Comments
 (0)