/* Set an interrupt handler for the provided pins. The provided handler will be called with the triggering pin as its parameter as soon as an interrupt is detected.  */
uint32_t pio_handler_set(Pio *p_pio, uint32_t ul_id, uint32_t ul_mask, uint32_t ul_attr, void(*p_handler)(uint32_t, uint32_t))
/* Set an interrupt handler for the provided pins. The provided handler will be called with the triggering pin as its parameter as soon as an interrupt is detected.  */
uint32_t pio_handler_set(Pio *p_pio, uint32_t ul_id, uint32_t ul_mask, uint32_t ul_attr, void(*p_handler)(uint32_t, uint32_t))
{
    uint8_t i;
	struct s_interrupt_source *pSource;
	if (gs_ul_nb_sources >= MAX_INTERRUPT_SOURCES)
		return 1;
	for (i = 0; i <= gs_ul_nb_sources; i++) {
		pSource = &(gs_interrupt_sources[i]);
		if (pSource->id == ul_id && pSource->mask == ul_mask) {
			break;
		}
	}
	pSource->id = ul_id;
	pSource->mask = ul_mask;
	pSource->attr = ul_attr;
	pSource->handler = p_handler;
	if (i == gs_ul_nb_sources + 1) {
		gs_ul_nb_sources++;
	}
	pio_configure_interrupt(p_pio, ul_mask, ul_attr);
	return 0;
}