Skip to content

Commit 9bf1f33

Browse files
authored
Clarify open drain (#3181)
* Migrationguide: Clarify how to replace `OpenDrainOutput` * Add hint to `DriveMode::OpenDrain`
1 parent 502d41f commit 9bf1f33

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

esp-hal/MIGRATING-0.23.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,16 +255,17 @@ GPIO drivers now take configuration structs.
255255

256256
The OutputOpenDrain driver has been removed. You can use `Output` instead with
257257
`DriveMode::OpenDrain`. The input-related methods of `OutputOpenDrain` (`level`,
258-
`is_high`, `is_low`) are available through the (unstable) `Flex` driver.
258+
`is_high`, `is_low`) are available through the (unstable) `Flex` driver when enabling input.
259259

260260
```diff
261-
- OutputOpenDrain::new(peripherals.GPIO0, Level::Low);
262-
+ Output::new(
263-
peripherals.GPIO0,
264-
Level::Low,
265-
OutputConfig::default()
266-
.with_drive_mode(DriveMode::OpenDrain),
267-
);
261+
- let mut gpio = OutputOpenDrain::new(peripherals.GPIO0, Level::Low);
262+
+ let mut gpio = Output::new(
263+
+ peripherals.GPIO0,
264+
+ Level::Low,
265+
+ OutputConfig::default()
266+
+ .with_drive_mode(DriveMode::OpenDrain),
267+
+ ).into_flex();
268+
+ gpio.enable_input(true);
268269
```
269270

270271
## AES DMA driver changes

esp-hal/src/gpio/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,10 @@ pub enum DriveMode {
11011101
/// logical [`Level`], but leaves the high level floating, which is then
11021102
/// determined by external hardware, or internal pull-up/pull-down
11031103
/// resistors.
1104+
#[cfg_attr(
1105+
feature = "unstable",
1106+
doc = "\n\nEnable the input related functionality by using [Output::into_flex] and enabling input via [Flex::enable_input]"
1107+
)]
11041108
OpenDrain,
11051109
}
11061110

0 commit comments

Comments
 (0)