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
This commit is contained in:
Dániel Buga 2024-09-18 09:01:16 +02:00 committed by GitHub
parent 5ae76d727e
commit fc92beebe6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -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. Use `NoPin` in place of the now-removed `NO_PIN` constant.
SPI pins, when using the `with_pin` function, are no longer optional. 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 ```diff
let spi = Spi::new(peripherals.SPI2, 100.kHz(), SpiMode::Mode0) let spi = Spi::new(peripherals.SPI2, 100.kHz(), SpiMode::Mode0)

View File

@ -7,6 +7,14 @@
use super::*; use super::*;
impl crate::peripheral::Peripheral for Level {
type P = Self;
unsafe fn clone_unchecked(&mut self) -> Self::P {
*self
}
}
impl PeripheralSignal for Level { impl PeripheralSignal for Level {
fn pull_direction(&self, _pull: Pull, _internal: private::Internal) {} fn pull_direction(&self, _pull: Pull, _internal: private::Internal) {}
} }