1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

cpu/cc2538: GPIO: use bitarithm_test_and_clear()

This commit is contained in:
Benjamin Valentin 2020-07-19 23:05:45 +02:00
parent 403b6b15c6
commit 08b3e2bd6b

View File

@ -24,6 +24,7 @@
#include <stdint.h>
#include "cpu.h"
#include "bitarithm.h"
#include "periph/gpio.h"
#define ENABLE_DEBUG (0)
@ -222,10 +223,9 @@ static inline void handle_isr(uint8_t port_num)
/* mask all non-GPIO bits */
state &= (1 << GPIO_BITS_PER_PORT) - 1;
uint8_t pin = 0;
while (state) {
/* we want the position of the first one bit, so N_bits - (N_zeros + 1) */
int pin = 32 - __builtin_clz(state) - 1;
state &= ~(1 << pin);
state = bitarithm_test_and_clear(state, &pin);
isr_ctx[port_num][pin].cb(isr_ctx[port_num][pin].arg);
}