Compare commits
6 Commits
e3e619c7ab
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d607cdec85 | |||
| 53075f63ec | |||
| 1fb1c3d573 | |||
| 9f781497d8 | |||
| 57f701e8aa | |||
| ce4ad89cf3 |
@@ -1,18 +1,17 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "static_pins"
|
name = "static-pins"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
|
||||||
test = false
|
|
||||||
|
|
||||||
[dependencies.static_pins_macros]
|
[dependencies.static_pins_macros]
|
||||||
path = "static_pins_macros"
|
path = "static_pins_macros"
|
||||||
|
|
||||||
[dependencies.arduino-hal]
|
[dependencies.arduino-hal]
|
||||||
git = "https://github.com/rahix/avr-hal"
|
git = "https://github.com/rahix/avr-hal"
|
||||||
rev = "3e362624547462928a219c40f9ea8e3a64f21e5f"
|
rev = "3e362624547462928a219c40f9ea8e3a64f21e5f"
|
||||||
features = ["sparkfun-promicro"]
|
|
||||||
|
[features]
|
||||||
|
sparkfun-promicro = ["arduino-hal/sparkfun-promicro"]
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2024-06-13"
|
channel = "nightly-2024-06-13"
|
||||||
components = [ "rust-src" ]
|
components = [ "rust-src" ]
|
||||||
profile = "minimal"
|
profile = "default"
|
||||||
|
|||||||
29
src/lib.rs
29
src/lib.rs
@@ -1,26 +1,7 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
pub use static_pins_macros::*;
|
use arduino_hal::{hal::port::*, pac::*};
|
||||||
|
use static_pins_macros::impl_static_pin;
|
||||||
pub trait StaticPinOps {
|
|
||||||
type Port;
|
|
||||||
const PIN_NUM: u8;
|
|
||||||
const PIN_POS: u8;
|
|
||||||
|
|
||||||
fn into_input();
|
|
||||||
fn into_output();
|
|
||||||
fn into_output_high();
|
|
||||||
fn into_pull_up_input();
|
|
||||||
|
|
||||||
fn write(data: u8);
|
|
||||||
fn read() -> u8;
|
|
||||||
|
|
||||||
fn is_low() -> bool;
|
|
||||||
fn is_high() -> bool;
|
|
||||||
|
|
||||||
fn set_low();
|
|
||||||
fn set_high();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_static_pins {
|
macro_rules! impl_static_pins {
|
||||||
@@ -50,3 +31,9 @@ macro_rules! impl_static_pins {
|
|||||||
)+
|
)+
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "sparkfun-promicro")]
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user