Skip to content

Commit 81f3408

Browse files
committed
separate OutputPin.toggle() into ToggleableOutputPin, provide default impl for StatefulOutputPin
1 parent 3f61ef2 commit 81f3408

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/digital.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,25 @@ pub trait OutputPin {
1111

1212
/// Output pin that can read its output state
1313
#[cfg(feature = "unproven")]
14-
trait StatefulOutputPin: OutputPin {
14+
trait StatefulOutputPin {
1515
/// Is the pin set to high?
1616
fn is_set_high(&self) -> bool;
1717

1818
/// Is the pin set to low?
1919
fn is_set_low(&self) -> bool;
20+
}
21+
22+
/// Output pin that can be toggled
23+
#[cfg(feature = "unproven")]
24+
trait ToggleableOutputPin {
25+
/// Toggle pin output
26+
fn toggle(&mut self);
27+
}
2028

29+
/// If you can read *and* write, a pin is toggleable by software. You
30+
/// may override the `toggle()` method with a hardware implementation.
31+
#[cfg(feature = "unproven")]
32+
impl<PIN: OutputPin + StatefulOutputPin> ToggleableOutputPin for PIN {
2133
/// Toggle pin output
2234
fn toggle(&mut self) {
2335
if self.is_set_low() {

0 commit comments

Comments
 (0)