ChibiOS/RT Logo ChibiOS/RT

Architecture - Reference Manual - Guides

How to write interrupt handlers

Since version 1.1.0 ChibiOS/RT offers a cross-platform method for writing interrupt handlers. Port-related and compiler-related details are encapsulated within standard system macros.

Writing Regular Interrupt handlers

A Regular Interrupts handler (see Interrupt Classes) must be written using the following general form:

CH_IRQ_HANDLER(myIRQ) {
  CH_IRQ_PROLOGUE();
  
  // IRQ handling code, preemptable if the architecture supports it.
  
  chSysLockFromIsr();
  // Invocation of some I-Class system APIs, never preemptable.
  chSysUnlockFromIsr();
  
  // More IRQ handling code, again preemptable.

  CH_IRQ_EPILOGUE();
}

Writing Fast Interrupt handlers

In those architectures (ARM7TDMI and ARM Cortex-Mx) supporting Fast Interrupts (see Interrupt Classes) handlers must be written using the following general form:

CH_FAST_IRQ_HANDLER(myIRQ) {

  // Fast IRQ handling code, preemptable if the architecture supports it.
  // The invocation of any API is forbidden here because fast interrupt
  // handlers can preempt the kernel even within its critical zones in
  // order to minimize latency.
}

Handlers naming

A note about the handler name "myIRQ", in some ports it must be a vector number rather than a function name, it could also be a name from within a predefined set, see the notes about the various ports.

Important Notes


Generated on Sun Nov 28 2010 14:09:55 for ChibiOS/RT by doxygen 1.7.1