aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2020-09-24 22:04:45 +0200
committerDario Nieuwenhuis <[email protected]>2020-09-24 22:04:45 +0200
commitf8d63b1f30b8204ef942869f23af18025008ab45 (patch)
tree40f13a87a3f1f2acd8e3d7a127f78a8ece7559ec /examples
parent3b39ab07e5b52acfe2ba7aa7f92cfa3c859d3dd7 (diff)
Update to static-executor "multi"
Diffstat (limited to 'examples')
-rw-r--r--examples/Cargo.toml1
-rw-r--r--examples/src/bin/gpiote.rs13
-rw-r--r--examples/src/bin/qspi.rs13
-rw-r--r--examples/src/bin/uart.rs13
-rw-r--r--examples/src/example_common.rs1
5 files changed, 30 insertions, 11 deletions
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 15716a541..5194e4f44 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -27,5 +27,4 @@ nrf52840-hal = { version = "0.11.0" }
27embassy = { version = "0.1.0", path = "../embassy" } 27embassy = { version = "0.1.0", path = "../embassy" }
28embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", features = ["defmt-trace", "52840"] } 28embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", features = ["defmt-trace", "52840"] }
29static-executor = { version = "0.1.0", features=["defmt"]} 29static-executor = { version = "0.1.0", features=["defmt"]}
30static-executor-cortex-m = { version = "0.1.0" }
31futures = { version = "0.3.5", default-features = false } 30futures = { version = "0.3.5", default-features = false }
diff --git a/examples/src/bin/gpiote.rs b/examples/src/bin/gpiote.rs
index f55b0386d..b3a391f13 100644
--- a/examples/src/bin/gpiote.rs
+++ b/examples/src/bin/gpiote.rs
@@ -13,7 +13,10 @@ use embassy_nrf::gpiote;
13use futures::pin_mut; 13use futures::pin_mut;
14use nrf52840_hal::gpio; 14use nrf52840_hal::gpio;
15 15
16#[static_executor::task] 16use static_executor::{task, Executor};
17static EXECUTOR: Executor = Executor::new(|| cortex_m::asm::sev());
18
19#[task]
17async fn run() { 20async fn run() {
18 let p = embassy_nrf::pac::Peripherals::take().dewrap(); 21 let p = embassy_nrf::pac::Peripherals::take().dewrap();
19 let port0 = gpio::p0::Parts::new(p.P0); 22 let port0 = gpio::p0::Parts::new(p.P0);
@@ -78,7 +81,11 @@ fn main() -> ! {
78 info!("Hello World!"); 81 info!("Hello World!");
79 82
80 unsafe { 83 unsafe {
81 run.spawn().dewrap(); 84 EXECUTOR.spawn(run()).dewrap();
82 static_executor::run(); 85
86 loop {
87 EXECUTOR.run();
88 cortex_m::asm::wfe();
89 }
83 } 90 }
84} 91}
diff --git a/examples/src/bin/qspi.rs b/examples/src/bin/qspi.rs
index 395422e7f..4e6ee53ea 100644
--- a/examples/src/bin/qspi.rs
+++ b/examples/src/bin/qspi.rs
@@ -11,6 +11,9 @@ use embassy::flash::Flash;
11use embassy_nrf::qspi; 11use embassy_nrf::qspi;
12use nrf52840_hal::gpio; 12use nrf52840_hal::gpio;
13 13
14use static_executor::{task, Executor};
15static EXECUTOR: Executor = Executor::new(|| cortex_m::asm::sev());
16
14const PAGE_SIZE: usize = 4096; 17const PAGE_SIZE: usize = 4096;
15 18
16// Workaround for alignment requirements. 19// Workaround for alignment requirements.
@@ -18,7 +21,7 @@ const PAGE_SIZE: usize = 4096;
18#[repr(C, align(4))] 21#[repr(C, align(4))]
19struct AlignedBuf([u8; 4096]); 22struct AlignedBuf([u8; 4096]);
20 23
21#[static_executor::task] 24#[task]
22async fn run() { 25async fn run() {
23 let p = embassy_nrf::pac::Peripherals::take().dewrap(); 26 let p = embassy_nrf::pac::Peripherals::take().dewrap();
24 27
@@ -117,7 +120,11 @@ fn main() -> ! {
117 info!("Hello World!"); 120 info!("Hello World!");
118 121
119 unsafe { 122 unsafe {
120 run.spawn().dewrap(); 123 EXECUTOR.spawn(run()).dewrap();
121 static_executor::run(); 124
125 loop {
126 EXECUTOR.run();
127 cortex_m::asm::wfe();
128 }
122 } 129 }
123} 130}
diff --git a/examples/src/bin/uart.rs b/examples/src/bin/uart.rs
index 21e26e3ad..6b9df380a 100644
--- a/examples/src/bin/uart.rs
+++ b/examples/src/bin/uart.rs
@@ -12,7 +12,10 @@ use embassy_nrf::uarte;
12use futures::pin_mut; 12use futures::pin_mut;
13use nrf52840_hal::gpio; 13use nrf52840_hal::gpio;
14 14
15#[static_executor::task] 15use static_executor::{task, Executor};
16static EXECUTOR: Executor = Executor::new(|| cortex_m::asm::sev());
17
18#[task]
16async fn run() { 19async fn run() {
17 let p = embassy_nrf::pac::Peripherals::take().dewrap(); 20 let p = embassy_nrf::pac::Peripherals::take().dewrap();
18 21
@@ -66,7 +69,11 @@ fn main() -> ! {
66 info!("Hello World!"); 69 info!("Hello World!");
67 70
68 unsafe { 71 unsafe {
69 run.spawn().dewrap(); 72 EXECUTOR.spawn(run()).dewrap();
70 static_executor::run(); 73
74 loop {
75 EXECUTOR.run();
76 cortex_m::asm::wfe();
77 }
71 } 78 }
72} 79}
diff --git a/examples/src/example_common.rs b/examples/src/example_common.rs
index e9919153c..65bfe6bb1 100644
--- a/examples/src/example_common.rs
+++ b/examples/src/example_common.rs
@@ -3,7 +3,6 @@
3use defmt_rtt as _; // global logger 3use defmt_rtt as _; // global logger
4use nrf52840_hal as _; 4use nrf52840_hal as _;
5use panic_probe as _; 5use panic_probe as _;
6use static_executor_cortex_m as _;
7 6
8pub use defmt::{info, intern}; 7pub use defmt::{info, intern};
9 8