From 2a72f2fc1babfbc1a339988a08e3f8b298d78aee Mon Sep 17 00:00:00 2001 From: anttib-5 <anttib-5@student.ltu.se> Date: Tue, 5 Mar 2019 12:02:34 +0100 Subject: [PATCH] bare0_4 --- Cargo.toml | 2 +- examples/bare0.rs | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3089f34..f1088d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ optional = true [dependencies.stm32f4xx-hal] git = "https://github.com/stm32-rs/stm32f4xx-hal.git" -version = "0.2.8" +version = "0.3.0" features = ["stm32f413", "rt"] optional = true diff --git a/examples/bare0.rs b/examples/bare0.rs index eef66f5..02cf056 100644 --- a/examples/bare0.rs +++ b/examples/bare0.rs @@ -48,25 +48,27 @@ fn main() -> ! { // 1. Run the program in the debugger, let the program run for a while and // then press pause. Look in the (Local -vscode) Variables view what do you find. // -// ** your answer here ** +// X = 7893536 +// Y = 7893536 // // In the Expressions (WATCH -vscode) view add X and Y // what do you find // -// ** your answer here ** +// X and Y are less than x // // Step through one complete iteration of the loop // and see how the (Local) Variables are updated // can you foresee what will eventually happen? // -// ** place your answer here ** -// +// x will increment then X will increment, then Y will be set as the same as X and then +// it will assert the changes. + // Commit your answers (bare0_1) // // 2. Alter the constant X_INIT so that `x += 1` directly causes `x` to wrap // what happens when `x` wraps // -// ** your answer here ** +// Core panic, since the u32 int will overflow // // Commit your answers (bare0_2) // @@ -74,10 +76,12 @@ fn main() -> ! { // // Change (both) += opertions to use wrapping_add // load and run the progam, what happens -// ** your answer here ** + +// The variables wrapped around back to 0. // // Now continue exectution, what happens -// ** your answer here ** + +// The variables was incremeted as normal. // // Commit your answers (bare0_3) // @@ -86,7 +90,7 @@ fn main() -> ! { // // 4. Change the asserion to `assert!(x == X && X == Y + 1)`, what happens? // -// ** place your answer here ** +// The assert fails and we get core panic. // // Commit your answers (bare0_4) // -- GitLab