Erase i2c peripheral instances (#2361)

* Clean up

* Erase I2C instance type

* Clean up

* Implement Peripheral

* Changelog

* Remove with_timeout constructors
This commit is contained in:
Dániel Buga 2024-10-23 08:31:08 +02:00 committed by GitHub
parent 1afc9eef89
commit e367c83bde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 304 additions and 324 deletions

View File

@ -16,11 +16,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `AnySpi` and `AnySpiDmaChannel`. (#2334)
- Added `AnyI2s` and `AnyI2sDmaChannel`. (#2367)
- `Pins::steal()` to unsafely obtain GPIO. (#2335)
- `I2c::with_timeout` (#2361)
### Changed
- Peripheral type erasure for SPI (#2334)
- Peripheral type erasure for I2S (#2367)
- Peripheral type erasure for I2C (#2361)
### Fixed
@ -31,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The `i2s::{I2sWrite, I2sWriteDma, I2sRead, I2sReadDma, I2sWriteDmaAsync, I2sReadDmaAsync}` traits have been removed. (#2316)
- The `ledc::ChannelHW` trait is no longer generic. (#2387)
- The `I2c::new_with_timeout` constructors have been removed (#2361)
## [0.21.1]

View File

@ -30,6 +30,7 @@ peripherals:
- SPI (both master and slave)
- I2S
- I2C
```diff
-Spi<'static, SPI2, FullDuplexMode>
@ -49,3 +50,12 @@ the peripheral instance has been moved to the last generic parameter position.
```rust
let spi: Spi<'static, FullDuplexMode, SPI2> = Spi::new_typed(peripherals.SPI2, 1.MHz(), SpiMode::Mode0);
```
## I2C constructor changes
The `with_timeout` constructors have been removed in favour of `set_timeout` or `with_timeout`.
```diff
-let i2c = I2c::new_with_timeout(peripherals.I2C0, io.pins.gpio4, io.pins.gpio5, 100.kHz(), timeout);
+let i2c = I2c::new(peripherals.I2C0, io.pins.gpio4, io.pins.gpio5, 100.kHz()).with_timeout(timeout);
```

File diff suppressed because it is too large Load Diff

View File

@ -165,14 +165,14 @@ fn main() -> ! {
pub const OV2640_ADDRESS: u8 = 0x30;
pub struct Sccb<'d, T> {
i2c: I2c<'d, T, Blocking>,
i2c: I2c<'d, Blocking, T>,
}
impl<'d, T> Sccb<'d, T>
where
T: i2c::Instance,
{
pub fn new(i2c: I2c<'d, T, Blocking>) -> Self {
pub fn new(i2c: I2c<'d, Blocking, T>) -> Self {
Self { i2c }
}

View File

@ -8,7 +8,6 @@
use esp_hal::{
gpio::Io,
i2c::{I2c, Operation},
peripherals::I2C0,
prelude::*,
Async,
Blocking,
@ -16,11 +15,11 @@ use esp_hal::{
use hil_test as _;
struct Context {
i2c: I2c<'static, I2C0, Blocking>,
i2c: I2c<'static, Blocking>,
}
fn _async_driver_is_compatible_with_blocking_ehal() {
fn _with_driver(driver: I2c<'static, I2C0, Async>) {
fn _with_driver(driver: I2c<'static, Async>) {
_with_ehal(driver);
}