aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/stm32f1.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-08-20 13:32:14 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-08-20 19:39:49 -0400
commite32be928dc042b61876384fac9ef2a225d10e929 (patch)
tree260659bab600486cb42b9dfdeaa9a764f56744b2 /src/stm32/stm32f1.c
parentc930fc392b6977b17d6f7953bd738583974208c2 (diff)
downloadkutter-e32be928dc042b61876384fac9ef2a225d10e929.tar.gz
kutter-e32be928dc042b61876384fac9ef2a225d10e929.tar.xz
kutter-e32be928dc042b61876384fac9ef2a225d10e929.zip
stm32: Add support for configuring open drain output mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/stm32f1.c')
-rw-r--r--src/stm32/stm32f1.c7
1 files changed, 6 insertions, 1 deletions
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