diff options
author | Perry Hung <iperry@alum.mit.edu> | 2010-04-22 01:43:23 -0400 |
---|---|---|
committer | Perry Hung <iperry@alum.mit.edu> | 2010-04-22 01:43:23 -0400 |
commit | cb3284fad5347fc9622a170d6e3cd870fd9e2846 (patch) | |
tree | 57ccb4580e054a7522218350dd84b4bb9eaf5415 | |
parent | a4e8827b0652be1133d7491fc749fcb55b7c3333 (diff) | |
download | librambutan-cb3284fad5347fc9622a170d6e3cd870fd9e2846.tar.gz librambutan-cb3284fad5347fc9622a170d6e3cd870fd9e2846.zip |
Clear ODR for input pull-down mode.
-rw-r--r-- | libmaple/gpio.c | 7 |
1 files changed, 3 insertions, 4 deletions
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); } |