Skip to content

Commit eca5943

Browse files
authored
Merge pull request #783 from stm32-rs/10bit-eh
I2C 10-bit address support (eh1)
2 parents a021893 + 4536160 commit eca5943

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

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

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

src/i2c/hal_1.rs

+32-5
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ impl<I2C: super::Instance> embedded_hal::i2c::ErrorType for super::I2c<I2C> {
44

55
mod blocking {
66
use super::super::{I2c, Instance};
7-
use embedded_hal::i2c::Operation;
7+
use embedded_hal::i2c::{Operation, SevenBitAddress, TenBitAddress};
88

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

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

1818
fn write_read(
1919
&mut self,
20-
addr: u8,
20+
addr: SevenBitAddress,
2121
bytes: &[u8],
2222
buffer: &mut [u8],
2323
) -> Result<(), Self::Error> {
@@ -26,7 +26,34 @@ mod blocking {
2626

2727
fn transaction(
2828
&mut self,
29-
addr: u8,
29+
addr: SevenBitAddress,
30+
operations: &mut [Operation<'_>],
31+
) -> Result<(), Self::Error> {
32+
self.transaction_slice(addr, operations)
33+
}
34+
}
35+
36+
impl<I2C: Instance> embedded_hal::i2c::I2c<TenBitAddress> for I2c<I2C> {
37+
fn read(&mut self, addr: TenBitAddress, buffer: &mut [u8]) -> Result<(), Self::Error> {
38+
self.read(addr, buffer)
39+
}
40+
41+
fn write(&mut self, addr: TenBitAddress, bytes: &[u8]) -> Result<(), Self::Error> {
42+
self.write(addr, bytes)
43+
}
44+
45+
fn write_read(
46+
&mut self,
47+
addr: TenBitAddress,
48+
bytes: &[u8],
49+
buffer: &mut [u8],
50+
) -> Result<(), Self::Error> {
51+
self.write_read(addr, bytes, buffer)
52+
}
53+
54+
fn transaction(
55+
&mut self,
56+
addr: TenBitAddress,
3057
operations: &mut [Operation<'_>],
3158
) -> Result<(), Self::Error> {
3259
self.transaction_slice(addr, operations)

0 commit comments

Comments
 (0)