Automatically set ALTERNATE pin mode when setting alternate function
authorKeith Packard <keithp@keithp.com>
Fri, 23 Mar 2012 07:03:29 +0000 (00:03 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 29 Mar 2012 04:37:03 +0000 (21:37 -0700)
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 <keithp@keithp.com>
src/stm/stm32l.h

index 50e5cc346a9ee0f404f06729a68ab6cc18f53182..531a4fb9488c026e899ea48375bc4ca6c3048660 100644 (file)
@@ -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))) |