Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to embedded-hal 1.0. #123

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Add support for PPI
- Servo example using TIMER, GPIOTE and PPI
- (NFC) GitHub CI changes
- Updated HAL crates to latest versions.
- Updated to `embedded-hal` 1.0.

## [0.13.0] - 2022-05-24

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"microbit-common",
"microbit",
Expand Down
8 changes: 4 additions & 4 deletions examples/analog-v1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cortex-m = { version = "0.7.3", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.3.2"
defmt = "0.3.1"
defmt-rtt = "0.4.0"
defmt = "0.3.6"

# NOTE: This currently only works with the microbit v1 due to naming issues!
# ADC vs SAADC
Expand Down
39 changes: 12 additions & 27 deletions examples/analog-v1/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use defmt_rtt as _;
use panic_halt as _;

use cortex_m_rt::entry;

use microbit::{
board::Board,
display::blocking::Display,
hal::{adc::AdcConfig, prelude::*, Adc, Timer},
hal::{adc::AdcConfig, Adc, Timer},
};

#[entry]
Expand Down Expand Up @@ -66,33 +65,19 @@ fn main() -> ! {
[0, 0, 1, 0, 0],
];

#[allow(non_snake_case)]
let letter_E = [
[0, 1, 1, 1, 0],
[0, 1, 0, 0, 0],
[0, 1, 1, 0, 0],
[0, 1, 0, 0, 0],
[0, 1, 1, 1, 0],
];

loop {
let analog = adc.read(&mut anapin);
match analog {
Ok(v) => {
let n_iter = numbers.iter();
let mut count: usize = 0;
for n_val in n_iter {
if count == usize::from(i16::unsigned_abs(v / 100)) {
display.show(&mut timer, *n_val, 10);
break;
}
count += 1;
}
if count == numbers.len() {
display.show(&mut timer, sign_plus, 10);
}
let analog_value = adc.read_channel(&mut anapin);
let n_iter = numbers.iter();
let mut count: usize = 0;
for n_val in n_iter {
if count == usize::from(i16::unsigned_abs(analog_value / 100)) {
display.show(&mut timer, *n_val, 10);
break;
}
Err(_e) => display.show(&mut timer, letter_E, 10),
count += 1;
}
if count == numbers.len() {
display.show(&mut timer, sign_plus, 10);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/analog-v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cortex-m = { version = "0.7.3", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.3.2"
defmt = "0.3.1"
defmt-rtt = "0.4.0"
defmt = "0.3.6"

# NOTE: This currently only works with the microbit v2 due to naming issues!
# ADC vs SAADC
Expand Down
5 changes: 2 additions & 3 deletions examples/analog-v2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use defmt_rtt as _;
use panic_halt as _;

use cortex_m_rt::entry;

use microbit::{
board::Board,
display::blocking::Display,
hal::{prelude::*, saadc::SaadcConfig, Saadc, Timer},
hal::{saadc::SaadcConfig, Saadc, Timer},
};

#[entry]
Expand Down Expand Up @@ -76,7 +75,7 @@ fn main() -> ! {
];

loop {
let analog = adc.read(&mut anapin);
let analog = adc.read_channel(&mut anapin);
match analog {
Ok(v) => {
let n_iter = numbers.iter();
Expand Down
8 changes: 4 additions & 4 deletions examples/analog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cortex-m = { version = "0.7.3", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.3.2"
defmt = "0.3.1"
defmt-rtt = "0.4.0"
defmt = "0.3.6"

[dependencies.microbit]
path = "../../microbit"
Expand Down
37 changes: 19 additions & 18 deletions examples/analog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ use defmt_rtt as _;
use panic_halt as _;

use cortex_m_rt::entry;

use microbit::{
adc::{Adc, AdcConfig, Default},
board::Board,
display::blocking::Display,
hal::{prelude::*, Timer},
hal::Timer,
};

#[entry]
Expand Down Expand Up @@ -67,6 +66,7 @@ fn main() -> ! {
[0, 0, 1, 0, 0],
];

#[cfg(feature = "v2")]
#[allow(non_snake_case)]
let letter_E = [
[0, 1, 1, 1, 0],
Expand All @@ -77,23 +77,24 @@ fn main() -> ! {
];

loop {
let analog = adc.read(&mut anapin);
match analog {
Ok(v) => {
let n_iter = numbers.iter();
let mut count: usize = 0;
for n_val in n_iter {
if count == usize::from(i16::unsigned_abs(v / 100)) {
display.show(&mut timer, *n_val, 10);
break;
}
count += 1;
}
if count == numbers.len() {
display.show(&mut timer, sign_plus, 10);
}
let analog = adc.read_channel(&mut anapin);
#[cfg(feature = "v2")]
let Ok(analog) = analog
else {
display.show(&mut timer, letter_E, 10);
continue;
};
let n_iter = numbers.iter();
let mut count: usize = 0;
for n_val in n_iter {
if count == usize::from(i16::unsigned_abs(analog / 100)) {
display.show(&mut timer, *n_val, 10);
break;
}
Err(_e) => display.show(&mut timer, letter_E, 10),
count += 1;
}
if count == numbers.len() {
display.show(&mut timer, sign_plus, 10);
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions examples/display-blocking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ version = "0.1.0"
edition = "2018"

[dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.4"
defmt = "0.3.1"
defmt-rtt = "0.4.0"
defmt = "0.3.6"
embedded-hal = "1.0.0"

[dependencies.microbit]
path = "../../microbit"
Expand Down
8 changes: 2 additions & 6 deletions examples/display-blocking/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ use defmt_rtt as _;
use panic_halt as _;

use cortex_m_rt::entry;

use microbit::{
board::Board,
display::blocking::Display,
hal::{prelude::*, Timer},
};
use embedded_hal::delay::DelayNs;
use microbit::{board::Board, display::blocking::Display, hal::Timer};

#[entry]
fn main() -> ! {
Expand Down
8 changes: 4 additions & 4 deletions examples/display-nonblocking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ version = "0.1.0"
edition = "2018"

[dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.4"
defmt = "0.3.1"
defmt-rtt = "0.4.0"
defmt = "0.3.6"

[dependencies.microbit]
path = "../../microbit"
Expand Down
1 change: 0 additions & 1 deletion examples/display-nonblocking/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use panic_halt as _;

use core::cell::RefCell;
use cortex_m::interrupt::Mutex;
use cortex_m::peripheral::Peripherals;
use cortex_m_rt::entry;

use microbit::{
Expand Down
8 changes: 4 additions & 4 deletions examples/display-rtic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ version = "0.1.0"
edition = "2018"

[dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"]}
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
panic-halt = "0.2.0"
defmt-rtt = "0.4"
defmt = "0.3.1"
cortex-m-rtic = { version = "1.1" }
defmt-rtt = "0.4.0"
defmt = "0.3.6"
cortex-m-rtic = { version = "1.1.4" }

[dependencies.microbit]
path = "../../microbit"
Expand Down
8 changes: 4 additions & 4 deletions examples/display-text-rtic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ version = "0.1.0"
edition = "2018"

[dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"]}
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
panic-halt = "0.2.0"
defmt-rtt = "0.4"
defmt = "0.3.1"
cortex-m-rtic = { version = "1.0.0" }
defmt-rtt = "0.4.0"
defmt = "0.3.6"
cortex-m-rtic = { version = "1.1.4" }
microbit-text = "1.0.0"

[dependencies.microbit]
Expand Down
6 changes: 3 additions & 3 deletions examples/gpio-direct-blinky/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ version = "0.1.0"
edition = "2018"

[dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt = "0.3.1"
defmt = "0.3.6"

[dependencies.microbit]
path = "../../microbit"
Expand Down
8 changes: 4 additions & 4 deletions examples/gpio-hal-blinky/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ version = "0.1.0"
edition = "2018"

[dependencies]
embedded-hal = "0.2.4"
cortex-m-rt = "0.7"
embedded-hal = "1.0.0"
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.4"
defmt = "0.3.1"
defmt-rtt = "0.4.0"
defmt = "0.3.6"

[dependencies.microbit]
path = "../../microbit"
Expand Down
6 changes: 3 additions & 3 deletions examples/gpio-hal-blinky/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use panic_halt as _;

use cortex_m_rt::entry;
use embedded_hal::{blocking::delay::DelayMs, digital::v2::OutputPin};
use embedded_hal::{delay::DelayNs, digital::OutputPin};
use microbit::{board::Board, hal::timer::Timer};

#[entry]
Expand All @@ -18,8 +18,8 @@ fn main() -> ! {

loop {
let _ = row1.set_low();
timer.delay_ms(1_000_u16);
timer.delay_ms(1_000);
let _ = row1.set_high();
timer.delay_ms(1_000_u16);
timer.delay_ms(1_000);
}
}
9 changes: 5 additions & 4 deletions examples/gpio-hal-ledbutton/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ version = "0.1.0"
edition = "2018"

[dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.4"
defmt = "0.3.1"
defmt-rtt = "0.4.0"
defmt = "0.3.6"
embedded-hal = "1.0.0"

[dependencies.microbit]
path = "../../microbit"
Expand Down
3 changes: 2 additions & 1 deletion examples/gpio-hal-ledbutton/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use defmt_rtt as _;
use panic_halt as _;

use cortex_m_rt::entry;
use microbit::{board::Board, hal::prelude::*};
use embedded_hal::digital::{InputPin, OutputPin};
use microbit::board::Board;

#[entry]
fn main() -> ! {
Expand Down
8 changes: 4 additions & 4 deletions examples/gpio-hal-printbuttons/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ version = "0.1.0"
edition = "2018"

[dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.3"
panic-halt = "0.2.0"
defmt-rtt = "0.4"
defmt = "0.3.1"
defmt-rtt = "0.4.0"
defmt = "0.3.6"

[dependencies.microbit]
path = "../../microbit"
Expand Down
Loading
Loading