From 6337b5f522be11926a6490d7bb27a4f7795da569 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 23 Mar 2012 00:03:29 -0700 Subject: [PATCH] Automatically set ALTERNATE pin mode when setting alternate function When selecting an alternate function, set the pin to alternate mode as well; there's no sense requiring two separate calls everywhere. Signed-off-by: Keith Packard --- src/stm/stm32l.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h index 50e5cc34..531a4fb9 100644 --- a/src/stm/stm32l.h +++ b/src/stm/stm32l.h @@ -133,6 +133,10 @@ stm_pupdr_get(struct stm_gpio *gpio, int pin) { static inline void stm_afr_set(struct stm_gpio *gpio, int pin, uint32_t value) { + /* + * Set alternate pin mode too + */ + stm_moder_set(gpio, pin, STM_MODER_ALTERNATE); if (pin < 8) gpio->afrl = ((gpio->afrl & ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) | -- 2.30.2