From 65178d1c850fcfdd3d81ba994dc1615df4bf88ac Mon Sep 17 00:00:00 2001 From: Javier Alvarez Date: Mon, 22 Mar 2021 23:20:54 +0100 Subject: [PATCH] Implement initial state for output pins --- avr-hal-generic/src/port.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/avr-hal-generic/src/port.rs b/avr-hal-generic/src/port.rs index 52a72bfa1c..f44dfd6904 100644 --- a/avr-hal-generic/src/port.rs +++ b/avr-hal-generic/src/port.rs @@ -107,8 +107,21 @@ impl Pin, PIN> { /// does it have the mode-relevant methods availailable (e.g. `set_high()` is only available for /// `Output` pins). impl Pin { - /// Convert this pin into an output pin. See [Digital Output](#digital-output). + /// Convert this pin into an output pin, setting the state to low. + /// See [Digital Output](#digital-output). pub fn into_output(mut self) -> Pin { + unsafe { self.pin.out_clear() }; + unsafe { self.pin.make_output() }; + Pin { + pin: self.pin, + _mode: PhantomData, + } + } + + /// Convert this pin into an output pin, setting the state to high. + /// See [Digital Output](#digital-output). + pub fn into_output_high(mut self) -> Pin { + unsafe { self.pin.out_set() }; unsafe { self.pin.make_output() }; Pin { pin: self.pin,