esp_hal/gpio/
placeholder.rs

1//! Placeholder pins/signals.
2//!
3//! These are useful to pass them into peripheral drivers where you don't want
4//! an actual pin but one is required.
5// This module also contains peripheral signal impls for `Level` to avoid
6// polluting the main module.
7
8use super::*;
9
10/// Placeholder pin, used when no pin is required when using a peripheral.
11///
12/// When used as a peripheral signal, `NoPin` is equivalent to [`Level::Low`].
13#[derive(Default, Clone, Copy)]
14pub struct NoPin;
15
16impl private::Sealed for NoPin {}
17
18impl embedded_hal::digital::ErrorType for NoPin {
19    type Error = core::convert::Infallible;
20}
21
22impl embedded_hal::digital::OutputPin for NoPin {
23    fn set_low(&mut self) -> Result<(), Self::Error> {
24        Ok(())
25    }
26
27    fn set_high(&mut self) -> Result<(), Self::Error> {
28        Ok(())
29    }
30}
31
32impl embedded_hal::digital::StatefulOutputPin for NoPin {
33    fn is_set_high(&mut self) -> Result<bool, Self::Error> {
34        Ok(false)
35    }
36
37    fn is_set_low(&mut self) -> Result<bool, Self::Error> {
38        Ok(false)
39    }
40}