Skip to content
Snippets Groups Projects
Commit dfd79ce0 authored by Per Lindgren's avatar Per Lindgren
Browse files

exercises updated

parent 12117010
Branches
No related tags found
No related merge requests found
//! 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)
//! bare3.rs
//! rtic_bare3.rs
//!
//! Measuring execution time
//!
......
//! bare4.rs
//! rtic_bare4.rs
//!
//! Access to Peripherals
//!
......
//! 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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment