Skip to content

Commit

Permalink
Docstrings for GPIO/PinDriver
Browse files Browse the repository at this point in the history
Signed-off-by: Iván Sánchez Ortega <[email protected]>
  • Loading branch information
IvanSanchez committed Aug 18, 2024
1 parent aa0e257 commit 06778a6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/gpio.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
//! GPIO and pin configuration
//!
//! Interface for the input/output pins.
//!
//! `Gpio1` through `Gpio39` represent the *physical* pins of the ESP chip.
//!
//! *Logical* pins (compatible with `embedded_hal::digital::InputPin`/`OutputPin`)
//! are implemented through `PinDriver`.
//!
//! The ESP architecture has a I/O multiplexer, which means that (almost) any
//! physical pin can be used for any logical function (i.e. GPIO, I2C, SPI, ADC, etc).
//! Even though it's possible to use a pin for several functions at once, this
//! should be avoided. This is particularly important with the pins used for the
//! SPI RAM and the SPI Flash.
//!
//! # Examples
//!
//! Create a logical input/output pin on physical pin 2
//! ```
//! use esp_idf_hal::peripherals::Peripherals;
//! use esp_idf_hal::gpio:PinDriver;
//! use esp_idf_hal::gpio:Level;
//!
//! let physical_pin_2 = Peripherals::take().unwrap().pins.gpio2;
//!
//! // Set pin to input/output and open drain
//! let logical_pin_2 = PinDriver::input_output_od().unwrap();
//!
//! // Set pin to high
//! logical_pin_2.set_level(Level::High);
//!
//! // The logical pin implements some embedded_hal traits, so it can
//! // be used in crates that rely on those traits, e.g.:
//! use one_wire_bus::OneWire;
//! let bus = OneWire::new(logical_pin_2).unwrap();
//! ```
use core::marker::PhantomData;

Expand Down

0 comments on commit 06778a6

Please sign in to comment.