aboutsummaryrefslogtreecommitdiff
path: root/examples/generics.rs
diff options
context:
space:
mode:
authorGravatar homunkulus <homunkulus@gmx.com> 2017-12-09 12:09:35 +0000
committerGravatar homunkulus <homunkulus@gmx.com> 2017-12-09 12:09:35 +0000
commite78ca98c42a2af1ca9c04d176441b045cd5e8c65 (patch)
tree36287f0622b3ea691e9fa83781c6308c5ad490e3 /examples/generics.rs
parente620b1e57a39f342cf73ad6ac8ab0e179b97bfd5 (diff)
parent1830bdbe5c10814031e5022552a09147d5c534fc (diff)
downloadrtic-e78ca98c42a2af1ca9c04d176441b045cd5e8c65.tar.gz
rtic-e78ca98c42a2af1ca9c04d176441b045cd5e8c65.tar.zst
rtic-e78ca98c42a2af1ca9c04d176441b045cd5e8c65.zip
Auto merge of #50 - japaric:singletons, r=japaric
Peripherals as scoped singletons See this RFC for details: japaric/svd2rust#157 - The first commit adapts this crate to the changes in japaric/cortex-m#65 and japaric/svd2rust#158 - ~~The second commit is an alternative implementation of RFC #47 (there's another implementation in #49. This second commit is not required for RFC157 but let us experiment with safe DMA abstractions.~~ postponed ### TODO - [x] un-bless peripherals as resources. Peripherals as resources were special cased: if resource listed in e.g. `app.tasks.FOO.resources` didn't appear in `app.resources` then it was assumed to be a peripheral and special code was generated for it. This is no longer required under RFC157. ~~This depends on PR japaric/rtfm-syntax#2~~ postponed
Diffstat (limited to 'examples/generics.rs')
-rw-r--r--examples/generics.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/generics.rs b/examples/generics.rs
index 57c9b8eb..afcafa0a 100644
--- a/examples/generics.rs
+++ b/examples/generics.rs
@@ -12,6 +12,11 @@ use stm32f103xx::{SPI1, GPIOA};
app! {
device: stm32f103xx,
+ resources: {
+ static GPIOA: GPIOA;
+ static SPI1: SPI1;
+ },
+
tasks: {
EXTI0: {
path: exti0,
@@ -27,7 +32,12 @@ app! {
},
}
-fn init(_p: init::Peripherals) {}
+fn init(p: init::Peripherals) -> init::LateResourceValues {
+ init::LateResourceValues {
+ GPIOA: p.device.GPIOA,
+ SPI1: p.device.SPI1,
+ }
+}
fn idle() -> ! {
loop {