first commit
This commit is contained in:
49
src/lib.rs
Normal file
49
src/lib.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
#![no_std]
|
||||
|
||||
pub use static_pins_macros::*;
|
||||
|
||||
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 set_low();
|
||||
fn set_high();
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! impl_static_pins {
|
||||
($($pin:expr), +) => {
|
||||
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();
|
||||
}
|
||||
|
||||
$(
|
||||
impl_static_pin!($pin);
|
||||
)+
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user