ARM/Microchip/SAM4L/src/iopincfg_sam4l.c
bool IOPinEnableInterrupt(int IntNo, int IntPrio, int PortNo, int PinNo, IOPINSENSE Sense, IOPINEVT_CB pEvtCB, void *pCtx)
{
	if (IntNo < 0 || IntNo >= IOPIN_MAX_INT || (IntNo >> 2) != PortNo || (IntNo & 3) != (PinNo >> 3))
	{
		return false;
	}

	GpioPort *reg = (GpioPort *)((uint32_t)&SAM4L_GPIO->GPIO_PORT[PortNo]);

	uint32_t pinmask = 1 << PinNo;

	reg->GPIO_GFERS = pinmask;	// Enable glitch filter

	IOPinSetSense(PortNo, PinNo, Sense);
	
    s_GpIOSenseEvt[IntNo].Sense = Sense;
	s_GpIOSenseEvt[IntNo].PortPinNo = (PortNo << 8) | PinNo; // For use when disable interrupt
	s_GpIOSenseEvt[IntNo].SensEvtCB = pEvtCB;
	s_GpIOSenseEvt[IntNo].pCtx = pCtx;

	reg->GPIO_IERS = pinmask;
	
	NVIC_ClearPendingIRQ(GPIO_0_IRQn + IntNo);
	NVIC_SetPriority(GPIO_0_IRQn + IntNo, IntPrio);
	NVIC_EnableIRQ(GPIO_0_IRQn + IntNo);

    return true;
}
/**
 * @brief Enable I/O pin sensing interrupt event
 *
 * Generate an interrupt when I/O sense a state change.
 * The IntNo (interrupt number) parameter is processor dependent. Some is
 * directly the hardware interrupt number other is just an index in an array
 *
 * SAM4L : IntNo is divided by group of 8 pins & port.
 * 			0 - PA 0..7
 * 			1 - PA 8..15
 *			...
 *			4 - PB 0..7
 *
 * @param	IntNo	: Interrupt number. -1 for port event interrupt
 * 			IntPrio : Interrupt priority
 * 			PortNo  : Port number (up to 32 ports)
 * 			PinNo   : Pin number (up to 32 pins)
 * 			Sense   : Sense type of event on the I/O pin
 * 			pEvtCB	: Pointer to callback function when event occurs
 * 			pCtx	: Pointer to data context to pass to handler callback
 */
@brief Enable I/O pin sensing interrupt event
Generate an interrupt when I/O sense a state change.
The IntNo (interrupt number) parameter is processor dependent. Some is
directly the hardware interrupt number other is just an index in an array

SAM4L : IntNo is divided by group of 8 pins & port.

@param       IntNo   : Interrupt number.
@brief Enable I / O pin sensing interrupt event Generate an interrupt when I / O sense a state change . The IntNo ( interrupt number ) parameter is processor dependent . Some is directly the hardware interrupt number other is just an index in an array SAM4L : IntNo is divided by group of 8 pins & port . @param IntNo : Interrupt number .
bool IOPinEnableInterrupt(int IntNo, int IntPrio, int PortNo, int PinNo, IOPINSENSE Sense, IOPINEVT_CB pEvtCB, void *pCtx)
{
	if (IntNo < 0 || IntNo >= IOPIN_MAX_INT || (IntNo >> 2) != PortNo || (IntNo & 3) != (PinNo >> 3))
	{
		return false;
	}
	GpioPort *reg = (GpioPort *)((uint32_t)&SAM4L_GPIO->GPIO_PORT[PortNo]);
	uint32_t pinmask = 1 << PinNo;
	reg->GPIO_GFERS = pinmask;	
	IOPinSetSense(PortNo, PinNo, Sense);
    s_GpIOSenseEvt[IntNo].Sense = Sense;
	s_GpIOSenseEvt[IntNo].PortPinNo = (PortNo << 8) | PinNo; 
	s_GpIOSenseEvt[IntNo].SensEvtCB = pEvtCB;
	s_GpIOSenseEvt[IntNo].pCtx = pCtx;
	reg->GPIO_IERS = pinmask;
	NVIC_ClearPendingIRQ(GPIO_0_IRQn + IntNo);
	NVIC_SetPriority(GPIO_0_IRQn + IntNo, IntPrio);
	NVIC_EnableIRQ(GPIO_0_IRQn + IntNo);
    return true;
}
bool IOPinEnableInterrupt ( int IntNo , int IntPrio , int PortNo , int PinNo , IOPINSENSE Sense , IOPINEVT_CB pEvtCB , void * pCtx ) { if ( IntNo < 0 || IntNo >= IOPIN_MAX_INT || ( IntNo >> 2 ) != PortNo || ( IntNo & 3 ) != ( PinNo >> 3 ) ) { return false ; } GpioPort * reg = ( GpioPort * ) ( ( uint32_t ) & SAM4L_GPIO -> GPIO_PORT [ PortNo ] ) ; uint32_t pinmask = 1 << PinNo ; reg -> GPIO_GFERS = pinmask ; IOPinSetSense ( PortNo , PinNo , Sense ) ; s_GpIOSenseEvt [ IntNo ] . Sense = Sense ; s_GpIOSenseEvt [ IntNo ] . PortPinNo = ( PortNo << 8 ) | PinNo ; s_GpIOSenseEvt [ IntNo ] . SensEvtCB = pEvtCB ; s_GpIOSenseEvt [ IntNo ] . pCtx = pCtx ; reg -> GPIO_IERS = pinmask ; NVIC_ClearPendingIRQ ( GPIO_0_IRQn + IntNo ) ; NVIC_SetPriority ( GPIO_0_IRQn + IntNo , IntPrio ) ; NVIC_EnableIRQ ( GPIO_0_IRQn + IntNo ) ; return true ; }
@brief Enable I/O pin sensing interrupt event
 Generate an interrupt when I/O sense a state change.
@brief Enable I / O pin sensing interrupt event Generate an interrupt when I / O sense a state change .
// Enable glitch filter // For use when disable interrupt