Skip to content

Commit 4d4940b

Browse files
committed
Auto merge of rust-embedded#36 - thejpster:input_pin, r=japaric
Add InputPin trait I needed a basic InputPin trait for the buttons on my Stellaris Launchpad.
2 parents 429daf9 + ecd1e85 commit 4d4940b

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
[package]
2-
authors = ["Jorge Aparicio <[email protected]>"]
2+
authors = [
3+
"Jorge Aparicio <[email protected]>",
4+
"Jonathan 'theJPster' Pallant <[email protected]>"
5+
]
36
categories = ["asynchronous", "embedded", "hardware-support", "no-std"]
47
description = " A Hardware Abstraction Layer (HAL) for embedded systems "
58
documentation = "https://docs.rs/embedded-hal"
69
keywords = ["hal", "IO"]
710
license = "MIT OR Apache-2.0"
811
name = "embedded-hal"
912
repository = "https://github.com/japaric/embedded-hal"
10-
version = "0.1.0"
13+
version = "0.1.1"
1114

1215
[dependencies.nb]
1316
version = "0.1.1"

src/digital.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@ pub trait OutputPin {
1414
/// Sets the pin high
1515
fn set_high(&mut self);
1616
}
17+
18+
/// Single digital input pin
19+
pub trait InputPin {
20+
/// Is the input pin high?
21+
fn is_high(&self) -> bool;
22+
23+
/// Is the input pin low?
24+
fn is_low(&self) -> bool;
25+
}

src/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub use ::timer::CountDown as _embedded_hal_timer_CountDown;
1414
pub use ::blocking::delay::DelayMs as _embedded_hal_blocking_delay_DelayMs;
1515
pub use ::blocking::delay::DelayUs as _embedded_hal_blocking_delay_DelayUs;
1616
pub use ::digital::OutputPin as _embedded_hal_digital_OutputPin;
17+
pub use ::digital::InputPin as _embedded_hal_digital_InputPin;
1718
pub use ::serial::Read as _embedded_hal_serial_Read;
1819
pub use ::serial::Write as _embedded_hal_serial_Write;
1920
pub use ::spi::FullDuplex as _embedded_hal_spi_FullDuplex;

0 commit comments

Comments
 (0)