We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e8be6ee commit 193390bCopy full SHA for 193390b
1 file changed
cpu/sam3/periph/gpio.c
@@ -22,6 +22,7 @@
22
* @}
23
*/
24
25
+#include "bitarithm.h"
26
#include "cpu.h"
27
#include "periph/gpio.h"
28
#include "periph_conf.h"
@@ -313,11 +314,11 @@ static inline void isr_handler(Pio *port, int port_num)
313
314
/* take interrupt flags only from pins which interrupt is enabled */
315
uint32_t status = (port->PIO_ISR & port->PIO_IMR);
316
- for (int i = 0; i < 32; i++) {
317
- if (status & ((uint32_t)1 << i)) {
318
- int ctx = _ctx(port_num, i);
319
- exti_ctx[ctx].cb(exti_ctx[ctx].arg);
320
- }
+ while (status) {
+ uint8_t pin_number;
+ status = bitarithm_test_and_clear(status, &pin_number);
+ int ctx = _ctx(port_num, pin_number);
321
+ exti_ctx[ctx].cb(exti_ctx[ctx].arg);
322
}
323
cortexm_isr_end();
324
0 commit comments