From eb90e7bb64fc8ed61523818261ed87a0a2f159b3 Mon Sep 17 00:00:00 2001 From: Per Date: Wed, 25 Sep 2019 19:26:37 +0200 Subject: [PATCH] wip, gen_ok, handwritten POC --- examples/gen_ok.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/gen_ok.rs b/examples/gen_ok.rs index 076bb81557..8693e19cf9 100644 --- a/examples/gen_ok.rs +++ b/examples/gen_ok.rs @@ -72,6 +72,7 @@ fn init(_: init::Context) { // hprintln!("{}", ctx.resources.shared2.lock(|v| *v)).unwrap(); ::cortex_m_semihosting::export::hstdout_str("init\n").unwrap(); + // rtfm::pend(Interrupt::GPIOA); } #[allow(non_snake_case)] @@ -90,27 +91,33 @@ static mut GENERATOR_FOO1: core::mem::MaybeUninit = core::mem::MaybeUninit::uninit(); #[allow(non_snake_case)] fn foo1(mut ctx: foo1::Context) -> Generatorfoo1 { - use rtfm::Mutex as _; - // ctx.resources.shared2.lock(|v| *v); move || loop { ctx.resources.shared2.lock(|v| { *v += 1; - hprintln!("{}", v) + hprintln!("foo1_1 lock {}", v); + rtfm::pend(Interrupt::GPIOB); + hprintln!("foo1_1 unloclock {}", v); }); - ::cortex_m_semihosting::export::hstdout_str("foo1_1\n").unwrap(); + ctx.resources.shared2.lock(|v| { + *v += 1; + hprintln!("foo1_1 {}", v); + }); + yield; ctx.resources.shared2.lock(|v| { *v += 1; - hprintln!("{}", v) + hprintln!("foo1_2 {}", v); }); - ::cortex_m_semihosting::export::hstdout_str("foo1_2\n").unwrap(); yield; } } #[allow(non_snake_case)] fn foo2(mut ctx: foo2::Context) { use rtfm::Mutex as _; - ctx.resources.shared2.lock(|v| *v += 1); + ctx.resources.shared2.lock(|v| { + *v += 1; + hprintln!("foo2 {}", v); + }); } #[allow(non_snake_case)] fn foo3(mut ctx: foo3::Context) {