From 9a706b026cf59f1549e1748464f3a21c00fd0015 Mon Sep 17 00:00:00 2001
From: Per <Per Lindgren>
Date: Mon, 20 Nov 2017 02:07:13 +0100
Subject: [PATCH] expand main

---
 doc/RTFM.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/doc/RTFM.md b/doc/RTFM.md
index ec0df64..d217545 100644
--- a/doc/RTFM.md
+++ b/doc/RTFM.md
@@ -205,6 +205,52 @@ or
 
 Let us study the `nested` example in detail.
 
+```rust
+fn main() {
+    let init: fn(stm32f40x::Peripherals, init::Resources) = init;
+    rtfm::atomic(unsafe { &mut rtfm::Threshold::new(0) }, |_t| unsafe {
+        let _late_resources =
+            init(stm32f40x::Peripherals::all(), init::Resources::new());
+        let nvic = &*stm32f40x::NVIC.get();
+        let prio_bits = stm32f40x::NVIC_PRIO_BITS;
+        let hw = ((1 << prio_bits) - 2u8) << (8 - prio_bits);
+        nvic.set_priority(stm32f40x::Interrupt::EXTI1, hw);
+        nvic.enable(stm32f40x::Interrupt::EXTI1);
+        let prio_bits = stm32f40x::NVIC_PRIO_BITS;
+        let hw = ((1 << prio_bits) - 1u8) << (8 - prio_bits);
+        nvic.set_priority(stm32f40x::Interrupt::EXTI0, hw);
+        nvic.enable(stm32f40x::Interrupt::EXTI0);
+        let prio_bits = stm32f40x::NVIC_PRIO_BITS;
+        let hw = ((1 << prio_bits) - 1u8) << (8 - prio_bits);
+        nvic.set_priority(stm32f40x::Interrupt::EXTI3, hw);
+        nvic.enable(stm32f40x::Interrupt::EXTI3);
+        let prio_bits = stm32f40x::NVIC_PRIO_BITS;
+        let hw = ((1 << prio_bits) - 3u8) << (8 - prio_bits);
+        nvic.set_priority(stm32f40x::Interrupt::EXTI2, hw);
+        nvic.enable(stm32f40x::Interrupt::EXTI2);
+    });
+    let idle: fn() -> ! = idle;
+    idle();
+}
+fn init(_p: init::Peripherals, _r: init::Resources) {}
+#[inline(never)]
+fn idle() -> ! {
+    let mut stdout = hio::hstdout().unwrap();
+    stdout
+        .write_fmt(::core::fmt::Arguments::new_v1(
+            &["Hello, world!\n"],
+            &match () {
+                () => [],
+            },
+        ))
+        .unwrap();
+    rtfm::bkpt();
+    rtfm::set_pending(Interrupt::EXTI3);
+    loop {
+        rtfm::wfi();
+    }
+}
+```
 
   
 
-- 
GitLab