- This topic has 0 replies, 1 voice, and was last updated 2 weeks, 2 days ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
Homepage › Forums › Modular Dev Kits › Q&A › Register GPIO Interrupt in uEZ
(This message was transferred over from our old forum)
Posted August 17, 2015
By Todd DeBoer
[hr]
On 3/19/10 TONYC asked, “I have an I2C device that supports interrupt, which I have hooked up to the DK-TS-Kit. The interrupt line from the device goes to one of the free GPIO on the kit. Is there any way to register the this interrupt to the uEZ interrupt routines?”
[hr]
(Follow up post)
There currently is not a way to do it with the uEZ API (making note to add feature). You’ll have to touch the hardware directly to enable this.
However, the GPIO interrupts of the LPC2478 occur on the same interrupt as External Interrupt 3 (17).
Sample code to enable this could look like follows:
[code]
#include
#include
IRQ_ROUTINE(GPIOIRQ_ISR);
SomeRoutineReadiesIRQ()
{
IO0IntEnF |= (1<<4); // Enable P0.4 for falling edge interrupts
IO2IntEnR |= (1<<3); // Enable P2.3 for rising edge interrupts
InterruptRegister(
INTERRUPT_CHANNEL_EINT3,
GPIOIRQ_ISR,
INTERRUPT_PRIORITY_NORMAL,
“”GPIOIRQ””);
}
void ProcessGPIO0Interrupt(void)
{
// P0.4 falling?
if (IO0IntEnF & (1<<4)) {
// Process P0.4 falling here
// …
// Clear the interrupt
IO0IntClr = (1<<4);
}
}
ProcessGPIO2Interrupt(void)
{
// P2.3 rising?
if (IO2IntEnR & (1<<3)) {
// Process P2.3 rising here
// …
// Clear the interrupt
IO2IntClr = (1<<3);
}
}
IRQ_ROUTINE(GPIOIRQ_ISR)
{
IRQ_START();
if (IOIntStatus & IOIntStatus_P0Int) {
// Port0 interrupt
ProcessGPIO0Interrupt();
}
if (IOIntStatus & IOIntStatus_P2Int) {
// Port2 interrupt
ProcessGPIO2Interrupt();
}
IRQ_END();
}
[/code]