Small fixes to the GPIO api, meaning it works!

pull/8/head
Joe Turner 2013-05-14 10:59:14 +01:00
parent 8ffca414a5
commit 3a0c872df4
1 changed files with 4 additions and 4 deletions

View File

@ -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;