Skip to content

Commit

Permalink
Merge pull request #21179 from dylad/pr/cpu/sam3/optimize_gpio_isr
Browse files Browse the repository at this point in the history
cpu/sam3: optimize gpio ISR processing
  • Loading branch information
dylad authored Feb 5, 2025
2 parents c20ce69 + 193390b commit 17bceab
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cpu/sam3/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @}
*/

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

for (int i = 0; i < 32; i++) {
if (status & ((uint32_t)1 << i)) {
int ctx = _ctx(port_num, i);
exti_ctx[ctx].cb(exti_ctx[ctx].arg);
}
while (status) {
uint8_t pin_number;
status = bitarithm_test_and_clear(status, &pin_number);
int ctx = _ctx(port_num, pin_number);
exti_ctx[ctx].cb(exti_ctx[ctx].arg);
}
cortexm_isr_end();
}
Expand Down

0 comments on commit 17bceab

Please sign in to comment.