From 1c86fa9f6dff9eaff5be29de434252daa063d4eb Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Thu, 20 Nov 2014 14:13:51 -0800 Subject: [PATCH] stm32f0: fix setting GPIO in push-pull mode When using gpio_set_flags_by_mask() to modify a GPIO pin setting, the former code was not able to revert an open-drain GPIO into push-pull mode (the other way round was working). Fix it to be able to transition in each direction. Signed-off-by: Vincent Palatin BRANCH=all BUG=none TEST=on Twinkie, run "tw res none RP3A0" then "adc" and see the RP3A0 GPIO set to 1 and pulling the CC to 3.3V. Change-Id: Ic2d8ed95ea21b21d261a12ba298931d8bd5e6919 Reviewed-on: https://chromium-review.googlesource.com/231150 Reviewed-by: Vic Yang Tested-by: Vincent Palatin Commit-Queue: Vincent Palatin Reviewed-by: Randall Spangler --- chip/stm32/gpio-f0-l.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chip/stm32/gpio-f0-l.c b/chip/stm32/gpio-f0-l.c index d3369d9d89..826cb7c591 100644 --- a/chip/stm32/gpio-f0-l.c +++ b/chip/stm32/gpio-f0-l.c @@ -44,6 +44,8 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags) */ if (flags & GPIO_OPEN_DRAIN) STM32_GPIO_OTYPER(port) |= mask; + else + STM32_GPIO_OTYPER(port) &= ~mask; val = STM32_GPIO_MODER(port) & ~mask2; if (flags & GPIO_OUTPUT) {