Skip to content

Commit

Permalink
fixed ch 10, started ch 9
Browse files Browse the repository at this point in the history
  • Loading branch information
BartMassey committed Jul 8, 2024
1 parent c79cc39 commit 645cee7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 47 deletions.
5 changes: 4 additions & 1 deletion mdbook/src/09-led-compass/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ edition = "2021"

[dependencies]
microbit-v2 = "0.15.0"
cortex-m = "0.7.7"
cortex-m-rt = "0.7.3"
rtt-target = "0.5.0"
panic-rtt-target = "0.1.3"
lsm303agr = "1.1.0"
libm = "0.2.8"
embedded-hal = "1.0.0"

[dependencies.cortex-m]
version = "0.7.7"
features = ["critical-section-single-core"]
12 changes: 6 additions & 6 deletions mdbook/src/09-led-compass/src/calibration.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Translated from <https://github.com/lancaster-university/codal-microbit-v2/blob/006abf5566774fbcf674c0c7df27e8a9d20013de/source/MicroBitCompassCalibrator.cpp>
use core::fmt::Debug;
use embedded_hal::blocking::delay::DelayUs;
use embedded_hal::blocking::i2c::{Write, WriteRead};
use embedded_hal::i2c::I2c;
use embedded_hal::delay::DelayNs;
use libm::{fabsf, sqrtf};
use lsm303agr::interface::I2cInterface;
use lsm303agr::mode::MagContinuous;
Expand Down Expand Up @@ -43,8 +43,8 @@ pub fn calc_calibration<I, T, E>(
timer: &mut T,
) -> Calibration
where
T: DelayUs<u32>,
I: Write<Error = E> + WriteRead<Error = E>,
T: DelayNs,
I: I2c,
E: Debug,
{
let data = get_data(sensor, display, timer);
Expand All @@ -57,8 +57,8 @@ fn get_data<I, T, E>(
timer: &mut T,
) -> [Measurement; 25]
where
T: DelayUs<u32>,
I: Write<Error = E> + WriteRead<Error = E>,
T: DelayNs,
I: I2c,
E: Debug,
{
let mut leds = [
Expand Down
6 changes: 4 additions & 2 deletions mdbook/src/10-punch-o-meter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ edition = "2021"

[dependencies]
microbit-v2 = "0.15.0"
cortex-m = "0.7.7"
cortex-m-rt = "0.7.3"
rtt-target = "0.5.0"
panic-rtt-target = "0.1.3"
lsm303agr = "1.1.0"
nb = "1.1.0"

[dependencies.cortex-m]
version = "0.7.7"
features = ["inline-asm", "critical-section-single-core"]
30 changes: 0 additions & 30 deletions mdbook/src/10-punch-o-meter/build.rs

This file was deleted.

6 changes: 0 additions & 6 deletions mdbook/src/10-punch-o-meter/memory.x

This file was deleted.

7 changes: 5 additions & 2 deletions mdbook/src/10-punch-o-meter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
#![no_main]
#![no_std]

use cortex_m::asm::wfi;
use cortex_m_rt::entry;
use rtt_target::rtt_init_print;
use panic_rtt_target as _;
use rtt_target::rtt_init_print;

#[entry]
fn main() -> ! {
rtt_init_print!();
let _board = microbit::Board::take().unwrap();

loop {}
loop {
wfi();
}
}

0 comments on commit 645cee7

Please sign in to comment.