Skip to content

Commit

Permalink
Merge pull request #783 from stm32-rs/10bit-eh
Browse files Browse the repository at this point in the history
I2C 10-bit address support (eh1)
  • Loading branch information
burrbull authored Jul 29, 2024
2 parents a021893 + 4536160 commit eca5943
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

- I2C 10-bit address support for I2c
- I2C 10-bit address support for I2c [#772] [#783]
- `i2c_scanner` example [#758]
- Enable `sdio` for stm32f446
- port LTDC implementation and example from stm32f7xx-hal [#731]
Expand All @@ -34,7 +34,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
[#725]: https://github.com/stm32-rs/stm32f4xx-hal/pull/725
[#731]: https://github.com/stm32-rs/stm32f4xx-hal/pull/731
[#758]: https://github.com/stm32-rs/stm32f4xx-hal/pull/758
[#772]: https://github.com/stm32-rs/stm32f4xx-hal/pull/772
[#773]: https://github.com/stm32-rs/stm32f4xx-hal/pull/773
[#783]: https://github.com/stm32-rs/stm32f4xx-hal/pull/783

## [v0.21.0] - 2024-05-30

Expand Down
37 changes: 32 additions & 5 deletions src/i2c/hal_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ impl<I2C: super::Instance> embedded_hal::i2c::ErrorType for super::I2c<I2C> {

mod blocking {
use super::super::{I2c, Instance};
use embedded_hal::i2c::Operation;
use embedded_hal::i2c::{Operation, SevenBitAddress, TenBitAddress};

impl<I2C: Instance> embedded_hal::i2c::I2c for I2c<I2C> {
fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
fn read(&mut self, addr: SevenBitAddress, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.read(addr, buffer)
}

fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> {
fn write(&mut self, addr: SevenBitAddress, bytes: &[u8]) -> Result<(), Self::Error> {
self.write(addr, bytes)
}

fn write_read(
&mut self,
addr: u8,
addr: SevenBitAddress,
bytes: &[u8],
buffer: &mut [u8],
) -> Result<(), Self::Error> {
Expand All @@ -26,7 +26,34 @@ mod blocking {

fn transaction(
&mut self,
addr: u8,
addr: SevenBitAddress,
operations: &mut [Operation<'_>],
) -> Result<(), Self::Error> {
self.transaction_slice(addr, operations)
}
}

impl<I2C: Instance> embedded_hal::i2c::I2c<TenBitAddress> for I2c<I2C> {
fn read(&mut self, addr: TenBitAddress, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.read(addr, buffer)
}

fn write(&mut self, addr: TenBitAddress, bytes: &[u8]) -> Result<(), Self::Error> {
self.write(addr, bytes)
}

fn write_read(
&mut self,
addr: TenBitAddress,
bytes: &[u8],
buffer: &mut [u8],
) -> Result<(), Self::Error> {
self.write_read(addr, bytes, buffer)
}

fn transaction(
&mut self,
addr: TenBitAddress,
operations: &mut [Operation<'_>],
) -> Result<(), Self::Error> {
self.transaction_slice(addr, operations)
Expand Down

0 comments on commit eca5943

Please sign in to comment.