From 39702d76242797106f77b3af56f3aed946e237b0 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 21:46:16 +0200 Subject: [PATCH] set_as_input_output() and set_as_output() : Have added comments and made functions public --- embassy-stm32/src/gpio.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 81969c4c..4f1ce3cf 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -68,8 +68,12 @@ impl<'d, T: Pin> Flex<'d, T> { }); } + /// Put the pin into output mode. + /// + /// The pin level will be whatever was set before (or low by default). If you want it to begin + /// at a specific level, call `set_high`/`set_low` on the pin first. #[inline] - fn set_as_output(&mut self, speed: Speed) { + pub fn set_as_output(&mut self, speed: Speed) { critical_section::with(|_| unsafe { let r = self.pin.block(); @@ -91,9 +95,18 @@ impl<'d, T: Pin> Flex<'d, T> { } }); } - + + /// Put the pin into input + output mode. + /// + /// This is commonly used for "open drain" mode. + /// the hardware will drive the line low if you set it to low, and will leave it floating if you set + /// it to high, in which case you can read the input to figure out whether another device + /// is driving the line low. + /// + /// The pin level will be whatever was set before (or low by default). If you want it to begin + /// at a specific level, call `set_high`/`set_low` on the pin first. #[inline] - fn set_as_input_output(&mut self,speed: Speed, pull : Pull) { + pub fn set_as_input_output(&mut self,speed: Speed, pull : Pull) { critical_section::with(|_| unsafe { let r = self.pin.block(); let n = self.pin.pin() as usize;