drivers: gpio_nrfx: Correct the way the callbacks are fired
Add additional masking of the pins with fired callback triggers against the currently enabled callbacks, in order to not call handlers for callbacks that got disabled in some other callback handlers that were called in the same ISR execution. Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
parent
680d778f57
commit
c542a4c56f
1 changed files with 19 additions and 1 deletions
|
@ -400,7 +400,25 @@ static u32_t check_level_trigger_pins(struct device *port)
|
||||||
|
|
||||||
static inline void fire_callbacks(struct device *port, u32_t pins)
|
static inline void fire_callbacks(struct device *port, u32_t pins)
|
||||||
{
|
{
|
||||||
gpio_fire_callbacks(&get_port_data(port)->callbacks, port, pins);
|
struct gpio_nrfx_data *data = get_port_data(port);
|
||||||
|
sys_slist_t *list = &data->callbacks;
|
||||||
|
struct gpio_callback *cb, *tmp;
|
||||||
|
|
||||||
|
/* Instead of calling the common gpio_fire_callbacks() function,
|
||||||
|
* iterate the list of callbacks locally, to be able to perform
|
||||||
|
* additional masking of the pins and to call handlers only for
|
||||||
|
* the currently enabled callbacks.
|
||||||
|
*/
|
||||||
|
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(list, cb, tmp, node) {
|
||||||
|
/* Check currently enabled callbacks (data->int_en) in each
|
||||||
|
* iteration, as some callbacks may get disabled also in any
|
||||||
|
* of the handlers called here.
|
||||||
|
*/
|
||||||
|
if ((cb->pin_mask & pins) & data->int_en) {
|
||||||
|
__ASSERT(cb->handler, "No callback handler!");
|
||||||
|
cb->handler(port, cb, pins);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_GPIO_NRF_P0
|
#ifdef CONFIG_GPIO_NRF_P0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue