mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-02 22:55:26 +00:00
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:
parent
1afc9eef89
commit
e367c83bde
@ -16,11 +16,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Added `AnySpi` and `AnySpiDmaChannel`. (#2334)
|
- Added `AnySpi` and `AnySpiDmaChannel`. (#2334)
|
||||||
- Added `AnyI2s` and `AnyI2sDmaChannel`. (#2367)
|
- Added `AnyI2s` and `AnyI2sDmaChannel`. (#2367)
|
||||||
- `Pins::steal()` to unsafely obtain GPIO. (#2335)
|
- `Pins::steal()` to unsafely obtain GPIO. (#2335)
|
||||||
|
- `I2c::with_timeout` (#2361)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Peripheral type erasure for SPI (#2334)
|
- Peripheral type erasure for SPI (#2334)
|
||||||
- Peripheral type erasure for I2S (#2367)
|
- Peripheral type erasure for I2S (#2367)
|
||||||
|
- Peripheral type erasure for I2C (#2361)
|
||||||
|
|
||||||
### Fixed
|
### 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 `i2s::{I2sWrite, I2sWriteDma, I2sRead, I2sReadDma, I2sWriteDmaAsync, I2sReadDmaAsync}` traits have been removed. (#2316)
|
||||||
- The `ledc::ChannelHW` trait is no longer generic. (#2387)
|
- The `ledc::ChannelHW` trait is no longer generic. (#2387)
|
||||||
|
- The `I2c::new_with_timeout` constructors have been removed (#2361)
|
||||||
|
|
||||||
## [0.21.1]
|
## [0.21.1]
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ peripherals:
|
|||||||
|
|
||||||
- SPI (both master and slave)
|
- SPI (both master and slave)
|
||||||
- I2S
|
- I2S
|
||||||
|
- I2C
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
-Spi<'static, SPI2, FullDuplexMode>
|
-Spi<'static, SPI2, FullDuplexMode>
|
||||||
@ -49,3 +50,12 @@ the peripheral instance has been moved to the last generic parameter position.
|
|||||||
```rust
|
```rust
|
||||||
let spi: Spi<'static, FullDuplexMode, SPI2> = Spi::new_typed(peripherals.SPI2, 1.MHz(), SpiMode::Mode0);
|
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
@ -165,14 +165,14 @@ fn main() -> ! {
|
|||||||
pub const OV2640_ADDRESS: u8 = 0x30;
|
pub const OV2640_ADDRESS: u8 = 0x30;
|
||||||
|
|
||||||
pub struct Sccb<'d, T> {
|
pub struct Sccb<'d, T> {
|
||||||
i2c: I2c<'d, T, Blocking>,
|
i2c: I2c<'d, Blocking, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T> Sccb<'d, T>
|
impl<'d, T> Sccb<'d, T>
|
||||||
where
|
where
|
||||||
T: i2c::Instance,
|
T: i2c::Instance,
|
||||||
{
|
{
|
||||||
pub fn new(i2c: I2c<'d, T, Blocking>) -> Self {
|
pub fn new(i2c: I2c<'d, Blocking, T>) -> Self {
|
||||||
Self { i2c }
|
Self { i2c }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
gpio::Io,
|
gpio::Io,
|
||||||
i2c::{I2c, Operation},
|
i2c::{I2c, Operation},
|
||||||
peripherals::I2C0,
|
|
||||||
prelude::*,
|
prelude::*,
|
||||||
Async,
|
Async,
|
||||||
Blocking,
|
Blocking,
|
||||||
@ -16,11 +15,11 @@ use esp_hal::{
|
|||||||
use hil_test as _;
|
use hil_test as _;
|
||||||
|
|
||||||
struct Context {
|
struct Context {
|
||||||
i2c: I2c<'static, I2C0, Blocking>,
|
i2c: I2c<'static, Blocking>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _async_driver_is_compatible_with_blocking_ehal() {
|
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);
|
_with_ehal(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user