From fc92beebe6f420c55d92c1acd7d5a88709552d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Wed, 18 Sep 2024 09:01:16 +0200 Subject: [PATCH] Guide: Clarify that Level can be used as an output signal (#2176) * Clarify that Level can be used as an output signal * Implement Peripheral for Level --- esp-hal/MIGRATING-0.20.md | 2 +- esp-hal/src/gpio/placeholder.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/esp-hal/MIGRATING-0.20.md b/esp-hal/MIGRATING-0.20.md index 77544c0d4..866a74c97 100644 --- a/esp-hal/MIGRATING-0.20.md +++ b/esp-hal/MIGRATING-0.20.md @@ -172,7 +172,7 @@ configure an input pin, and pass it to `set_edge_signal` or `set_ctrl_signal`. Use `NoPin` in place of the now-removed `NO_PIN` constant. SPI pins, when using the `with_pin` function, are no longer optional. -You can pass `NoPin` or `Level` as inputs, and `NoPin` as output if you don't need a particular pin. +You can pass `NoPin` or `Level` if you don't need a particular pin. ```diff let spi = Spi::new(peripherals.SPI2, 100.kHz(), SpiMode::Mode0) diff --git a/esp-hal/src/gpio/placeholder.rs b/esp-hal/src/gpio/placeholder.rs index c984f3860..3ced27796 100644 --- a/esp-hal/src/gpio/placeholder.rs +++ b/esp-hal/src/gpio/placeholder.rs @@ -7,6 +7,14 @@ use super::*; +impl crate::peripheral::Peripheral for Level { + type P = Self; + + unsafe fn clone_unchecked(&mut self) -> Self::P { + *self + } +} + impl PeripheralSignal for Level { fn pull_direction(&self, _pull: Pull, _internal: private::Internal) {} }