diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-05-31 18:44:26 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-05-31 18:44:26 -0400 |
commit | 322a324963d8210dbbe529357b41e7c9ff8f8db6 (patch) | |
tree | 7a0b74b1636918058f4f7fdeb39a16dd320e31e7 | |
parent | 1ed01dad43f95be2af258d44d03fcafde5714942 (diff) | |
download | librambutan-322a324963d8210dbbe529357b41e7c9ff8f8db6.tar.gz librambutan-322a324963d8210dbbe529357b41e7c9ff8f8db6.zip |
stm32f2/gpio.c: Fix some bugs.
Make gpioh.regs actually point to GPIOH_BASE. Properly AND out flag
bits in gpio_set_modef().
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
-rw-r--r-- | libmaple/stm32f2/gpio.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libmaple/stm32f2/gpio.c b/libmaple/stm32f2/gpio.c index 7479922..f2cd776 100644 --- a/libmaple/stm32f2/gpio.c +++ b/libmaple/stm32f2/gpio.c @@ -87,7 +87,7 @@ gpio_dev gpiog = { gpio_dev* const GPIOG = &gpiog; gpio_dev gpioh = { - .regs = GPIOG_BASE, + .regs = GPIOH_BASE, .clk_id = RCC_GPIOH, }; /** GPIO port G device. */ @@ -146,13 +146,13 @@ void gpio_set_modef(gpio_dev *dev, /* Speed */ tmp = regs->OSPEEDR; tmp &= ~(0x3 << shift); - tmp |= (flags >> 1) << shift; + tmp |= ((flags >> 1) & 0x3) << shift; regs->OSPEEDR = tmp; /* Pull-up/pull-down */ tmp = regs->PUPDR; tmp &= ~(0x3 << shift); - tmp |= (flags >> 2) << shift; + tmp |= ((flags >> 3) & 0x3) << shift; regs->PUPDR = tmp; } |