mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #7220 from melvinvdb/fix_nrf5x_interrupt_pull_mode
Fix mbed::InterruptIn.mode() in NRF5x targetspull/7299/head
commit
0b8f46763a
|
@ -111,8 +111,7 @@ static void gpiote_pin_uninit(uint8_t pin)
|
||||||
if (m_gpio_initialized & ((gpio_mask_t)1UL << pin)) {
|
if (m_gpio_initialized & ((gpio_mask_t)1UL << pin)) {
|
||||||
if ((m_gpio_cfg[pin].direction == PIN_OUTPUT) && (!m_gpio_cfg[pin].used_as_irq)) {
|
if ((m_gpio_cfg[pin].direction == PIN_OUTPUT) && (!m_gpio_cfg[pin].used_as_irq)) {
|
||||||
nrf_drv_gpiote_out_uninit(pin);
|
nrf_drv_gpiote_out_uninit(pin);
|
||||||
}
|
} else if (m_gpio_cfg[pin].used_as_irq) {
|
||||||
else if (m_gpio_cfg[pin].used_as_irq) {
|
|
||||||
nrf_drv_gpiote_in_uninit(pin);
|
nrf_drv_gpiote_in_uninit(pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,16 +128,6 @@ static void gpio_apply_config(uint8_t pin)
|
||||||
cfg.hi_accuracy = false;
|
cfg.hi_accuracy = false;
|
||||||
cfg.is_watcher = false;
|
cfg.is_watcher = false;
|
||||||
cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE;
|
cfg.sense = NRF_GPIOTE_POLARITY_TOGGLE;
|
||||||
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))
|
|
||||||
{
|
|
||||||
nrf_drv_gpiote_in_event_enable(pin, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
switch (m_gpio_cfg[pin].pull) {
|
switch (m_gpio_cfg[pin].pull) {
|
||||||
case PullUp:
|
case PullUp:
|
||||||
cfg.pull = NRF_GPIO_PIN_PULLUP;
|
cfg.pull = NRF_GPIO_PIN_PULLUP;
|
||||||
|
@ -150,17 +139,22 @@ static void gpio_apply_config(uint8_t pin)
|
||||||
cfg.pull = NRF_GPIO_PIN_NOPULL;
|
cfg.pull = NRF_GPIO_PIN_NOPULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (m_gpio_cfg[pin].used_as_irq) {
|
||||||
|
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)) {
|
||||||
|
nrf_drv_gpiote_in_event_enable(pin, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
nrf_gpio_cfg_input(pin, cfg.pull);
|
nrf_gpio_cfg_input(pin, cfg.pull);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Configure as output.
|
// Configure as output.
|
||||||
nrf_drv_gpiote_out_config_t cfg = GPIOTE_CONFIG_OUT_SIMPLE(nrf_gpio_pin_out_read(pin));
|
nrf_drv_gpiote_out_config_t cfg = GPIOTE_CONFIG_OUT_SIMPLE(nrf_gpio_pin_out_read(pin));
|
||||||
nrf_drv_gpiote_out_init(pin, &cfg);
|
nrf_drv_gpiote_out_init(pin, &cfg);
|
||||||
}
|
}
|
||||||
m_gpio_initialized |= ((gpio_mask_t)1UL << pin);
|
m_gpio_initialized |= ((gpio_mask_t)1UL << pin);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
m_gpio_initialized &= ~((gpio_mask_t)1UL << pin);
|
m_gpio_initialized &= ~((gpio_mask_t)1UL << pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +197,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
|
||||||
gpiote_pin_uninit(pin); // try to uninitialize gpio before a change.
|
gpiote_pin_uninit(pin); // try to uninitialize gpio before a change.
|
||||||
|
|
||||||
m_gpio_cfg[pin].used_as_irq = true;
|
m_gpio_cfg[pin].used_as_irq = true;
|
||||||
|
m_gpio_cfg[pin].pull = PullNone;
|
||||||
m_channel_ids[pin] = id;
|
m_channel_ids[pin] = id;
|
||||||
obj->ch = pin;
|
obj->ch = pin;
|
||||||
m_irq_handler = handler;
|
m_irq_handler = handler;
|
||||||
|
@ -232,8 +227,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||||
|
|
||||||
if (event == IRQ_RISE) {
|
if (event == IRQ_RISE) {
|
||||||
cfg->irq_rise = enable ? true : false;
|
cfg->irq_rise = enable ? true : false;
|
||||||
}
|
} else if (event == IRQ_FALL) {
|
||||||
else if (event == IRQ_FALL) {
|
|
||||||
cfg->irq_fall = enable ? true : false;
|
cfg->irq_fall = enable ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue