Skip navigation.
Home
The QNX Community Portal

View topic - Interrupt Handler

Interrupt Handler

anything that doesn't fit to other groups.

Interrupt Handler

Postby umamahesh » Sun Jun 07, 2015 4:48 pm

Hi,
Any examples for Writing interrupts in RM
umamahesh
Active Member
 
Posts: 39
Joined: Thu Feb 19, 2015 6:12 am

Re: Interrupt Handler

Postby maschoen » Thu Jun 11, 2015 5:16 pm

Were you looking for examples on the structural way to write an interrupt handler in QNX? The documentation is pretty good in this area. Or did you want to know the ins and outs (there's a pun there in case you didn't notice) it writing the code inside an interrupt handler. For this you would have to provide a little more info on your hardware.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Interrupt Handler

Postby umamahesh » Sat Jun 13, 2015 10:07 am

Thanks for the reply. I am writing I2C master RM to communicate to SGTL5000 on i.mx51. I have initialized the handler as follows

SIGEV_INTR_INIT(&dev->intrevent);
dev->iid = InterruptAttachEvent(dev->intr, &dev->intrevent,_NTO_INTR_FLAGS_TRK_MSK);
if (dev->iid == -1) {
perror("InterruptAttachEvent");
goto fail;
}

but how to point my handler function, few examples in QNX they mentioned ablove code snippet in separate thread and instead of &dev->intrevent they replaced with handler function. Like to know how it works. Please suggest.
umamahesh
Active Member
 
Posts: 39
Joined: Thu Feb 19, 2015 6:12 am

Re: Interrupt Handler

Postby maschoen » Mon Jun 22, 2015 1:14 am

umamahesh wrote:Thanks for the reply. I am writing I2C master RM to communicate to SGTL5000 on i.mx51. I have initialized the handler as follows

SIGEV_INTR_INIT(&dev->intrevent);
dev->iid = InterruptAttachEvent(dev->intr, &dev->intrevent,_NTO_INTR_FLAGS_TRK_MSK);
if (dev->iid == -1) {
perror("InterruptAttachEvent");
goto fail;
}

but how to point my handler function, few examples in QNX they mentioned ablove code snippet in separate thread and instead of &dev->intrevent they replaced with handler function. Like to know how it works. Please suggest.


There are two contexts that you might want to execute code after an interrupt, interrupt context or process context. If your interrupt handler doesn't need immediate attention, you can use InterruptAttachEvent() to attach an event to the interrupt which will wake up your process and allow you to handle the interrupt in process context. Typically you use the event SIGEV_PULSE if your program is receive blocked most of the time. You can also use the SIGEV_INTR event, typically in a thread that can wait.

The other context is the interrupt context. For this you need the interruptAttach() call to attach your handler. On a first pass I would suggest using interruptAttachEvent() with a thread waiting on SIGEV_INTR. Then you can put printf's in the code for debugging. Then move the code to an interrupt handler routine.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm


Return to General Programming

Who is online

Users browsing this forum: No registered users and 2 guests