<p>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.</p>
<p>A Regular Interrupts handler (see <aclass="el"href="concepts.html#interrupt_classes">Interrupt Classes</a>) must be written using the following general form: </p>
<divclass="fragment"><preclass="fragment"><aclass="code"href="group__system.html#ga52426c607fac82b1e0ad975b367f95e9"title="Standard normal IRQ handler declaration.">CH_IRQ_HANDLER</a>(myIRQ) {
<aclass="code"href="group__system.html#ga0d78c6e90e5f0a4eb52aaab37e45a494"title="IRQ handler enter code.">CH_IRQ_PROLOGUE</a>();
<spanclass="comment">// IRQ handling code, preemptable if the architecture supports it.</span>
<aclass="code"href="group__system.html#gab826c6d946aa1eb839751246ea158a72"title="Enters the kernel lock mode from within an interrupt handler.">chSysLockFromIsr</a>();
<spanclass="comment">// Invocation of some I-Class system APIs, never preemptable.</span>
<aclass="code"href="group__system.html#ga984fb4af1420b6a217714ed317224ec0"title="Leaves the kernel lock mode from within an interrupt handler.">chSysUnlockFromIsr</a>();
<spanclass="comment">// More IRQ handling code, again preemptable.</span>
</pre></div><h2>Writing Fast Interrupt handlers</h2>
<p>In those architectures (<aclass="el"href="group___a_r_m7.html">ARM7TDMI</a> and <aclass="el"href="group___a_r_m_c_mx.html">ARM Cortex-Mx</a>) supporting Fast Interrupts (see <aclass="el"href="concepts.html#interrupt_classes">Interrupt Classes</a>) handlers must be written using the following general form: </p>
<divclass="fragment"><preclass="fragment"><aclass="code"href="group__system.html#ga07883f8c07160bf1f95f8b8a783dbe38"title="Standard fast IRQ handler declaration.">CH_FAST_IRQ_HANDLER</a>(myIRQ) {
<spanclass="comment">// Fast IRQ handling code, preemptable if the architecture supports it.</span>
<spanclass="comment">// The invocation of any API is forbidden here because fast interrupt</span>
<spanclass="comment">// handlers can preempt the kernel even within its critical zones in</span>
<spanclass="comment">// order to minimize latency.</span>
}
</pre></div><h2>Handlers naming</h2>
<p>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.</p>
<h2>Important Notes</h2>
<ul>
<li>There is an important application note about ARM7 interrupt handlers, please read about it in the ARM7 port section: <aclass="el"href="group___a_r_m7.html#ARM7_IH">ARM7 Interrupt Handlers</a></li>
Generated on Sun Nov 28 2010 14:09:55 for ChibiOS/RT by <ahref="http://www.doxygen.org/index.html"><imgsrc="doxygen.png"alt="doxygen"align="middle"border="0"></a> 1.7.1</small></address>