Skip to content

Commit

Permalink
gpio: add dynamic pin support and conversion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
astapleton committed Oct 10, 2024
1 parent 5118c26 commit 8d0dfa7
Show file tree
Hide file tree
Showing 4 changed files with 650 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,32 @@
//! If you need a more temporary mode change, and can not use the `into_<mode>` functions for
//! ownership reasons, you can use the closure based `with_<mode>` functions to temporarily change the pin type, do
//! some output or input, and then have it change back once done.
//!
//! ### Dynamic Mode Change
//! The above mode change methods guarantee that you can only call input functions when the pin is
//! in input mode, and output when in output modes, but can lead to some issues. Therefore, there
//! is also a mode where the state is kept track of at runtime, allowing you to change the mode
//! often, and without problems with ownership, or references, at the cost of some performance and
//! the risk of runtime errors.
//!
//! To make a pin dynamic, use the `into_dynamic` function, and then use the `make_<mode>` functions to
//! change the mode
mod convert;
mod dynamic;
mod erased;
mod exti;
mod gpio_def;
mod partially_erased;

use core::{fmt, marker::PhantomData};

pub use embedded_hal::digital::PinState;

use crate::rcc::ResetEnable;

pub use convert::PinMode;
pub use dynamic::{Dynamic, DynamicPin};
pub use embedded_hal::digital::PinState;

pub use erased::{EPin, ErasedPin};
pub use exti::ExtiPin;
pub use gpio_def::*;
Expand Down Expand Up @@ -166,10 +180,8 @@ mod marker {
/// Marker trait for active pin modes
pub trait Active {}
/// Marker trait for all pin modes except alternate
#[allow(dead_code)] // TODO: Remove when alternate function conversion is implemented
pub trait NotAlt {}
/// Marker trait for pins with alternate function `A` mapping
#[allow(dead_code)] // TODO: Remove when alternate function conversion is implemented
pub trait IntoAf<const A: u8> {}
}

Expand Down
Loading

0 comments on commit 8d0dfa7

Please sign in to comment.