diff options
Diffstat (limited to 'embassy-embedded-hal')
| -rw-r--r-- | embassy-embedded-hal/CHANGELOG.md | 8 | ||||
| -rw-r--r-- | embassy-embedded-hal/Cargo.toml | 4 | ||||
| -rw-r--r-- | embassy-embedded-hal/release.toml | 5 | ||||
| -rw-r--r-- | embassy-embedded-hal/src/adapter/blocking_async.rs | 28 |
4 files changed, 24 insertions, 21 deletions
diff --git a/embassy-embedded-hal/CHANGELOG.md b/embassy-embedded-hal/CHANGELOG.md index 224036af4..04d95415c 100644 --- a/embassy-embedded-hal/CHANGELOG.md +++ b/embassy-embedded-hal/CHANGELOG.md | |||
| @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file. | |||
| 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
| 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 | 7 | ||
| 8 | ## Unreleased | 8 | <!-- next-header --> |
| 9 | ## Unreleased - ReleaseDate | ||
| 10 | |||
| 11 | ## 0.3.1 - 2025-07-16 | ||
| 12 | |||
| 13 | - `SpiDevice` cancel safety: always set CS pin to high on drop | ||
| 14 | - Update `embassy-sync` to v0.7.0 | ||
| 9 | 15 | ||
| 10 | ## 0.3.0 - 2025-01-05 | 16 | ## 0.3.0 - 2025-01-05 |
| 11 | 17 | ||
diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index efc3173d4..aab6e0f1e 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-embedded-hal" | 2 | name = "embassy-embedded-hal" |
| 3 | version = "0.3.0" | 3 | version = "0.3.1" |
| 4 | edition = "2021" | 4 | edition = "2021" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Collection of utilities to use `embedded-hal` and `embedded-storage` traits with Embassy." | 6 | description = "Collection of utilities to use `embedded-hal` and `embedded-storage` traits with Embassy." |
| @@ -22,7 +22,7 @@ time = ["dep:embassy-time"] | |||
| 22 | default = ["time"] | 22 | default = ["time"] |
| 23 | 23 | ||
| 24 | [dependencies] | 24 | [dependencies] |
| 25 | embassy-hal-internal = { version = "0.2.0", path = "../embassy-hal-internal" } | 25 | embassy-hal-internal = { version = "0.3.0", path = "../embassy-hal-internal" } |
| 26 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } | 26 | embassy-futures = { version = "0.1.0", path = "../embassy-futures" } |
| 27 | embassy-sync = { version = "0.7.0", path = "../embassy-sync" } | 27 | embassy-sync = { version = "0.7.0", path = "../embassy-sync" } |
| 28 | embassy-time = { version = "0.4.0", path = "../embassy-time", optional = true } | 28 | embassy-time = { version = "0.4.0", path = "../embassy-time", optional = true } |
diff --git a/embassy-embedded-hal/release.toml b/embassy-embedded-hal/release.toml new file mode 100644 index 000000000..fb6feaf21 --- /dev/null +++ b/embassy-embedded-hal/release.toml | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | pre-release-replacements = [ | ||
| 2 | {file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1}, | ||
| 3 | {file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1}, | ||
| 4 | {file="CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n## Unreleased - ReleaseDate\n", exactly=1}, | ||
| 5 | ] | ||
diff --git a/embassy-embedded-hal/src/adapter/blocking_async.rs b/embassy-embedded-hal/src/adapter/blocking_async.rs index bafc31583..3b6e0ec00 100644 --- a/embassy-embedded-hal/src/adapter/blocking_async.rs +++ b/embassy-embedded-hal/src/adapter/blocking_async.rs | |||
| @@ -1,5 +1,3 @@ | |||
| 1 | use embedded_hal_02::blocking; | ||
| 2 | |||
| 3 | /// Wrapper that implements async traits using blocking implementations. | 1 | /// Wrapper that implements async traits using blocking implementations. |
| 4 | /// | 2 | /// |
| 5 | /// This allows driver writers to depend on the async traits while still supporting embedded-hal peripheral implementations. | 3 | /// This allows driver writers to depend on the async traits while still supporting embedded-hal peripheral implementations. |
| @@ -24,7 +22,7 @@ impl<T> BlockingAsync<T> { | |||
| 24 | impl<T, E> embedded_hal_1::i2c::ErrorType for BlockingAsync<T> | 22 | impl<T, E> embedded_hal_1::i2c::ErrorType for BlockingAsync<T> |
| 25 | where | 23 | where |
| 26 | E: embedded_hal_1::i2c::Error + 'static, | 24 | E: embedded_hal_1::i2c::Error + 'static, |
| 27 | T: blocking::i2c::WriteRead<Error = E> + blocking::i2c::Read<Error = E> + blocking::i2c::Write<Error = E>, | 25 | T: embedded_hal_1::i2c::I2c<Error = E>, |
| 28 | { | 26 | { |
| 29 | type Error = E; | 27 | type Error = E; |
| 30 | } | 28 | } |
| @@ -32,7 +30,7 @@ where | |||
| 32 | impl<T, E> embedded_hal_async::i2c::I2c for BlockingAsync<T> | 30 | impl<T, E> embedded_hal_async::i2c::I2c for BlockingAsync<T> |
| 33 | where | 31 | where |
| 34 | E: embedded_hal_1::i2c::Error + 'static, | 32 | E: embedded_hal_1::i2c::Error + 'static, |
| 35 | T: blocking::i2c::WriteRead<Error = E> + blocking::i2c::Read<Error = E> + blocking::i2c::Write<Error = E>, | 33 | T: embedded_hal_1::i2c::I2c<Error = E>, |
| 36 | { | 34 | { |
| 37 | async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { | 35 | async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { |
| 38 | self.wrapped.read(address, read) | 36 | self.wrapped.read(address, read) |
| @@ -51,9 +49,7 @@ where | |||
| 51 | address: u8, | 49 | address: u8, |
| 52 | operations: &mut [embedded_hal_1::i2c::Operation<'_>], | 50 | operations: &mut [embedded_hal_1::i2c::Operation<'_>], |
| 53 | ) -> Result<(), Self::Error> { | 51 | ) -> Result<(), Self::Error> { |
| 54 | let _ = address; | 52 | self.wrapped.transaction(address, operations) |
| 55 | let _ = operations; | ||
| 56 | todo!() | ||
| 57 | } | 53 | } |
| 58 | } | 54 | } |
| 59 | 55 | ||
| @@ -63,16 +59,16 @@ where | |||
| 63 | 59 | ||
| 64 | impl<T, E> embedded_hal_async::spi::ErrorType for BlockingAsync<T> | 60 | impl<T, E> embedded_hal_async::spi::ErrorType for BlockingAsync<T> |
| 65 | where | 61 | where |
| 66 | E: embedded_hal_1::spi::Error, | 62 | E: embedded_hal_async::spi::Error, |
| 67 | T: blocking::spi::Transfer<u8, Error = E> + blocking::spi::Write<u8, Error = E>, | 63 | T: embedded_hal_1::spi::SpiBus<Error = E>, |
| 68 | { | 64 | { |
| 69 | type Error = E; | 65 | type Error = E; |
| 70 | } | 66 | } |
| 71 | 67 | ||
| 72 | impl<T, E> embedded_hal_async::spi::SpiBus<u8> for BlockingAsync<T> | 68 | impl<T, E> embedded_hal_async::spi::SpiBus<u8> for BlockingAsync<T> |
| 73 | where | 69 | where |
| 74 | E: embedded_hal_1::spi::Error + 'static, | 70 | E: embedded_hal_async::spi::Error, |
| 75 | T: blocking::spi::Transfer<u8, Error = E> + blocking::spi::Write<u8, Error = E>, | 71 | T: embedded_hal_1::spi::SpiBus<Error = E>, |
| 76 | { | 72 | { |
| 77 | async fn flush(&mut self) -> Result<(), Self::Error> { | 73 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 78 | Ok(()) | 74 | Ok(()) |
| @@ -84,21 +80,17 @@ where | |||
| 84 | } | 80 | } |
| 85 | 81 | ||
| 86 | async fn read(&mut self, data: &mut [u8]) -> Result<(), Self::Error> { | 82 | async fn read(&mut self, data: &mut [u8]) -> Result<(), Self::Error> { |
| 87 | self.wrapped.transfer(data)?; | 83 | self.wrapped.read(data)?; |
| 88 | Ok(()) | 84 | Ok(()) |
| 89 | } | 85 | } |
| 90 | 86 | ||
| 91 | async fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { | 87 | async fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { |
| 92 | // Ensure we write the expected bytes | 88 | self.wrapped.transfer(read, write)?; |
| 93 | for i in 0..core::cmp::min(read.len(), write.len()) { | ||
| 94 | read[i] = write[i].clone(); | ||
| 95 | } | ||
| 96 | self.wrapped.transfer(read)?; | ||
| 97 | Ok(()) | 89 | Ok(()) |
| 98 | } | 90 | } |
| 99 | 91 | ||
| 100 | async fn transfer_in_place(&mut self, data: &mut [u8]) -> Result<(), Self::Error> { | 92 | async fn transfer_in_place(&mut self, data: &mut [u8]) -> Result<(), Self::Error> { |
| 101 | self.wrapped.transfer(data)?; | 93 | self.wrapped.transfer_in_place(data)?; |
| 102 | Ok(()) | 94 | Ok(()) |
| 103 | } | 95 | } |
| 104 | } | 96 | } |
