Skip to content

Commit

Permalink
cpu/sam3: optimize gpio ISR processing
Browse files Browse the repository at this point in the history
Signed-off-by: dylad <dylan.laduranty@mesotic.com>
  • Loading branch information
dylad committed Jan 31, 2025
1 parent e8be6ee commit 193390b
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 193390b

Please sign in to comment.