From f59655629ea8038c142377e84910c9b768d74f6a Mon Sep 17 00:00:00 2001 From: Melvin van den berg Date: Thu, 14 Jun 2018 16:54:03 +0200 Subject: [PATCH] Fixed broken InterruptIn.mode() in NRF5x target which didn't do anything: interruptIn always remained with pullup resistor enabled. --- targets/TARGET_NORDIC/TARGET_NRF5x/gpio_api.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/gpio_api.c b/targets/TARGET_NORDIC/TARGET_NRF5x/gpio_api.c index f103afb1b7..eaedc80b32 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/gpio_api.c +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/gpio_api.c @@ -129,8 +129,18 @@ static void gpio_apply_config(uint8_t pin) cfg.hi_accuracy = false; cfg.is_watcher = false; cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE; + switch(m_gpio_cfg[pin].pull) { + case PullUp: + cfg.pull = NRF_GPIO_PIN_PULLUP; + break; + case PullDown: + cfg.pull = NRF_GPIO_PIN_PULLDOWN; + break; + default: + cfg.pull = NRF_GPIO_PIN_NOPULL; + break; + } if (m_gpio_cfg[pin].used_as_irq) { - cfg.pull = NRF_GPIO_PIN_PULLUP; nrf_drv_gpiote_in_init(pin, &cfg, gpiote_irq_handler); if ((m_gpio_irq_enabled & ((gpio_mask_t)1 << pin)) && (m_gpio_cfg[pin].irq_rise || m_gpio_cfg[pin].irq_fall)) @@ -139,17 +149,6 @@ static void gpio_apply_config(uint8_t pin) } } else { - switch(m_gpio_cfg[pin].pull) { - case PullUp: - cfg.pull = NRF_GPIO_PIN_PULLUP; - break; - case PullDown: - cfg.pull = NRF_GPIO_PIN_PULLDOWN; - break; - default: - cfg.pull = NRF_GPIO_PIN_NOPULL; - break; - } nrf_gpio_cfg_input(pin,cfg.pull); } }