From 7f46e4cbf51e51ba0a96636871c630437ee03b4a Mon Sep 17 00:00:00 2001
From: Per Lindgren <per.lindgren@ltu.se>
Date: Sat, 1 Feb 2020 12:01:15 +0100
Subject: [PATCH] blinky_msg123

---
 Cargo.toml                   | 10 +++++++++-
 examples/rtfm_blinky_msg1.rs |  6 +++---
 examples/rtfm_blinky_msg2.rs |  6 +++---
 examples/rtfm_blinky_msg3.rs | 14 ++++++++------
 4 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index bbdda9d..94fc7ba 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -55,7 +55,15 @@ name                = "serial"
 required-features   = ["stm32f4xx-hal"]
 
 [[example]]
-name                = "rtfm_blinky"
+name                = "rtfm_blinky_msg1"
+required-features   = ["rtfm"]
+
+[[example]]
+name                = "rtfm_blinky_msg2"
+required-features   = ["rtfm"]
+
+[[example]]
+name                = "rtfm_blinky_msg3"
 required-features   = ["rtfm"]
 
 [profile.dev]
diff --git a/examples/rtfm_blinky_msg1.rs b/examples/rtfm_blinky_msg1.rs
index 48d4574..dddb87d 100644
--- a/examples/rtfm_blinky_msg1.rs
+++ b/examples/rtfm_blinky_msg1.rs
@@ -1,5 +1,5 @@
 #![deny(unsafe_code)]
-// #![deny(warnings)]
+#![deny(warnings)]
 #![no_main]
 #![no_std]
 
@@ -16,9 +16,9 @@ const APP: () = {
         GPIOA: stm32::GPIOA,
     }
     #[init(schedule = [toggle])]
-    fn init(mut cx: init::Context) -> init::LateResources {
+    fn init(cx: init::Context) -> init::LateResources {
         let mut core = cx.core;
-        let mut device = cx.device;
+        let device = cx.device;
 
         // Initialize (enable) the monotonic timer (CYCCNT)
         core.DCB.enable_trace();
diff --git a/examples/rtfm_blinky_msg2.rs b/examples/rtfm_blinky_msg2.rs
index 18867aa..d1ddee9 100644
--- a/examples/rtfm_blinky_msg2.rs
+++ b/examples/rtfm_blinky_msg2.rs
@@ -1,5 +1,5 @@
 #![deny(unsafe_code)]
-// #![deny(warnings)]
+#![deny(warnings)]
 #![no_main]
 #![no_std]
 
@@ -16,9 +16,9 @@ const APP: () = {
         GPIOA: stm32::GPIOA,
     }
     #[init(schedule = [toggle])]
-    fn init(mut cx: init::Context) -> init::LateResources {
+    fn init(cx: init::Context) -> init::LateResources {
         let mut core = cx.core;
-        let mut device = cx.device;
+        let device = cx.device;
 
         // Initialize (enable) the monotonic timer (CYCCNT)
         core.DCB.enable_trace();
diff --git a/examples/rtfm_blinky_msg3.rs b/examples/rtfm_blinky_msg3.rs
index 81f2858..a80f9a7 100644
--- a/examples/rtfm_blinky_msg3.rs
+++ b/examples/rtfm_blinky_msg3.rs
@@ -1,5 +1,5 @@
 #![deny(unsafe_code)]
-// #![deny(warnings)]
+#![deny(warnings)]
 #![no_main]
 #![no_std]
 
@@ -12,9 +12,9 @@ use stm32f4xx_hal::stm32;
 #[rtfm::app(device = stm32f4xx_hal::stm32, monotonic = rtfm::cyccnt::CYCCNT, peripherals = true)]
 const APP: () = {
     #[init(schedule = [toggle])]
-    fn init(mut cx: init::Context) {
+    fn init(cx: init::Context) {
         let mut core = cx.core;
-        let mut device = cx.device;
+        let device = cx.device;
 
         // Initialize (enable) the monotonic timer (CYCCNT)
         core.DCB.enable_trace();
@@ -32,10 +32,11 @@ const APP: () = {
         device.GPIOA.moder.modify(|_, w| w.moder5().bits(1));
 
         cx.schedule
-            .toggle(now + 8_000_000.cycles(), true, device.GPIOA);
+            .toggle(now + 8_000_000.cycles(), true, device.GPIOA)
+            .ok();
     }
 
-    #[task(schedule = [toggle])]
+    #[task(schedule= [toggle])]
     fn toggle(cx: toggle::Context, toggle: bool, gpioa: stm32::GPIOA) {
         hprintln!("toggle  @ {:?}", Instant::now()).unwrap();
 
@@ -46,7 +47,8 @@ const APP: () = {
         }
 
         cx.schedule
-            .toggle(cx.scheduled + 8_000_000.cycles(), !toggle, gpioa);
+            .toggle(cx.scheduled + 8_000_000.cycles(), !toggle, gpioa)
+            .ok();
     }
 
     extern "C" {
-- 
GitLab