Skip to content

Commit

Permalink
gpio: Make AnyPin, AnyInputOnlyPin, DummyPin available from gpio module
Browse files Browse the repository at this point in the history
Making these available straight from `gpio` aligns it with other Embassy
implementations (mainly nrf and stm32).

Signed-off-by: Priit Laes <[email protected]>
  • Loading branch information
plaes committed Aug 25, 2024
1 parent 0e333f7 commit d5e3acb
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- DMA buffers now don't require a static lifetime. Make sure to never `mem::forget` an in-progress DMA transfer (consider using `#[deny(clippy::mem_forget)]`) (#1837)
- SHA driver now use specific structs for the hashing algorithm instead of a parameter. (#1908)
- Remove `fn free(self)` in HMAC which goes against esp-hal API guidelines (#1972)
- `AnyPin`, `AnyInputOnyPin` and `DummyPin` are now accessible from `gpio` module (#1918)

### Fixed

Expand Down
6 changes: 0 additions & 6 deletions esp-hal/src/gpio/any_pin.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
//! Type-erased wrappers for GPIO pins.
//! These are useful to pass them into peripheral drivers.
//!
//! If you want a generic pin for GPIO input/output look into
//! [Output],[OutputOpenDrain], [Input] and [Flex].
use super::*;

#[derive(Clone, Copy)]
Expand Down
15 changes: 9 additions & 6 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
//! - [Input] pins can be used as digital inputs.
//! - [Output] and [OutputOpenDrain] pins can be used as digital outputs.
//! - [Flex] pin is a pin that can be used as an input and output pin.
//! - [any_pin::AnyPin] pin is type-erased that can be used for peripherals
//! signals.
//! - It supports inverting the pin, so the peripheral signal can be
//! inverted.
//! - [AnyPin] and [AnyInputOnlyPin] are type-erased GPIO pins with support for
//! inverted signalling.
//! - [DummyPin] is a useful for cases where peripheral driver requires a pin,
//! but real pin cannot be used.
//!
//! ## Examples
//! ### Set up a GPIO as an Output
Expand Down Expand Up @@ -67,8 +67,11 @@ use crate::{
#[cfg(touch)]
pub(crate) use crate::{touch_common, touch_into};

pub mod any_pin;
pub mod dummy_pin;
mod any_pin;
mod dummy_pin;

pub use any_pin::{AnyInputOnlyPin, AnyPin};
pub use dummy_pin::DummyPin;

#[cfg(soc_etm)]
pub mod etm;
Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! # use esp_hal::uart::{config::Config, Uart};
//! use esp_hal::gpio::{Io, any_pin::AnyPin};
//! use esp_hal::gpio::{AnyPin, Io};
//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
//!
//! let tx = AnyPin::new_inverted(io.pins.gpio1);
Expand All @@ -103,7 +103,7 @@
//! ```rust, no_run
#![doc = crate::before_snippet!()]
//! # use esp_hal::uart::{config::Config, UartTx, UartRx};
//! use esp_hal::gpio::{Io, any_pin::AnyPin};
//! use esp_hal::gpio::{AnyPin, Io};
//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
//!
//! let tx = UartTx::new(peripherals.UART0, &clocks,
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/spi_loopback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use esp_backtrace as _;
use esp_hal::{
clock::ClockControl,
delay::Delay,
gpio::{any_pin::AnyPin, Io},
gpio::{AnyPin, Io},
peripherals::Peripherals,
prelude::*,
spi::{master::Spi, SpiMode},
Expand Down
2 changes: 1 addition & 1 deletion hil-test/tests/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use critical_section::Mutex;
use esp_hal::{
clock::ClockControl,
delay::Delay,
gpio::{any_pin::AnyPin, Gpio2, Gpio3, GpioPin, Input, Io, Level, Output, Pull},
gpio::{AnyPin, Gpio2, Gpio3, GpioPin, Input, Io, Level, Output, Pull},
macros::handler,
peripherals::Peripherals,
system::SystemControl,
Expand Down
2 changes: 1 addition & 1 deletion hil-test/tests/lcd_cam_i8080.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use esp_hal::{
clock::{ClockControl, Clocks},
dma::{Dma, DmaDescriptor, DmaPriority},
dma_buffers,
gpio::dummy_pin::DummyPin,
gpio::DummyPin,
lcd_cam::{
lcd::{
i8080,
Expand Down
2 changes: 1 addition & 1 deletion hil-test/tests/lcd_cam_i8080_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use esp_hal::{
clock::{ClockControl, Clocks},
dma::{Dma, DmaDescriptor, DmaPriority},
dma_buffers,
gpio::dummy_pin::DummyPin,
gpio::DummyPin,
lcd_cam::{
lcd::{
i8080,
Expand Down

0 comments on commit d5e3acb

Please sign in to comment.