Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cc32xx gpio driver to prevent spurious interrupts in gpio_basic_api test #22850

Merged
merged 2 commits into from
Feb 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions drivers/gpio/gpio_cc32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ static int gpio_cc32xx_pin_interrupt_configure(struct device *port,

__ASSERT(pin < 8, "Invalid pin number - only 8 pins per port");

/*
* disable interrupt prior to changing int type helps
* prevent spurious interrupts observed when switching
* to level-based
*/
MAP_GPIOIntDisable(port_base, (1 << pin));

if (mode != GPIO_INT_MODE_DISABLED) {
if (mode == GPIO_INT_MODE_EDGE) {
if (trig == GPIO_INT_TRIG_BOTH) {
Expand All @@ -187,14 +194,13 @@ static int gpio_cc32xx_pin_interrupt_configure(struct device *port,
int_type = GPIO_LOW_LEVEL;
}
}

MAP_GPIOIntTypeSet(port_base, (1 << pin), int_type);
MAP_GPIOIntClear(port_base, (1 << pin));
MAP_GPIOIntEnable(port_base, (1 << pin));

WRITE_BIT(data->pin_callback_enables, pin,
mode != GPIO_INT_MODE_DISABLED);
} else {
MAP_GPIOIntDisable(port_base, (1 << pin));
}

return 0;
Expand Down Expand Up @@ -246,16 +252,12 @@ static void gpio_cc32xx_port_isr(void *arg)

enabled_int = int_status & data->pin_callback_enables;

/* Clear and Disable GPIO Interrupt */
MAP_GPIOIntDisable(config->port_base, int_status);
/* Clear GPIO Interrupt */
MAP_GPIOIntClear(config->port_base, int_status);

/* Call the registered callbacks */
gpio_fire_callbacks(&data->callbacks, (struct device *)dev,
enabled_int);

/* Re-enable the interrupts */
MAP_GPIOIntEnable(config->port_base, int_status);
}

static const struct gpio_driver_api api_funcs = {
Expand Down