diff options
Diffstat (limited to 'examples/src/bin/executor_fairness_test.rs')
| -rw-r--r-- | examples/src/bin/executor_fairness_test.rs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/examples/src/bin/executor_fairness_test.rs b/examples/src/bin/executor_fairness_test.rs deleted file mode 100644 index 9b2c1bd26..000000000 --- a/examples/src/bin/executor_fairness_test.rs +++ /dev/null | |||
| @@ -1,74 +0,0 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | #[path = "../example_common.rs"] | ||
| 6 | mod example_common; | ||
| 7 | use example_common::*; | ||
| 8 | |||
| 9 | use core::task::Poll; | ||
| 10 | use cortex_m_rt::entry; | ||
| 11 | use defmt::panic; | ||
| 12 | use embassy::executor::{task, Executor}; | ||
| 13 | use embassy::time::{Duration, Instant, Timer}; | ||
| 14 | use embassy::util::Forever; | ||
| 15 | use embassy_nrf::pac; | ||
| 16 | use embassy_nrf::{interrupt, rtc}; | ||
| 17 | use nrf52840_hal::clocks; | ||
| 18 | |||
| 19 | #[task] | ||
| 20 | async fn run1() { | ||
| 21 | loop { | ||
| 22 | info!("DING DONG"); | ||
| 23 | Timer::after(Duration::from_ticks(16000)).await; | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | #[task] | ||
| 28 | async fn run2() { | ||
| 29 | loop { | ||
| 30 | Timer::at(Instant::from_ticks(0)).await; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | #[task] | ||
| 35 | async fn run3() { | ||
| 36 | futures::future::poll_fn(|cx| { | ||
| 37 | cx.waker().wake_by_ref(); | ||
| 38 | Poll::<()>::Pending | ||
| 39 | }) | ||
| 40 | .await; | ||
| 41 | } | ||
| 42 | |||
| 43 | static RTC: Forever<rtc::RTC<pac::RTC1>> = Forever::new(); | ||
| 44 | static ALARM: Forever<rtc::Alarm<pac::RTC1>> = Forever::new(); | ||
| 45 | static EXECUTOR: Forever<Executor> = Forever::new(); | ||
| 46 | |||
| 47 | #[entry] | ||
| 48 | fn main() -> ! { | ||
| 49 | info!("Hello World!"); | ||
| 50 | |||
| 51 | let p = unwrap!(embassy_nrf::pac::Peripherals::take()); | ||
| 52 | |||
| 53 | clocks::Clocks::new(p.CLOCK) | ||
| 54 | .enable_ext_hfosc() | ||
| 55 | .set_lfclk_src_external(clocks::LfOscConfiguration::NoExternalNoBypass) | ||
| 56 | .start_lfclk(); | ||
| 57 | |||
| 58 | let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1))); | ||
| 59 | rtc.start(); | ||
| 60 | |||
| 61 | unsafe { embassy::time::set_clock(rtc) }; | ||
| 62 | |||
| 63 | let alarm = ALARM.put(rtc.alarm0()); | ||
| 64 | let executor = EXECUTOR.put(Executor::new_with_alarm(alarm, cortex_m::asm::sev)); | ||
| 65 | |||
| 66 | unwrap!(executor.spawn(run1())); | ||
| 67 | unwrap!(executor.spawn(run2())); | ||
| 68 | unwrap!(executor.spawn(run3())); | ||
| 69 | |||
| 70 | loop { | ||
| 71 | executor.run(); | ||
| 72 | cortex_m::asm::wfe(); | ||
| 73 | } | ||
| 74 | } | ||
