From 6a2fde39fe534102b1fd4937a0cd048cf170bb0f Mon Sep 17 00:00:00 2001 From: Per <Per Lindgren> Date: Thu, 4 Jan 2018 15:55:44 +0100 Subject: [PATCH] loop, example --- .vscode/launch.json | 18 ++++++++++++++++++ .vscode/tasks.json | 22 ++++++++++++++-------- examples/loop.rs | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 examples/loop.rs diff --git a/.vscode/launch.json b/.vscode/launch.json index 30daa54..d3c2e2a 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 8d2be76..c825d3b 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 0000000..8f615cd --- /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(); + } +} -- GitLab