Skip to content

Commit 193390b

Browse files
committed
cpu/sam3: optimize gpio ISR processing
Signed-off-by: dylad <dylan.laduranty@mesotic.com>
1 parent e8be6ee commit 193390b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

cpu/sam3/periph/gpio.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* @}
2323
*/
2424

25+
#include "bitarithm.h"
2526
#include "cpu.h"
2627
#include "periph/gpio.h"
2728
#include "periph_conf.h"
@@ -313,11 +314,11 @@ static inline void isr_handler(Pio *port, int port_num)
313314
/* take interrupt flags only from pins which interrupt is enabled */
314315
uint32_t status = (port->PIO_ISR & port->PIO_IMR);
315316

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-
}
317+
while (status) {
318+
uint8_t pin_number;
319+
status = bitarithm_test_and_clear(status, &pin_number);
320+
int ctx = _ctx(port_num, pin_number);
321+
exti_ctx[ctx].cb(exti_ctx[ctx].arg);
321322
}
322323
cortexm_isr_end();
323324
}

0 commit comments

Comments
 (0)