Commit 9a706b02 authored by Per's avatar Per

expand main

parent 497a3a35
......@@ -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();
}
}
```
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment