aboutsummaryrefslogtreecommitdiffstats
path: root/src/lpc176x/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lpc176x/gpio.c')
-rw-r--r--src/lpc176x/gpio.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lpc176x/gpio.c b/src/lpc176x/gpio.c
index 0b5fb1a9..5c76ec55 100644
--- a/src/lpc176x/gpio.c
+++ b/src/lpc176x/gpio.c
@@ -23,7 +23,7 @@ static LPC_GPIO_TypeDef * const digital_regs[] = {
// Set the mode and extended function of a pin
void
-gpio_peripheral(uint32_t gpio, int func, int pullup)
+gpio_peripheral(uint32_t gpio, int func, int pull_up)
{
uint32_t bank_pos = GPIO2PORT(gpio) * 2, pin_pos = (gpio % 32) * 2;
if (pin_pos >= 32) {
@@ -31,12 +31,12 @@ gpio_peripheral(uint32_t gpio, int func, int pullup)
bank_pos++;
}
uint32_t sel_bits = (func & 0x03) << pin_pos, mask = ~(0x03 << pin_pos);
- uint32_t mode_bits = (pullup ? 0x00 : 0x02) << pin_pos;
+ uint32_t mode = (pull_up ? (pull_up > 0 ? 0x00 : 0x03) : 0x02) << pin_pos;
volatile uint32_t *pinsel = &LPC_PINCON->PINSEL0;
volatile uint32_t *pinmode = &LPC_PINCON->PINMODE0;
irqstatus_t flag = irq_save();
pinsel[bank_pos] = (pinsel[bank_pos] & mask) | sel_bits;
- pinmode[bank_pos] = (pinmode[bank_pos] & mask) | mode_bits;
+ pinmode[bank_pos] = (pinmode[bank_pos] & mask) | mode;
irq_restore(flag);
}