From cb3284fad5347fc9622a170d6e3cd870fd9e2846 Mon Sep 17 00:00:00 2001 From: Perry Hung Date: Thu, 22 Apr 2010 01:43:23 -0400 Subject: Clear ODR for input pull-down mode. --- libmaple/gpio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libmaple') diff --git a/libmaple/gpio.c b/libmaple/gpio.c index 9759df8..9334c1e 100644 --- a/libmaple/gpio.c +++ b/libmaple/gpio.c @@ -44,14 +44,15 @@ void gpio_set_mode(GPIO_Port* port, uint8 gpio_pin, GPIOPinMode mode) { uint32 tmp; uint32 shift = POS(gpio_pin % 8); GPIOReg CR; - uint32 pullup = 0; ASSERT(port); ASSERT(gpio_pin < 16); if (mode == GPIO_MODE_INPUT_PU) { - pullup = 1; + port->ODR |= BIT(gpio_pin); mode = CNF_INPUT_PD; + } else if (mode == GPIO_MODE_INPUT_PD) { + port->ODR &= ~BIT(gpio_pin); } CR = (gpio_pin < 8) ? &(port->CRL) : &(port->CRH); @@ -62,6 +63,4 @@ void gpio_set_mode(GPIO_Port* port, uint8 gpio_pin, GPIOPinMode mode) { *CR = tmp; - if (pullup) - port->ODR = BIT(gpio_pin); } -- cgit v1.2.3