diff --git a/.vscode/launch.json b/.vscode/launch.json index 30daa5417c05c83377dbe8bd02ff715729f84ebc..d3c2e2a128eba1866d959d64e480da7f53b0d0e5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -40,5 +40,23 @@ ], "cwd": "${workspaceRoot}" }, + { + "type": "gdb", + "request": "attach", + "name": "loop", + "gdbpath": "/usr/bin/arm-none-eabi-gdb", + "executable": "./target/thumbv7em-none-eabihf/debug/examples/loop", + "target": ":3333", + "remote": true, + "autorun": [ + "monitor reset init", + "monitor arm semihosting enable", + "monitor tpiu config internal /tmp/itm.log uart off 64000000", + "monitor itm port 0 on", + "load", + "monitor reset init" + ], + "cwd": "${workspaceRoot}" + }, ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 8d2be764cffa01fbc049405378f0afec9eeb1db5..c825d3b62539fbb79127f4217b20faef5e18213a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,10 +6,7 @@ { "type": "shell", "label": "xargo build", - "command": "xargo", - "args": [ - "build" - ], + "command": "xargo build", "problemMatcher": [ "$rustc" ], @@ -21,10 +18,19 @@ { "type": "shell", "label": "xargo build --release", - "command": "xargo", - "args": [ - "build --release" + "command": "xargo build --release", + "problemMatcher": [ + "$rustc" ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "type": "shell", + "label": "xargo build --example loop", + "command": "xargo build --example loop ", "problemMatcher": [ "$rustc" ], @@ -32,6 +38,6 @@ "kind": "build", "isDefault": true } - } + }, ] } \ No newline at end of file diff --git a/examples/loop.rs b/examples/loop.rs new file mode 100644 index 0000000000000000000000000000000000000000..8f615cd3e9f1b71594d7e5f4813728f0e8a92576 --- /dev/null +++ b/examples/loop.rs @@ -0,0 +1,36 @@ +//! Nesting claims and how the preemption threshold works +//! +//! If you run this program you'll hit the breakpoints as indicated by the +//! letters in the comments: A, then B, then C, etc. +#![deny(unsafe_code)] +#![feature(proc_macro)] +#![no_std] + +extern crate cortex_m; +extern crate cortex_m_rtfm as rtfm; +extern crate stm32f40x; + +#[macro_use] +extern crate cortex_m_debug; + +use rtfm::app; + +app! { + device: stm32f40x, +} + +fn init(_p: init::Peripherals) { + let mut sum = 0; + for i in 0..10 { + ipln!("i = {}", i); + sum += i; + } + ipln!("Sum 0 .. 10 = {}", sum); +} + +#[inline(never)] +fn idle() -> ! { + loop { + rtfm::wfi(); + } +}