Skip to content

Commit

Permalink
Remove gpio dispatch macro-defining proc macro (#2069)
Browse files Browse the repository at this point in the history
* Keep a single PinType trait

* Merge impl blocks

* Deduplicate usb pad workaround

* Deduplicate some bit manipulation

* Remove gpio dispatch proc macro

* Inline PinType into GpioProperties
  • Loading branch information
bugadani authored Sep 4, 2024
1 parent 99bf346 commit 39109a4
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 320 deletions.
77 changes: 0 additions & 77 deletions esp-hal-procmacros/src/enum_dispatch.rs

This file was deleted.

33 changes: 0 additions & 33 deletions esp-hal-procmacros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ use proc_macro::TokenStream;

#[cfg(feature = "embassy")]
mod embassy;
#[cfg(feature = "enum-dispatch")]
mod enum_dispatch;
#[cfg(feature = "interrupt")]
mod interrupt;
#[cfg(any(
Expand Down Expand Up @@ -339,37 +337,6 @@ pub fn handler(args: TokenStream, input: TokenStream) -> TokenStream {
.into()
}

/// Create an enum for erased GPIO pins, using the enum-dispatch pattern
///
/// Only used internally
#[cfg(feature = "enum-dispatch")]
#[proc_macro]
pub fn make_gpio_enum_dispatch_macro(input: TokenStream) -> TokenStream {
use quote::{format_ident, quote};

use self::enum_dispatch::{build_match_arms, MakeGpioEnumDispatchMacro};

let input = syn::parse_macro_input!(input as MakeGpioEnumDispatchMacro);

let macro_name = format_ident!("{}", input.name);
let arms = build_match_arms(input);

quote! {
#[doc(hidden)]
#[macro_export]
macro_rules! #macro_name {
($m:ident, $target:ident, $body:block) => {
match $m {
#(#arms)*
}
}
}

pub(crate) use #macro_name;
}
.into()
}

/// Load code to be run on the LP/ULP core.
///
/// ## Example
Expand Down
Loading

0 comments on commit 39109a4

Please sign in to comment.