From e32be928dc042b61876384fac9ef2a225d10e929 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 20 Aug 2019 13:32:14 -0400 Subject: stm32: Add support for configuring open drain output mode Signed-off-by: Kevin O'Connor --- src/stm32/stm32f1.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/stm32/stm32f1.c') diff --git a/src/stm32/stm32f1.c b/src/stm32/stm32f1.c index 927ee1db..e5defd96 100644 --- a/src/stm32/stm32f1.c +++ b/src/stm32/stm32f1.c @@ -75,10 +75,15 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup) cfg = pullup ? 0x8 : 0x4; } else if (mode == GPIO_OUTPUT) { cfg = 0x1; + } else if (mode == (GPIO_OUTPUT | GPIO_OPEN_DRAIN)) { + cfg = 0x5; } else if (mode == GPIO_ANALOG) { cfg = 0x0; } else { - if (pullup > 0) + if (mode & GPIO_OPEN_DRAIN) + // Alternate function with open-drain mode + cfg = 0xd; + else if (pullup > 0) // Alternate function input pins use GPIO_INPUT mode on the stm32f1 cfg = 0x8; else -- cgit v1.2.3-70-g09d2