From dfd79ce0996e48f823e6015eb357456d91b25e1e Mon Sep 17 00:00:00 2001 From: Per Lindgren <per.lindgren@ltu.se> Date: Mon, 1 Mar 2021 10:20:25 +0100 Subject: [PATCH] exercises updated --- examples/rtic_bare2.rs | 11 +++-------- examples/rtic_bare3.rs | 2 +- examples/rtic_bare4.rs | 2 +- examples/rtic_bare5.rs | 18 +++++++----------- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/examples/rtic_bare2.rs b/examples/rtic_bare2.rs index 48fbb05..04266d7 100644 --- a/examples/rtic_bare2.rs +++ b/examples/rtic_bare2.rs @@ -1,4 +1,4 @@ -//! bare2.rs +//! rtic_bare2.rs //! //! Measuring execution time //! @@ -10,11 +10,6 @@ #![no_main] #![no_std] -// use panic_halt as _; - -// use cortex_m::{iprintln, peripheral::DWT, Peripherals}; -// use cortex_m_rt::entry; - use cortex_m::peripheral::DWT; use cortex_m_semihosting::hprintln; use panic_semihosting as _; @@ -124,7 +119,7 @@ fn wait(i: u32) { // // Commit your answers (bare2_2) // -// 3. Now add a second call to `wait` (line 47). +// 3. Now add a second call to `wait` (line 42). // // Recompile and run until the breakpoint. // @@ -136,4 +131,4 @@ fn wait(i: u32) { // // ** your answer here ** // -// +// Commit your answers (bare2_3) diff --git a/examples/rtic_bare3.rs b/examples/rtic_bare3.rs index 74f6c52..9173175 100644 --- a/examples/rtic_bare3.rs +++ b/examples/rtic_bare3.rs @@ -1,4 +1,4 @@ -//! bare3.rs +//! rtic_bare3.rs //! //! Measuring execution time //! diff --git a/examples/rtic_bare4.rs b/examples/rtic_bare4.rs index a04efb3..1d53d13 100644 --- a/examples/rtic_bare4.rs +++ b/examples/rtic_bare4.rs @@ -1,4 +1,4 @@ -//! bare4.rs +//! rtic_bare4.rs //! //! Access to Peripherals //! diff --git a/examples/rtic_bare5.rs b/examples/rtic_bare5.rs index 3fddcb3..5686e1b 100644 --- a/examples/rtic_bare5.rs +++ b/examples/rtic_bare5.rs @@ -1,4 +1,4 @@ -//! bare5.rs +//! rtic_bare5.rs //! //! C Like Peripheral API //! @@ -177,6 +177,8 @@ const APP: () = { let r = gpioa.MODER.read() & !(0b11 << (5 * 2)); // read and mask gpioa.MODER.write(r | 0b01 << (5 * 2)); // set output mode + // test_modify(); + loop { // set PA5 high gpioa.BSRRH.write(1 << 5); // set bit, output hight (turn on led) @@ -198,11 +200,6 @@ const APP: () = { } }; -// 0. Build and run the application. -// -// > cargo build --example bare5 -// (or use the vscode) -// // 1. C like API. // Using C the .h files are used for defining interfaces, like function signatures (prototypes), // structs and macros (but usually not the functions themselves). @@ -211,9 +208,8 @@ const APP: () = { // provided by ST (and other companies). Actually, the file presented here is mostly a // cut/paste/replace of the stm32f40x.h, just Rustified. // -// // In the loop we access PA5 through bit set/clear operations. -// Comment out those operations and uncomment the the ODR accesses. +// Comment out those operations and uncomment the ODR based accesses. // (They should have the same behavior, but is a bit less efficient.) // // Run and see that the program behaves the same. @@ -228,12 +224,10 @@ const APP: () = { // // Implement and check that running `test` gives you expected behavior. // -// Change the code into using your new API. +// Change the code into using your new `modify` API. // // Run and see that the program behaves the same. // -// Commit your answers (bare5_2) -// // Discussion: // As with arithmetic operations, default semantics differ in between // debug/dev and release builds. @@ -248,3 +242,5 @@ const APP: () = { // Wouldn't that be great? // // ** your answer here ** +// +// Commit your answers (bare5_2) -- GitLab