0.21 Migration guide fixes (#2592)

This commit is contained in:
Dániel Buga 2024-11-23 16:20:14 +01:00 committed by GitHub
parent fe482bdd05
commit 3adb0b288e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -99,8 +99,8 @@ The constructors no longer take pins. Use `with_sda` and `with_scl` instead.
```diff ```diff
-use esp_hal::i2c::I2c; -use esp_hal::i2c::I2c;
+use esp_hal::i2c::{Config, I2c}; +use esp_hal::i2c::{Config, I2c};
-let i2c = I2c::new_with_timeout(peripherals.I2C0, io.pins.gpio4, io.pins.gpio5, 100.kHz(), timeout); -let i2c = I2c::new_with_timeout(peripherals.I2C0, sda, scl, 100.kHz(), timeout);
+I2c::new_with_config( +let i2c = I2c::new(
+ peripherals.I2C0, + peripherals.I2C0,
+ { + {
+ let mut config = Config::default(); + let mut config = Config::default();
@ -109,8 +109,8 @@ The constructors no longer take pins. Use `with_sda` and `with_scl` instead.
+ config + config
+ }, + },
+) +)
+.with_sda(io.pins.gpio4) +.with_sda(sda)
+.with_scl(io.pins.gpio5); +.with_scl(scl);
``` ```
### The calculation of I2C timeout has changed ### The calculation of I2C timeout has changed