Handling an Interrupt

The main technique for handling an interrupt is to associate an event to a specified interrupt service routine (ISR). Windows CE then schedules your interrupt service thread (IST) when the event is triggered. A typical interrupt handling sequence includes the following steps:

  1. The hardware raises an interrupt.

  2. The kernel looks up the interrupt request (IRQ) of the interrupt, calls the registered ISR, and disables all lower-priority interrupts.

  3. The ISR performs any necessary handling, and then returns an interrupt identifier.

  4. If the interrupt identifier value returned by the ISR is SYSINTR_NOP, the kernel completes processing without setting an event — all interrupts are enabled — and continues performing any tasks in process before the interrupt occurred. Otherwise, the kernel sets the event you have associated with the interrupt identifier. When the ISR returns, the kernel enables all other interrupts except the one that is being processed.

  5. The kernel schedules the IST indicated by the interrupt identifier to run.

    The IST can use driver resources to get or send data and control codes to the hardware and to acknowledge the hardware interrupt.

  6. After completely servicing the interrupt, the IST calls the InterruptDone function. In turn, InterruptDone calls the OEMInterruptDone OAL interface function to perform any hardware actions necessary to enable the next interrupt of the target device.

The following code example shows the functions that an IST typically calls.

// CreateThread can supply one 32-bit parameter, so pass the event handle.
// Associate this thread with the registered event. 
MyISTRoutine(HANDLE hEvent) {
  while (1) {
    WaitForSingleObject(hEvent, INFINITE); 
   // Check for thread exit signal and exit if set
    // Interrupt processing here.
    // On completion, call InterruptDone.
    InterruptDone(InterruptId);
    // Loop and wait for the kernel to set the event.
  }
}

See Also

How to Develop an OEM Adaptation Layer | Implementing an ISR

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.