From 7216f21122a2c3ec710204501d788c63e8e1993f Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Mon, 15 Jun 2015 20:34:26 +0200 Subject: [PATCH] cpu/stm32f4: fix init_af in GPIO driver --- cpu/stm32f4/periph/gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/stm32f4/periph/gpio.c b/cpu/stm32f4/periph/gpio.c index b8bf944e50..50f8124b36 100644 --- a/cpu/stm32f4/periph/gpio.c +++ b/cpu/stm32f4/periph/gpio.c @@ -152,8 +152,8 @@ void gpio_init_af(gpio_t pin, gpio_af_t af) port->MODER &= ~(3 << (2 * pin_num)); port->MODER |= (2 << (2 * pin_num)); /* set selected function */ - port->AFR[pin_num & 0x10] &= ~(0xf << ((pin_num & 0x0f) * 4)); - port->AFR[pin_num & 0x10] |= (af << ((pin_num & 0x0f) * 4)); + port->AFR[(pin_num > 7) ? 1 : 0] &= ~(0xf << ((pin_num & 0x07) * 4)); + port->AFR[(pin_num > 7) ? 1 : 0] |= (af << ((pin_num & 0x07) * 4)); } void gpio_irq_enable(gpio_t pin)