From 3a0c872df4dc5cf859060a75614cedde346abd18 Mon Sep 17 00:00:00 2001 From: Joe Turner Date: Tue, 14 May 2013 10:59:14 +0100 Subject: [PATCH] Small fixes to the GPIO api, meaning it works! --- libraries/mbed/vendor/STM/capi/gpio_api.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/mbed/vendor/STM/capi/gpio_api.c b/libraries/mbed/vendor/STM/capi/gpio_api.c index d6875fae15..0806e56997 100644 --- a/libraries/mbed/vendor/STM/capi/gpio_api.c +++ b/libraries/mbed/vendor/STM/capi/gpio_api.c @@ -20,7 +20,7 @@ uint32_t gpio_set(PinName pin) { uint32_t port_index = (uint32_t) pin >> 4; // Enable GPIO peripheral clock - RCC->APB1ENR |= 1 << port_index; + RCC->AHB1ENR |= 1 << port_index; pin_function(pin, 0); return 1 << ((uint32_t) pin & 0xF); @@ -34,10 +34,10 @@ void gpio_init(gpio_t *obj, PinName pin, PinDirection direction) { uint32_t port_index = (uint32_t) pin >> 4; - GPIO_TypeDef *port_reg = (GPIO_TypeDef *) (GPIOA_BASE + (port_index << 6)); + GPIO_TypeDef *port_reg = (GPIO_TypeDef *) (GPIOA_BASE + (port_index << 10)); obj->reg_mode = &port_reg->MODER; - obj->reg_set = &port_reg->BSRRH; - obj->reg_clr = &port_reg->BSRRL; + obj->reg_set = &port_reg->BSRRL; + obj->reg_clr = &port_reg->BSRRH; obj->reg_in = &port_reg->IDR; obj->reg_in = &port_reg->ODR;