I am trying to detect the input pin which have triggered the interrupt. But it appears that the library is already reading the interrupt status register. And that's why status register is cleared and I can not read it again inside my interrupt function.
void PIOA_Handler(void) { pio_handler_process(PIOA, ID_PIOA); }
Above is the Library side Interrupt handler, which calls the function below.
void pio_handler_process(Pio *p_pio, uint32_t ul_id) { uint32_t status; uint32_t i; /* Read PIO controller status */ status = pio_get_interrupt_status(p_pio); status &= pio_get_interrupt_mask(p_pio); /* Check pending events */ if (status != 0) { /* Find triggering source */ i = 0; while (status != 0) { /* Source is configured on the same controller */ if (gs_interrupt_sources[i].id == ul_id) { /* Source has PIOs whose statuses have changed */ if ((status & gs_interrupt_sources[i].mask) != 0) { gs_interrupt_sources[i].handler(gs_interrupt_sources[i].id, gs_interrupt_sources[i].mask); status &= ~(gs_interrupt_sources[i].mask); } } i++; if (i >= MAX_INTERRUPT_SOURCES) { break; } } } /* Check capture events */ #if (SAM3S || SAM4S || SAM4E) if (pio_capture_enable_flag) { if (pio_capture_handler) { pio_capture_handler(p_pio); } } #endif }
And the bolded "handler" is my interrupt function pointer who is supposed to know which pin have called the interrupt. I am trying to not edit the library files, I do not want to pass the status to my Interrupt function.