Skip to content

Commit 655d5ba

Browse files
authored
Merge pull request #759 from jannic/v0.9.x
Prepare release 0.9.2 with e-h 1.0.0 support
2 parents 7b04000 + 0a28a1b commit 655d5ba

File tree

6 files changed

+48
-33
lines changed

6 files changed

+48
-33
lines changed

rp2040-hal/CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.9.2]
9+
10+
### Changed
11+
12+
- Update embedded-hal 1 to version 1.0.0.
13+
(This is the version of embedded-hal activated by feature
14+
"eh1_0_alpha". Embedded-hal 0.9 is still supported by default.) - @jannic
15+
816
## [0.9.1]
917

1018
### Added
@@ -339,7 +347,8 @@ The Minimum-Supported Rust Version (MSRV) for this release is 1.54.
339347

340348
- Initial release
341349

342-
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/v0.9.1...HEAD
350+
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/v0.9.2...HEAD
351+
[0.9.2]: https://github.com/rp-rs/rp-hal/compare/v0.9.1...v0.9.2
343352
[0.9.1]: https://github.com/rp-rs/rp-hal/compare/v0.9.0...v0.9.1
344353
[0.9.0]: https://github.com/rp-rs/rp-hal/compare/v0.8.1...v0.9.0
345354
[0.8.1]: https://github.com/rp-rs/rp-hal/compare/v0.8.0...v0.8.1

rp2040-hal/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rp2040-hal"
3-
version = "0.9.1"
3+
version = "0.9.2"
44
authors = ["The rp-rs Developers"]
55
edition = "2021"
66
homepage = "https://github.com/rp-rs/rp-hal"
@@ -18,8 +18,8 @@ targets = ["thumbv6m-none-eabi"]
1818
[dependencies]
1919
cortex-m = "0.7.2"
2020
embedded-hal = { version = "0.2.5", features = ["unproven"] }
21-
eh1_0_alpha = { package = "embedded-hal", version = "=1.0.0-rc.1", optional = true }
22-
eh_nb_1_0_alpha = { package = "embedded-hal-nb", version = "=1.0.0-rc.1", optional = true }
21+
eh1_0_alpha = { package = "embedded-hal", version = "1.0.0", optional = true }
22+
eh_nb_1_0_alpha = { package = "embedded-hal-nb", version = "1.0.0", optional = true }
2323
embedded-dma = "0.2.0"
2424
fugit = "0.3.6"
2525
itertools = { version = "0.10.1", default-features = false }

rp2040-hal/README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ https://github.com/rp-rs/rp-hal-boards/ for more details.
7070
To include this crate in your project, amend your `Cargo.toml` file to include
7171

7272
```toml
73-
rp2040-hal = "0.9.1"
73+
rp2040-hal = "0.9.2"
7474
```
7575

7676
To obtain a copy of the source code (e.g. if you want to propose a bug-fix or
@@ -94,16 +94,14 @@ proposed features (and known issues).
9494

9595
### Support for embedded-hal 1.0
9696

97-
We plan to support embedded-hal 1.0 soon after it is released.
98-
99-
For now, there is preliminary support for alpha/rc versions of embedded-hal, which can
100-
be enabled with the feature `eh1_0_alpha`. Please note that this support does not
97+
This crate now supports embedded-hal 1.0, albeit still optional and
98+
hidden behind the `eh1_0_alpha` feature flag. Please note that this support does not
10199
provide any semver compatibility guarantees: With that feature activated, there
102100
will be breaking changes even in minor versions of rp2040-hal.
103101

104-
Support for embedded-hal 1.0(-alpha/rc) exists in parallel to support for
105-
embedded-hal 0.2: Traits of both versions are implemented and can be used
106-
at the same time.
102+
Support for embedded-hal 1.0 exists in parallel to support for
103+
embedded-hal 0.2: Traits of both versions are implemented and can be
104+
used at the same time.
107105

108106
<!-- CONTRIBUTING -->
109107
## Contributing

rp2040-hal/src/gpio/mod.rs

+7-20
Original file line numberDiff line numberDiff line change
@@ -1398,9 +1398,7 @@ impl<T: AnyPin> embedded_hal::digital::v2::OutputPin for InOutPin<T> {
13981398

13991399
#[cfg(feature = "eh1_0_alpha")]
14001400
mod eh1 {
1401-
use eh1_0_alpha::digital::{
1402-
ErrorType, InputPin, OutputPin, StatefulOutputPin, ToggleableOutputPin,
1403-
};
1401+
use eh1_0_alpha::digital::{ErrorType, InputPin, OutputPin, StatefulOutputPin};
14041402

14051403
use super::{Error, FunctionSio, Pin, PinId, PullType, SioConfig, SioInput, SioOutput};
14061404

@@ -1434,36 +1432,25 @@ mod eh1 {
14341432
I: PinId,
14351433
P: PullType,
14361434
{
1437-
fn is_set_high(&self) -> Result<bool, Self::Error> {
1435+
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
14381436
Ok(self._is_set_high())
14391437
}
14401438

1441-
fn is_set_low(&self) -> Result<bool, Self::Error> {
1439+
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
14421440
Ok(self._is_set_low())
14431441
}
14441442
}
14451443

1446-
impl<I, P> ToggleableOutputPin for Pin<I, FunctionSio<SioOutput>, P>
1447-
where
1448-
I: PinId,
1449-
P: PullType,
1450-
{
1451-
fn toggle(&mut self) -> Result<(), Self::Error> {
1452-
self._toggle();
1453-
Ok(())
1454-
}
1455-
}
1456-
14571444
impl<I, P> InputPin for Pin<I, FunctionSio<SioInput>, P>
14581445
where
14591446
I: PinId,
14601447
P: PullType,
14611448
{
1462-
fn is_high(&self) -> Result<bool, Self::Error> {
1449+
fn is_high(&mut self) -> Result<bool, Self::Error> {
14631450
Ok(self._is_high())
14641451
}
14651452

1466-
fn is_low(&self) -> Result<bool, Self::Error> {
1453+
fn is_low(&mut self) -> Result<bool, Self::Error> {
14671454
Ok(self._is_low())
14681455
}
14691456
}
@@ -1480,11 +1467,11 @@ mod eh1 {
14801467
impl<'a, I: PinId, F: super::func::Function, P: PullType> InputPin
14811468
for super::AsInputPin<'a, I, F, P>
14821469
{
1483-
fn is_high(&self) -> Result<bool, Self::Error> {
1470+
fn is_high(&mut self) -> Result<bool, Self::Error> {
14841471
Ok(self.0._is_high())
14851472
}
14861473

1487-
fn is_low(&self) -> Result<bool, Self::Error> {
1474+
fn is_low(&mut self) -> Result<bool, Self::Error> {
14881475
Ok(self.0._is_low())
14891476
}
14901477
}

rp2040-hal/src/rom_data.rs

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ macro_rules! declare_rom_function {
150150
}
151151

152152
$(#[$outer])*
153+
/// # Safety
154+
///
155+
/// This is a low-level C function. It may be difficult to call safely from
156+
/// Rust. If in doubt, check the RP2040 datasheet for details and do your own
157+
/// safety evaluation.
153158
pub unsafe extern "C" fn $name( $($argname: $ty),* ) -> $ret {
154159
$name::ptr()($($argname),*)
155160
}

rp2040-hal/src/timer.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,26 @@ macro_rules! impl_delay_traits {
167167
impl_delay_traits!(u8, u16, u32, i32);
168168

169169
#[cfg(feature = "eh1_0_alpha")]
170-
impl eh1_0_alpha::delay::DelayUs for Timer {
170+
impl eh1_0_alpha::delay::DelayNs for Timer {
171+
fn delay_ns(&mut self, ns: u32) {
172+
// For now, just use microsecond delay, internally. Of course, this
173+
// might cause a much longer delay than necessary. So a more advanced
174+
// implementation would be desirable for sub-microsecond delays.
175+
let us = ns / 1000 + if ns % 1000 == 0 { 0 } else { 1 };
176+
// With rustc 1.73, this can be replaced by:
177+
// let us = ns.div_ceil(1000);
178+
self.delay_us_internal(us)
179+
}
180+
171181
fn delay_us(&mut self, us: u32) {
172182
self.delay_us_internal(us)
173183
}
184+
185+
fn delay_ms(&mut self, ms: u32) {
186+
for _ in 0..ms {
187+
self.delay_us_internal(1000);
188+
}
189+
}
174190
}
175191

176192
/// Implementation of the embedded_hal::Timer traits using rp2040_hal::timer counter

0 commit comments

Comments
 (0)