diff --git a/CHANGELOG.md b/CHANGELOG.md index a244848..d8b4d12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Cargo.toml b/Cargo.toml index 10c2d14..28f2e0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "microbit-common", "microbit", diff --git a/examples/analog-v1/Cargo.toml b/examples/analog-v1/Cargo.toml index 07d10f9..117aa5c 100644 --- a/examples/analog-v1/Cargo.toml +++ b/examples/analog-v1/Cargo.toml @@ -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 diff --git a/examples/analog-v1/src/main.rs b/examples/analog-v1/src/main.rs index 51634c9..c73e55e 100644 --- a/examples/analog-v1/src/main.rs +++ b/examples/analog-v1/src/main.rs @@ -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] @@ -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); } } } diff --git a/examples/analog-v2/Cargo.toml b/examples/analog-v2/Cargo.toml index f7991cf..785529a 100644 --- a/examples/analog-v2/Cargo.toml +++ b/examples/analog-v2/Cargo.toml @@ -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 diff --git a/examples/analog-v2/src/main.rs b/examples/analog-v2/src/main.rs index 205e77f..0e84796 100644 --- a/examples/analog-v2/src/main.rs +++ b/examples/analog-v2/src/main.rs @@ -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] @@ -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(); diff --git a/examples/analog/Cargo.toml b/examples/analog/Cargo.toml index b96df73..3cf2c33 100644 --- a/examples/analog/Cargo.toml +++ b/examples/analog/Cargo.toml @@ -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" diff --git a/examples/analog/src/main.rs b/examples/analog/src/main.rs index e2ecf63..6a4bde0 100644 --- a/examples/analog/src/main.rs +++ b/examples/analog/src/main.rs @@ -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] @@ -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], @@ -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); } } } diff --git a/examples/display-blocking/Cargo.toml b/examples/display-blocking/Cargo.toml index e67187b..2648073 100644 --- a/examples/display-blocking/Cargo.toml +++ b/examples/display-blocking/Cargo.toml @@ -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" diff --git a/examples/display-blocking/src/main.rs b/examples/display-blocking/src/main.rs index 95903b9..bbabb47 100644 --- a/examples/display-blocking/src/main.rs +++ b/examples/display-blocking/src/main.rs @@ -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() -> ! { diff --git a/examples/display-nonblocking/Cargo.toml b/examples/display-nonblocking/Cargo.toml index fde153b..035a850 100644 --- a/examples/display-nonblocking/Cargo.toml +++ b/examples/display-nonblocking/Cargo.toml @@ -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" diff --git a/examples/display-nonblocking/src/main.rs b/examples/display-nonblocking/src/main.rs index a23ae94..228e39c 100644 --- a/examples/display-nonblocking/src/main.rs +++ b/examples/display-nonblocking/src/main.rs @@ -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::{ diff --git a/examples/display-rtic/Cargo.toml b/examples/display-rtic/Cargo.toml index 690f405..854eafb 100644 --- a/examples/display-rtic/Cargo.toml +++ b/examples/display-rtic/Cargo.toml @@ -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" diff --git a/examples/display-text-rtic/Cargo.toml b/examples/display-text-rtic/Cargo.toml index 6a858b3..d495123 100644 --- a/examples/display-text-rtic/Cargo.toml +++ b/examples/display-text-rtic/Cargo.toml @@ -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] diff --git a/examples/gpio-direct-blinky/Cargo.toml b/examples/gpio-direct-blinky/Cargo.toml index 70b9f68..6bd4b12 100644 --- a/examples/gpio-direct-blinky/Cargo.toml +++ b/examples/gpio-direct-blinky/Cargo.toml @@ -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" diff --git a/examples/gpio-hal-blinky/Cargo.toml b/examples/gpio-hal-blinky/Cargo.toml index 57b4213..b8dd3f4 100644 --- a/examples/gpio-hal-blinky/Cargo.toml +++ b/examples/gpio-hal-blinky/Cargo.toml @@ -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" diff --git a/examples/gpio-hal-blinky/src/main.rs b/examples/gpio-hal-blinky/src/main.rs index 3e860ef..7a9e5c6 100644 --- a/examples/gpio-hal-blinky/src/main.rs +++ b/examples/gpio-hal-blinky/src/main.rs @@ -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] @@ -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); } } diff --git a/examples/gpio-hal-ledbutton/Cargo.toml b/examples/gpio-hal-ledbutton/Cargo.toml index 573d2d1..454f570 100644 --- a/examples/gpio-hal-ledbutton/Cargo.toml +++ b/examples/gpio-hal-ledbutton/Cargo.toml @@ -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" diff --git a/examples/gpio-hal-ledbutton/src/main.rs b/examples/gpio-hal-ledbutton/src/main.rs index 5b3176e..5e0483b 100644 --- a/examples/gpio-hal-ledbutton/src/main.rs +++ b/examples/gpio-hal-ledbutton/src/main.rs @@ -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() -> ! { diff --git a/examples/gpio-hal-printbuttons/Cargo.toml b/examples/gpio-hal-printbuttons/Cargo.toml index 78378dd..fff23f2 100644 --- a/examples/gpio-hal-printbuttons/Cargo.toml +++ b/examples/gpio-hal-printbuttons/Cargo.toml @@ -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" diff --git a/examples/magnetometer/Cargo.toml b/examples/magnetometer/Cargo.toml index d1e7c81..a221d11 100644 --- a/examples/magnetometer/Cargo.toml +++ b/examples/magnetometer/Cargo.toml @@ -4,12 +4,13 @@ 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" +embedded-hal = "1.0.0" panic-halt = "0.2.0" -defmt-rtt = "0.4" -defmt = "0.3" -lsm303agr = "0.2.0" +defmt-rtt = "0.4.0" +defmt = "0.3.6" +lsm303agr = "0.2.2" [dependencies.microbit] path = "../../microbit" diff --git a/examples/magnetometer/src/main.rs b/examples/magnetometer/src/main.rs index 39b09e3..e06ef20 100644 --- a/examples/magnetometer/src/main.rs +++ b/examples/magnetometer/src/main.rs @@ -5,8 +5,11 @@ use defmt_rtt as _; use panic_halt as _; use cortex_m_rt::entry; - -use microbit::hal::{prelude::*, Timer}; +use embedded_hal::delay::DelayNs; +use lsm303agr::{ + interface::I2cInterface, mode::MagOneShot, AccelMode, AccelOutputDataRate, Lsm303agr, +}; +use microbit::hal::Timer; #[cfg(feature = "v1")] use microbit::{ @@ -19,10 +22,6 @@ use microbit::{ pac::{twim0::frequency::FREQUENCY_A, TWIM0}, }; -use lsm303agr::{ - interface::I2cInterface, mode::MagOneShot, AccelMode, AccelOutputDataRate, Lsm303agr, -}; - #[entry] fn main() -> ! { let board = microbit::Board::take().unwrap(); diff --git a/examples/rng-direct/Cargo.toml b/examples/rng-direct/Cargo.toml index 2bd0043..a409566 100644 --- a/examples/rng-direct/Cargo.toml +++ b/examples/rng-direct/Cargo.toml @@ -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" diff --git a/examples/rng-hal/Cargo.toml b/examples/rng-hal/Cargo.toml index 3e3dcd4..7a7686c 100644 --- a/examples/rng-hal/Cargo.toml +++ b/examples/rng-hal/Cargo.toml @@ -4,19 +4,19 @@ 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.rand] default-features = false -version = "0.8.3" +version = "0.8.5" [dependencies.rand_pcg] default-features = false -version = "0.3.0" +version = "0.3.1" [dependencies.microbit] path = "../../microbit" diff --git a/examples/serial-direct-echo/Cargo.toml b/examples/serial-direct-echo/Cargo.toml index c72796f..709e14c 100644 --- a/examples/serial-direct-echo/Cargo.toml +++ b/examples/serial-direct-echo/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2018" [dependencies] -cortex-m-rt = "0.7" +cortex-m-rt = "0.7.3" panic-halt = "0.2.0" -defmt-rtt = "0.4" +defmt-rtt = "0.4.0" [dependencies.microbit] path = "../../microbit" diff --git a/examples/serial-direct-helloworld/Cargo.toml b/examples/serial-direct-helloworld/Cargo.toml index 151a79e..79fffb9 100644 --- a/examples/serial-direct-helloworld/Cargo.toml +++ b/examples/serial-direct-helloworld/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2018" [dependencies] -cortex-m-rt = "0.7" +cortex-m-rt = "0.7.3" panic-halt = "0.2.0" -defmt-rtt = "0.4" +defmt-rtt = "0.4.0" [dependencies.microbit] path = "../../microbit" diff --git a/examples/serial-hal-blocking-echo/Cargo.toml b/examples/serial-hal-blocking-echo/Cargo.toml index 0d275d6..518ded4 100644 --- a/examples/serial-hal-blocking-echo/Cargo.toml +++ b/examples/serial-hal-blocking-echo/Cargo.toml @@ -8,7 +8,8 @@ cortex-m-rt = "0.7" panic-halt = "0.2.0" defmt-rtt = "0.4" nb = "1.0.0" -embedded-hal = "0.2.6" +embedded-hal = "1.0.0" +embedded-io = "0.6.1" [dependencies.microbit] path = "../../microbit" diff --git a/examples/serial-hal-blocking-echo/src/main.rs b/examples/serial-hal-blocking-echo/src/main.rs index ef07833..1ca3bcb 100644 --- a/examples/serial-hal-blocking-echo/src/main.rs +++ b/examples/serial-hal-blocking-echo/src/main.rs @@ -4,23 +4,21 @@ use panic_halt as _; use core::fmt::Write; +use cortex_m_rt::entry; +use embedded_io::Read; #[cfg(feature = "v1")] use microbit::{ - hal::prelude::*, hal::uart, hal::uart::{Baudrate, Parity}, }; #[cfg(feature = "v2")] use microbit::{ - hal::prelude::*, hal::uarte, hal::uarte::{Baudrate, Parity}, }; -use cortex_m_rt::entry; - #[cfg(feature = "v2")] mod serial_setup; #[cfg(feature = "v2")] @@ -53,7 +51,8 @@ fn main() -> ! { loop { write!(serial, "Hello World:\r\n").unwrap(); - let input = nb::block!(serial.read()).unwrap(); - write!(serial, "You said: {}\r\n", input as char).unwrap(); + let mut input = [0]; + serial.read_exact(&mut input).unwrap(); + write!(serial, "You said: {}\r\n", input[0] as char).unwrap(); } } diff --git a/examples/serial-hal-blocking-echo/src/serial_setup.rs b/examples/serial-hal-blocking-echo/src/serial_setup.rs index eb3997a..7246a4a 100644 --- a/examples/serial-hal-blocking-echo/src/serial_setup.rs +++ b/examples/serial-hal-blocking-echo/src/serial_setup.rs @@ -1,6 +1,4 @@ -use core::fmt; -use embedded_hal::blocking::serial as bserial; -use embedded_hal::serial; +use core::{fmt, ptr::addr_of_mut}; use microbit::hal::uarte::{Error, Instance, Uarte, UarteRx, UarteTx}; static mut TX_BUF: [u8; 1] = [0; 1]; @@ -11,7 +9,9 @@ pub struct UartePort(UarteTx, UarteRx); impl UartePort { pub fn new(serial: Uarte) -> UartePort { let (tx, rx) = serial - .split(unsafe { &mut TX_BUF }, unsafe { &mut RX_BUF }) + .split(unsafe { addr_of_mut!(TX_BUF).as_mut().unwrap() }, unsafe { + addr_of_mut!(RX_BUF).as_mut().unwrap() + }) .unwrap(); UartePort(tx, rx) } @@ -23,24 +23,22 @@ impl fmt::Write for UartePort { } } -impl serial::Write for UartePort { +impl embedded_io::ErrorType for UartePort { type Error = Error; +} - fn write(&mut self, b: u8) -> nb::Result<(), Self::Error> { - self.0.write(b) +impl embedded_io::Write for UartePort { + fn write(&mut self, buffer: &[u8]) -> Result { + self.0.write(buffer) } - fn flush(&mut self) -> nb::Result<(), Self::Error> { + fn flush(&mut self) -> Result<(), Self::Error> { self.0.flush() } } -impl bserial::write::Default for UartePort {} - -impl serial::Read for UartePort { - type Error = Error; - - fn read(&mut self) -> nb::Result { - self.1.read() +impl embedded_io::Read for UartePort { + fn read(&mut self, buffer: &mut [u8]) -> Result { + self.1.read(buffer) } } diff --git a/examples/servo/Cargo.toml b/examples/servo/Cargo.toml index cc66bac..faf08c2 100644 --- a/examples/servo/Cargo.toml +++ b/examples/servo/Cargo.toml @@ -7,10 +7,10 @@ edition = "2021" [dependencies] cortex-m = { version = "0.7.7", features = ["critical-section-single-core"]} -cortex-m-rt = "0.7" +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" diff --git a/examples/v2-microphone/Cargo.toml b/examples/v2-microphone/Cargo.toml index c7cf8a9..ff2d506 100644 --- a/examples/v2-microphone/Cargo.toml +++ b/examples/v2-microphone/Cargo.toml @@ -4,12 +4,12 @@ version = "0.1.0" edition = "2018" [dependencies] -cortex-m = { version = "0.7", features = ["critical-section-single-core"]} -embedded-hal = "0.2.4" -cortex-m-rt = "0.7.2" +cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] } +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-v2] path = "../../microbit-v2" diff --git a/examples/v2-microphone/src/main.rs b/examples/v2-microphone/src/main.rs index b00061a..780ba2f 100644 --- a/examples/v2-microphone/src/main.rs +++ b/examples/v2-microphone/src/main.rs @@ -5,13 +5,11 @@ use defmt_rtt as _; use panic_halt as _; use cortex_m_rt::entry; - use microbit::{ board::Board, display::blocking::Display, hal::{ gpio::{Level, OpenDrainConfig}, - prelude::*, saadc::SaadcConfig, Saadc, Timer, }, @@ -39,7 +37,7 @@ fn main() -> ! { let mut max_value: u16 = 0; loop { let mic_value = saadc - .read(&mut mic_in) + .read_channel(&mut mic_in) .expect("could not read value of microphone") as u16; // Smoothen the signal as audio comes in waves diff --git a/examples/v2-speaker/Cargo.toml b/examples/v2-speaker/Cargo.toml index 4b26115..0f13b70 100644 --- a/examples/v2-speaker/Cargo.toml +++ b/examples/v2-speaker/Cargo.toml @@ -4,12 +4,12 @@ version = "0.1.0" edition = "2018" [dependencies] -cortex-m = { version = "0.7", features = ["critical-section-single-core"]} -embedded-hal = "0.2.4" -cortex-m-rt = "0.7" +cortex-m = { version = "0.7.7", features = ["critical-section-single-core"]} +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 = "0.3.6" [dependencies.microbit-v2] path = "../../microbit-v2" diff --git a/examples/v2-speaker/src/main.rs b/examples/v2-speaker/src/main.rs index 260d591..dcdab27 100644 --- a/examples/v2-speaker/src/main.rs +++ b/examples/v2-speaker/src/main.rs @@ -6,14 +6,12 @@ use panic_halt as _; use core::cell::RefCell; use cortex_m::interrupt::Mutex; - use cortex_m_rt::entry; +use embedded_hal::digital::OutputPin; use microbit::{ hal::{ clocks::Clocks, - gpio, - prelude::OutputPin, - pwm, + gpio, pwm, rtc::{Rtc, RtcInterrupt}, time::Hertz, }, diff --git a/microbit-common/Cargo.toml b/microbit-common/Cargo.toml index 2718b20..6662cc6 100644 --- a/microbit-common/Cargo.toml +++ b/microbit-common/Cargo.toml @@ -25,16 +25,16 @@ keywords = [ license = "0BSD" [dependencies] -tiny-led-matrix = "1.0.1" -embedded-hal = "0.2.4" +tiny-led-matrix = "1.0.2" +embedded-hal = "1.0.0" [dependencies.nrf51-hal] optional = true -version = "0.14.0" +version = "0.17.0" [dependencies.nrf52833-hal] optional = true -version = "0.14.0" +version = "0.17.0" [features] doc = [] diff --git a/microbit-common/src/display/blocking.rs b/microbit-common/src/display/blocking.rs index b17245a..9c209f2 100644 --- a/microbit-common/src/display/blocking.rs +++ b/microbit-common/src/display/blocking.rs @@ -13,7 +13,7 @@ //! # hal, //! # display::blocking::Display, //! # }; -//! # use embedded_hal::blocking::delay::DelayMs; +//! # use embedded_hal::delay::DelayNs; //! // take the board //! let board = Board::take().unwrap(); //! // make a timer @@ -31,7 +31,7 @@ //! loop { //! display.show(&mut timer, heart, 1000); //! display.clear(); -//! timer.delay_ms(250u32); +//! timer.delay_ms(250); //! } //! ``` //! @@ -63,14 +63,9 @@ //! Will display an arrow pointing towards the boards usb port. //! //! For a working example [`examples/display-blocking`](https://github.com/nrf-rs/microbit/tree/main/examples/display-blocking) -use crate::hal::{ - gpio::{Output, Pin, PushPull}, - prelude::*, -}; - use crate::gpio::{DisplayPins, NUM_COLS, NUM_ROWS}; - -use embedded_hal::blocking::delay::DelayUs; +use crate::hal::gpio::{Output, Pin, PushPull}; +use embedded_hal::{delay::DelayNs, digital::OutputPin}; #[allow(clippy::upper_case_acronyms)] pub(crate) type LED = Pin>; @@ -142,12 +137,7 @@ impl Display { } /// Display 5x5 image for a given duration - pub fn show>( - &mut self, - delay: &mut D, - led_display: [[u8; 5]; 5], - duration_ms: u32, - ) { + pub fn show(&mut self, delay: &mut D, led_display: [[u8; 5]; 5], duration_ms: u32) { #[cfg(feature = "v1")] { let led_matrix = Display::image2matrix(led_display); @@ -161,7 +151,7 @@ impl Display { /// /// The pins are represented as a [3x9 matrix on the micro:bit /// V1](https://tech.microbit.org/hardware/1-5-revision/#display). - fn show_inner>( + fn show_inner( &mut self, delay: &mut D, led_matrix: [[u8; NUM_COLS]; NUM_ROWS], diff --git a/microbit-common/src/display/nonblocking/mod.rs b/microbit-common/src/display/nonblocking/mod.rs index bdcd275..a290173 100644 --- a/microbit-common/src/display/nonblocking/mod.rs +++ b/microbit-common/src/display/nonblocking/mod.rs @@ -22,7 +22,7 @@ //! hal, //! display::nonblocking::{Display, GreyscaleImage}, //! }; -//! use embedded_hal::blocking::delay::DelayMs; +//! use embedded_hal::delay::DelayNs; //! //! let board = Board::take().unwrap(); //! @@ -39,10 +39,10 @@ //! [0, 7, 0, 7, 0], //! [0, 0, 7, 0, 0], //! ])); -//! timer2.delay_ms(1000u32); +//! timer2.delay_ms(1000); //! //! display.clear(); -//! timer2.delay_ms(1000u32); +//! timer2.delay_ms(1000); //! } //! } //! diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index a7175ff..d77d4e4 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -4,5 +4,5 @@ version = "0.1.0" edition = "2018" [dependencies] -cargo_toml = "0.14" -chrono = "0.4.19" +cargo_toml = "0.19.2" +chrono = "0.4.37" diff --git a/xtask/src/bump.rs b/xtask/src/bump.rs index f88f4c0..62ecb0e 100644 --- a/xtask/src/bump.rs +++ b/xtask/src/bump.rs @@ -39,7 +39,7 @@ pub fn bump_versions(new_version: &str, dry_run: bool) { ); // Prepend empty "[Unreleased]" section, promote the current one. - let today = Local::today().format("%Y-%m-%d").to_string(); + let today = Local::now().date_naive().format("%Y-%m-%d").to_string(); let from = String::from("## [Unreleased]"); let to = format!( "## [Unreleased]\n\n(no changes)\n\n## [{}] - {}",