Interrupt Handler

Any examples for Writing interrupts in RM

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.

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

	dev->iid = InterruptAttachEvent(dev->intr, &dev->intrevent,_NTO_INTR_FLAGS_TRK_MSK);
	if (dev->iid == -1) {
	   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.