From 1eaaf72374fcaabf04538afb06b57f9d04cbac61 Mon Sep 17 00:00:00 2001 From: 9names <60134748+9names@users.noreply.github.com> Date: Thu, 28 Dec 2023 23:41:35 +1100 Subject: [PATCH 1/6] Update embedded-hal to 1.0.0rc3 --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 529eec4..75b4e01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ description = "HAL for the bl602 microcontroller" [dependencies] bl602-pac = { git = "https://github.com/sipeed/bl602-pac", branch = "main" } -embedded-hal = "=1.0.0-rc.1" -embedded-hal-nb = "=1.0.0-rc.1" +embedded-hal = "=1.0.0-rc.3" +embedded-hal-nb = "=1.0.0-rc.3" embedded-time = "0.12.0" riscv = "0.10.1" nb = "1.0" From 9e69a5b2c412f773ab66fce6ea901a134631714b Mon Sep 17 00:00:00 2001 From: 9names <60134748+9names@users.noreply.github.com> Date: Thu, 28 Dec 2023 23:33:32 +1100 Subject: [PATCH 2/6] Add DelayNs impl for eh-1.0-rc3 --- src/clock.rs | 2 +- src/delay.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/clock.rs b/src/clock.rs index 53f24e8..8884381 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -27,7 +27,7 @@ use crate::delay::*; use crate::gpio::ClkCfg; use crate::pac; use core::num::NonZeroU32; -use embedded_hal::delay::DelayUs; +use embedded_hal::delay::DelayNs; use embedded_time::rate::{Extensions, Hertz}; /// Internal high-speed RC oscillator frequency diff --git a/src/delay.rs b/src/delay.rs index 67b24e5..f09da45 100644 --- a/src/delay.rs +++ b/src/delay.rs @@ -1,6 +1,6 @@ //! Delays -use embedded_hal::delay::DelayUs; +use embedded_hal::delay::DelayNs; use embedded_hal_zero::blocking::delay::{DelayMs as DelayMsZero, DelayUs as DelayUsZero}; /// Use RISCV machine-mode cycle counter (`mcycle`) as a delay provider. @@ -44,7 +44,11 @@ impl McycleDelay { } // embedded-hal 1.0 traits -impl DelayUs for McycleDelay { +impl DelayNs for McycleDelay { + /// Performs a busy-wait loop until the number of nanoseconds `ns` has elapsed + fn delay_ns(&mut self, ns: u32) { + McycleDelay::delay_cycles((ns as u64 * (self.core_frequency as u64)) / 1_000_000_000); + } /// Performs a busy-wait loop until the number of microseconds `us` has elapsed #[inline] fn delay_us(&mut self, us: u32) { From 2d9498c580c190f50048cacf70fc897391194d22 Mon Sep 17 00:00:00 2001 From: 9names <60134748+9names@users.noreply.github.com> Date: Thu, 28 Dec 2023 23:35:30 +1100 Subject: [PATCH 3/6] GPIO pin fn's take &mut for eh-1.0-rc3 --- src/gpio.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gpio.rs b/src/gpio.rs index c66ef45..55b0575 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -459,11 +459,11 @@ macro_rules! impl_glb { } impl InputPin for $Pini> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high_inner()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low_inner()) } } @@ -570,11 +570,11 @@ macro_rules! impl_glb { } impl StatefulOutputPin for $Pini> { - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_output_high_inner()) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_output_low_inner()) } } From 6ac1aa285eae4a0f477a5f28cc421e4db08618c3 Mon Sep 17 00:00:00 2001 From: 9names <60134748+9names@users.noreply.github.com> Date: Fri, 29 Dec 2023 00:59:07 +1100 Subject: [PATCH 4/6] Bump MSRV to 1.60 --- .github/workflows/ci.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49e63c4..8c4c8b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: include: # Run check with MSRV as well - - rust: 1.59.0 + - rust: 1.60.0 steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 3a4b2b7..889e351 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Matrix: [#bl602-rust:matrix.org](https://matrix.to/#/#bl602-rust:matrix.org) ## Minimum Supported Rust Version -The minimum supported Rust version (MSRV) for this project is Rust **v1.59.0**. The +The minimum supported Rust version (MSRV) for this project is Rust **v1.60.0**. The project might build on earlier versions, but this is the earliest version that is expected to work. From ee855d2669d9b39a39058fd1011fc7df3f5b5f7c Mon Sep 17 00:00:00 2001 From: 9names <60134748+9names@users.noreply.github.com> Date: Fri, 29 Dec 2023 01:02:33 +1100 Subject: [PATCH 5/6] Bump MSRV to 1.65 --- .github/workflows/ci.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c4c8b8..5b95838 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: include: # Run check with MSRV as well - - rust: 1.60.0 + - rust: 1.65.0 steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 889e351..d54dd8d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Matrix: [#bl602-rust:matrix.org](https://matrix.to/#/#bl602-rust:matrix.org) ## Minimum Supported Rust Version -The minimum supported Rust version (MSRV) for this project is Rust **v1.60.0**. The +The minimum supported Rust version (MSRV) for this project is Rust **v1.65.0**. The project might build on earlier versions, but this is the earliest version that is expected to work. From d65170b70d0d8d4b3a64891a715e82f4a00c29d6 Mon Sep 17 00:00:00 2001 From: 9names <60134748+9names@users.noreply.github.com> Date: Sat, 30 Dec 2023 12:28:29 +1100 Subject: [PATCH 6/6] Pin build deps to avoid MSRV bump --- .github/workflows/ci.yml | 2 +- Cargo.toml | 6 ++++++ README.md | 2 +- src/delay.rs | 6 +++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b95838..8c4c8b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: include: # Run check with MSRV as well - - rust: 1.65.0 + - rust: 1.60.0 steps: - uses: actions/checkout@v2 diff --git a/Cargo.toml b/Cargo.toml index 75b4e01..199149d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,12 @@ critical-section = "1.1" [build-dependencies] riscv-target = "0.1.2" +# riscv-target depends on regex, which depends on memchr. +# memchr bumped it's MSRV to 1.61 midway through 2.6.x releases +# regex increased it's MSRV to 1.65 in release 1.10.x +# pinning regex to 1.8.4 and memchr to 2.5.0 until we bump MSRV +regex = "=1.8.4" +memchr = "=2.5.0" [features] default = ["critical-section-impl"] diff --git a/README.md b/README.md index d54dd8d..889e351 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Matrix: [#bl602-rust:matrix.org](https://matrix.to/#/#bl602-rust:matrix.org) ## Minimum Supported Rust Version -The minimum supported Rust version (MSRV) for this project is Rust **v1.65.0**. The +The minimum supported Rust version (MSRV) for this project is Rust **v1.60.0**. The project might build on earlier versions, but this is the earliest version that is expected to work. diff --git a/src/delay.rs b/src/delay.rs index f09da45..e6c4a5e 100644 --- a/src/delay.rs +++ b/src/delay.rs @@ -9,15 +9,15 @@ use embedded_hal_zero::blocking::delay::{DelayMs as DelayMsZero, DelayUs as Dela /// bit-banging protocols, etc #[derive(Copy, Clone)] pub struct McycleDelay { + /// System clock frequency, used to convert clock cycles + /// into real-world time values core_frequency: u32, } impl McycleDelay { /// Constructs the delay provider based on core clock frequency `freq` pub fn new(freq: u32) -> Self { - Self { - /// System clock frequency, used to convert clock cycles - /// into real-world time values + Self { core_frequency: freq, } }