diff --git a/neopixel_macros/Cargo.lock b/neopixel_macros/Cargo.lock deleted file mode 100644 index ac52083..0000000 --- a/neopixel_macros/Cargo.lock +++ /dev/null @@ -1,46 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "neopixel_macros" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "syn", -] - -[[package]] -name = "proc-macro2" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "syn" -version = "2.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" diff --git a/neopixel_macros/Cargo.toml b/neopixel_macros/Cargo.toml deleted file mode 100644 index 36b36e7..0000000 --- a/neopixel_macros/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "neopixel_macros" -version = "0.1.0" -edition = "2021" - -[lib] -proc_macro = true - -[dependencies] -syn = "2.0.58" - -[build-dependencies.proc-macro2] -version = "=1.0.79" diff --git a/neopixel_macros/rust-toolchain.toml b/neopixel_macros/rust-toolchain.toml deleted file mode 100644 index d0c456a..0000000 --- a/neopixel_macros/rust-toolchain.toml +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "nightly-2024-03-22" -components = [ "rust-src" ] -profile = "complete" diff --git a/neopixel_macros/src/lib.rs b/neopixel_macros/src/lib.rs deleted file mode 100644 index 75cbac5..0000000 --- a/neopixel_macros/src/lib.rs +++ /dev/null @@ -1,54 +0,0 @@ -#![feature(proc_macro_quote)] -#![no_std] - -use core::str::FromStr; - -extern crate alloc; - -use alloc::string::ToString; -use proc_macro::{quote, TokenStream}; -use syn::parse; - -#[proc_macro] -pub fn impl_static_pin(pin: TokenStream) -> TokenStream { - let parsing_result = parse::(pin.clone()); - - if let Ok(ident) = parsing_result { - let pin = TokenStream::from_str(ident.to_string().as_str()).unwrap(); - let mut identifier = ident.to_string(); - identifier.insert_str(1, "ORT"); - - let pin_num = identifier.pop().unwrap(); - - if pin_num.is_ascii_digit() { - let pin_num = TokenStream::from_str(&pin_num.to_string()).unwrap(); - - let port_field = TokenStream::from_str(&identifier.to_ascii_lowercase()).unwrap(); - - let port_ident = TokenStream::from_str(identifier.as_str()).unwrap(); - let trait_ident = TokenStream::from_str("StaticPin").unwrap(); - - quote! { - impl $trait_ident for $pin { - type Port = $port_ident; - const PIN_NUM: u8 = $pin_num; - - fn write(data: u8) { - unsafe { - (*Self::Port::ptr()) - .$port_field - .write(|w| w.bits(data)); - } - } - fn read() -> u8 { - unsafe { (*Self::Port::ptr()).$port_field.read().bits() } - } - } - } - } else { - unreachable!() - } - } else { - unreachable!() - } -} diff --git a/src/macros/mod.rs b/src/macros/mod.rs deleted file mode 100644 index 57d237d..0000000 --- a/src/macros/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[macro_export] -macro_rules! impl_static_pins { - ($($pin:ident),+) => { - $( - impl_static_pin!($pin); - )+ - }; -} diff --git a/src/types/mod.rs b/src/types/mod.rs deleted file mode 100644 index 7c5ec70..0000000 --- a/src/types/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod static_pin; -pub(crate) use static_pin::*; diff --git a/src/types/static_pin.rs b/src/types/static_pin.rs deleted file mode 100644 index d04b482..0000000 --- a/src/types/static_pin.rs +++ /dev/null @@ -1,16 +0,0 @@ -use arduino_hal::{hal::port::*, pac::*}; - -use crate::{impl_static_pin, impl_static_pins}; - -pub trait StaticPin { - type Port; - const PIN_NUM: u8; - - fn write(data: u8); - fn read() -> u8; -} - -impl_static_pins!( - PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PC6, PC7, PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PE2, - PE6, PF0, PF1, PF4, PF5, PF6, PF7 -);