gnuk/ChibiOS_2.0.8/docs/html/article_interrupts.html

77 lines
4.6 KiB
HTML
Raw Normal View History

2010-08-10 03:11:02 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ChibiOS/RT: How to write interrupt handlers</title>
<link href="custom.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<table style="text-align: center; width: 100%;" border="0"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="width: 80px;"><img alt="ChibiOS/RT Logo" src="logo_small.png"></td>
<td><big><big>ChibiOS/RT</big></big><br><br>Architecture - Reference Manual - Guides</td>
<td style="width: 80px;"></td>
</tr>
</tbody>
</table>
<hr size="1">
2010-11-22 05:53:37 +00:00
<!-- Generated by Doxygen 1.7.1 -->
2010-08-10 03:11:02 +00:00
<div class="navigation" id="top">
<div class="tabs">
2010-11-22 05:53:37 +00:00
<ul class="tablist">
2010-08-10 03:11:02 +00:00
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
2010-11-22 05:53:37 +00:00
<div class="navpath">
<ul>
<li><a class="el" href="main.html">ChibiOS/RT</a> </li>
<li><a class="el" href="articles.html">Articles and Code Samples</a> </li>
<li><a class="el" href="page_howtos.html">How To's</a> </li>
</ul>
2010-08-10 03:11:02 +00:00
</div>
</div>
2010-11-22 05:53:37 +00:00
<div class="header">
<div class="headertitle">
<h1>How to write interrupt handlers </h1> </div>
</div>
2010-08-10 03:11:02 +00:00
<div class="contents">
2010-11-22 05:53:37 +00:00
<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>
2010-08-10 03:11:02 +00:00
<h2>Writing Regular Interrupt handlers</h2>
<p>A Regular Interrupts handler (see <a class="el" href="concepts.html#interrupt_classes">Interrupt Classes</a>) must be written using the following general form: </p>
<div class="fragment"><pre class="fragment"><a class="code" href="group__system.html#ga52426c607fac82b1e0ad975b367f95e9" title="Standard normal IRQ handler declaration.">CH_IRQ_HANDLER</a>(myIRQ) {
<a class="code" href="group__system.html#ga0d78c6e90e5f0a4eb52aaab37e45a494" title="IRQ handler enter code.">CH_IRQ_PROLOGUE</a>();
<span class="comment">// IRQ handling code, preemptable if the architecture supports it.</span>
<a class="code" href="group__system.html#gab826c6d946aa1eb839751246ea158a72" title="Enters the kernel lock mode from within an interrupt handler.">chSysLockFromIsr</a>();
<span class="comment">// Invocation of some I-Class system APIs, never preemptable.</span>
<a class="code" href="group__system.html#ga984fb4af1420b6a217714ed317224ec0" title="Leaves the kernel lock mode from within an interrupt handler.">chSysUnlockFromIsr</a>();
<span class="comment">// More IRQ handling code, again preemptable.</span>
<a class="code" href="group__system.html#ga864d6b8056d7d8f56322bbfcc8515d77" title="IRQ handler exit code.">CH_IRQ_EPILOGUE</a>();
}
</pre></div><h2>Writing Fast Interrupt handlers</h2>
<p>In those architectures (<a class="el" href="group___a_r_m7.html">ARM7TDMI</a> and <a class="el" href="group___a_r_m_c_mx.html">ARM Cortex-Mx</a>) supporting Fast Interrupts (see <a class="el" href="concepts.html#interrupt_classes">Interrupt Classes</a>) handlers must be written using the following general form: </p>
<div class="fragment"><pre class="fragment"><a class="code" href="group__system.html#ga07883f8c07160bf1f95f8b8a783dbe38" title="Standard fast IRQ handler declaration.">CH_FAST_IRQ_HANDLER</a>(myIRQ) {
<span class="comment">// Fast IRQ handling code, preemptable if the architecture supports it.</span>
<span class="comment">// The invocation of any API is forbidden here because fast interrupt</span>
<span class="comment">// handlers can preempt the kernel even within its critical zones in</span>
<span class="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: <a class="el" href="group___a_r_m7.html#ARM7_IH">ARM7 Interrupt Handlers</a></li>
</ul>
</div>
<hr size="1"><address style="text-align: right;"><small>
2010-11-30 04:54:43 +00:00
Generated on Sun Nov 28 2010 14:09:55 for ChibiOS/RT by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.7.1</small></address>
2010-08-10 03:11:02 +00:00
</body>
</html>