📄 x-timestamp3.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Creating a VxWorks Timestamp Driver </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="x-timestamp.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="x-timestamp.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="x-timestamp2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="x-timestamp4.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="85658">G.3 Timestamp Driver Interface</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85659"> </a>The timestamp timer interface is a non-standard device driver interface; it does not go through the VxWorks I/O system. Although the interface was developed for use with VxWorks kernel instrumentation, it is also useful as a general BSP facility. The timestamp driver's external interface is expected to change in the future, when a more generic, abstracted timer facility is adopted.</p><dd><p class="Body"><a name="85660"> </a>The following sections describe each procedure and its external interface. The descriptions are for a standard timestamp driver. Although the external functionality must remain as described here, procedure content may differ for a particular driver implementation.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="86744"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE: </font></b></a>Remember that each routine must return the appropriate value, as described in the following sections. For example, <b class="routine"><i class="routine">sysTimestampEnable</i></b><b>( )</b> must return <b class="symbol_UC">OK</b> if successful, or <b class="symbol_UC">ERROR</b> if not successful. <b class="symbol_UC">OK</b> and <b class="symbol_UC">ERROR</b> are defined in the VxWorks header file <i class="textVariable">installDir</i><b class="file">/target/h/vxWorks.h</b>.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85665">Path Name Conventions</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85666"> </a>Tornado uses the same tree organization on Windows hosts and UNIX hosts. However, because UNIX and Windows use a different convention to separate directory segments in path names, any concrete examples of path names in this appendix cannot apply to both kinds of host. Because the UNIX convention matches the VxWorks convention, this appendix shows path names using UNIX separators. Whenever you see a path name of the following form in this manual, you can use the path directly on UNIX, but not on Windows:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85667"><i class="textVariable">dir</i>/<i class="textVariable">subdir</i>/<i class="textVariable">file</i> </a></b></pre></dl><dd><p class="Body"><a name="85668"> </a>To obtain the corresponding path name on Windows, use <b class="file">\</b> (backslash) rather than <b class="file">/</b> (slash) as the separator between segments. The following Windows path name corresponds to the example above:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85669"><i class="textVariable">dir</i>\<i class="textVariable">subdir</i>\<i class="textVariable">file</i> </a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85671"><b class="routine"><i class="routine">sysTimestampConnect</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85672"> </a>This routine specifies the <i class="term">timestamp callback routine</i>, a routine to be run each time the timestamp counter rolls over. If this facility is available, <b class="routine"><i class="routine">sysTimeStampConnect</i></b><b>( )</b> must<b>( )</b>store the function pointer in the global variable <b class="symbol_lc">sysTimestampRoutine</b> and return <b class="symbol_UC">OK</b>, to indicate success.</p><dd><p class="Body"><a name="85673"> </a>If the callback cannot be provided, <b class="routine"><i class="routine">sysTimeStampConnect</i></b><b>( )</b>returns <b class="symbol_UC">ERROR</b> to indicate that no callback routine is connected. In this situation, the VxWorks kernel instrumentation does not use the interrupt handler <b class="routine"><i class="routine">sysTimestampInt</i></b><b>( )</b> as part of its timestamp timer implementation, but relies instead on the system clock tick to signal a timestamp reset event (see <a href="x-timestamp4.html#85777"><i class="title">Using the VxWorks System Clock Timer</i></a>). To use the timestamp driver in other applications, you must make similar provisions for an ERROR result.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="86777"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE: </font></b></a><b class="routine"><i class="routine">sysTimestampConnect</i></b><b>( )</b> must not enable or disable the timestamp timer itself. Initialization must be done in the <b class="routine"><i class="routine">sysTimestampEnable</i></b><b>( )</b> routine.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dl class="margin"><dd><pre class="Code2"><b><a name="85678">STATUS sysTimestampConnect ( FUNCPTR routine, int arg )</a></b></pre></dl></dl><dl class="margin"><dd><p class="Body"><a name="85683"> </a>The arguments for this routine are:</p><dl class="margin"><dd><div class="Item2"><a name="85684"> </a><i class="textVariable">routine</i><i class="textVariable"> </i></div><dl class="margin"><dd><div class="Indent2"><a name="85862"> </a>pointer to the function called at each timer rollover interrupt.</div><br></dl><dd><div class="Item2"><a name="85685"> </a><i class="textVariable">arg</i><i class="textVariable"> </i></div><dl class="margin"><dd><div class="Indent2"><a name="85863"> </a>argument for <i class="textVariable">routine</i>.</div><br></dl></dl><dd><p class="Body"><a name="85686"> </a>The result must be <b class="symbol_UC">OK </b>or <b class="symbol_UC">ERROR</b>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85687"><b class="routine"><i class="routine">sysTimestampEnable</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85688"> </a>If the timer is not already enabled, this routine performs all the necessary initialization for the timer (for example, connecting the interrupt vector, resetting registers, configuring for timestamp mode, and so on), and then enables the timestamp timer. If the timer is already enabled, this routine simply resets the timer counter value.</p><dl class="margin"><dd><pre class="Code2"><b><a name="85689">STATUS sysTimestampEnable (void)</a></b></pre></dl><dd><p class="Body"><a name="85690"> </a>This routine takes no arguments.</p><dd><p class="Body"><a name="85691"> </a>The result must be <b class="symbol_UC">OK</b> or <b class="symbol_UC">ERROR</b>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85692"><b class="routine"><i class="routine">sysTimestampDisable</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85693"> </a>This routine disables the timestamp timer. Interrupts are not disabled. However, the tick counter does not count after the timestamp timer is disabled; thus, rollover interrupts are no longer generated.</p><dl class="margin"><dd><pre class="Code2"><b><a name="85694">STATUS sysTimestampDisable (void)</a></b></pre></dl><dd><p class="Body"><a name="85695"> </a>This routine takes no arguments.</p><dd><p class="Body"><a name="85696"> </a>The result must be <b class="symbol_UC">OK</b> or <b class="symbol_UC">ERROR</b>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85697"><b class="routine"><i class="routine">sysTimestampPeriod</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85698"> </a>This routine returns the period of the timer in timestamp ticks. The period is the number of ticks the timestamp timer counts before rolling over (or resetting) and restarting the counting process.</p><dl class="margin"><dd><pre class="Code2"><b><a name="85699">UINT32 sysTimestampPeriod (void)</a></b></pre></dl><dd><p class="Body"><a name="85700"> </a>This routine takes no arguments.</p><dd><p class="Body"><a name="85701"> </a>The result must be the period of the timer in timestamp ticks.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85702"><b class="routine"><i class="routine">sysTimestampFreq</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85703"> </a>This routine returns the output frequency of the timer, in timestamp ticks per second. When possible, the frequency should be derived from actual hardware register values.</p><dd><p class="Body"><a name="85704"> </a>If the timer input clock is programmable, do not set its clock rate in <b class="routine"><i class="routine">sysTimestampFreq</i></b><b>( )</b>. Setting the timer input clock rate should be part of the initialization performed by <b class="routine"><i class="routine">sysHwInit</i></b><b>( )</b> in <b class="file">sysLib.c</b>. </p><dl class="margin"><dd><pre class="Code2"><b><a name="85705">UINT32 sysTimestampFreq (void)</a></b></pre></dl><dd><p class="Body"><a name="85706"> </a>This routine takes no arguments.</p><dd><p class="Body"><a name="85707"> </a>The result must be the timestamp timer frequency, in ticks per second.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85708"><b class="routine"><i class="routine">sysTimestamp</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85709"> </a>This routine returns the current value of the timestamp counter. To convert this tick count to seconds, divide by the result of <b class="routine"><i class="routine">sysTimestampFreq</i></b><b>( )</b>. The result must increase monotonically; that is, the timestamp values must count up. If you are working with a timer that actually counts down, see <a href="x-timestamp4.html#85750"><i class="title">Working Around Deficiencies in Hardware Timers</i></a>.</p><dd><p class="Body"><a name="85713"> </a>This routine should be called with interrupts locked. If interrupts are not already locked, call <b class="routine"><i class="routine">sysTimestampLock</i></b><b>( )</b> instead.</p><dl class="margin"><dd><pre class="Code2"><b><a name="85714">UINT32 sysTimestamp (void)</a></b></pre></dl><dd><p class="Body"><a name="85715"> </a>This routine takes no arguments.</p><dd><p class="Body"><a name="85716"> </a>The result must be the current tick count of the timestamp timer.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85717"><b class="routine"><i class="routine">sysTimestampLock</i></b><b>( )</b> </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85718"> </a>This routine returns the current value of the timestamp counter. To convert the result to seconds, divide the tick count by the result of <b class="routine"><i class="routine">sysTimestampFreq</i></b><b>( )</b>. The result must increase monotonically; that is, the timestamp values must count up. If you are working with a timer that actually counts down, see <a href="x-timestamp4.html#85750"><i class="title">Working Around Deficiencies in Hardware Timers</i></a>.</p><dd><p class="Body"><a name="85722"> </a>This routine locks interrupts for cases where it is necessary to stop the tick counter to read it, or when two independent counters must be read. If interrupts are already locked, call <b class="routine"><i class="routine">sysTimestamp</i></b><b>( )</b>instead.</p><dl class="margin"><dd><pre class="Code2"><b><a name="85723">UINT32 sysTimestampLock (void)</a></b></pre></dl><dd><p class="Body"><a name="85724"> </a>This routine takes no arguments.</p><dd><p class="Body"><a name="85725"> </a>The result must be the current tick count of the timestamp timer.</p></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="x-timestamp.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="x-timestamp.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="x-timestamp2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="x-timestamp4.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -