sdk-ameba-v4.0c_180328/doc/api_doc/group__timer.html

506 lines
22 KiB
HTML
Raw Permalink Normal View History

2019-04-02 08:34:25 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>SDK3.5: TIMER</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">SDK3.5
</div>
<div id="projectbrief">This document shows Ameba SDK 3.5 APIs</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li class="current"><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#enumval-members">Enumerator</a> </div>
<div class="headertitle">
<div class="title">TIMER<div class="ingroups"><a class="el" href="group__sdk.html">Ameba SDK</a> &raquo; <a class="el" href="group__hal.html">HAL</a></div></div> </div>
</div><!--header-->
<div class="contents">
<p>timer functions
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Ameba Common</h2></td></tr>
<tr class="memitem:ga9041b3db8eb28b8b0ad7740f24b4fcef"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga9041b3db8eb28b8b0ad7740f24b4fcef"></a>
typedef struct gtimer_s&#160;</td><td class="memItemRight" valign="bottom"><b>gtimer_t</b></td></tr>
<tr class="separator:ga9041b3db8eb28b8b0ad7740f24b4fcef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8378a651a617544dd4c93a5313e2f690"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga8378a651a617544dd4c93a5313e2f690"></a>
typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><b>gtimer_irq_handler</b>) (uint32_t id)</td></tr>
<tr class="separator:ga8378a651a617544dd4c93a5313e2f690"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa5677feb7776f5779f4b98ce17d1cc02"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#gaa5677feb7776f5779f4b98ce17d1cc02">gtimer_init</a> (gtimer_t *obj, uint32_t tid)</td></tr>
<tr class="memdesc:gaa5677feb7776f5779f4b98ce17d1cc02"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the timer, including clock/function/timer registers. <a href="#gaa5677feb7776f5779f4b98ce17d1cc02">More...</a><br /></td></tr>
<tr class="separator:gaa5677feb7776f5779f4b98ce17d1cc02"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga314f507400989dbc81493477fc46707a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga314f507400989dbc81493477fc46707a">gtimer_deinit</a> (gtimer_t *obj)</td></tr>
<tr class="memdesc:ga314f507400989dbc81493477fc46707a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Deinitializes the timer, including clock/function/timer registers. <a href="#ga314f507400989dbc81493477fc46707a">More...</a><br /></td></tr>
<tr class="separator:ga314f507400989dbc81493477fc46707a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad7b1b6f347b4d33026728e95e914cbed"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#gad7b1b6f347b4d33026728e95e914cbed">gtimer_read_tick</a> (gtimer_t *obj)</td></tr>
<tr class="memdesc:gad7b1b6f347b4d33026728e95e914cbed"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read current timer tick in Gtimer clock(0~32768). <a href="#gad7b1b6f347b4d33026728e95e914cbed">More...</a><br /></td></tr>
<tr class="separator:gad7b1b6f347b4d33026728e95e914cbed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae786e76349356f2a663efad813949779"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#gae786e76349356f2a663efad813949779">gtimer_read_us</a> (gtimer_t *obj)</td></tr>
<tr class="memdesc:gae786e76349356f2a663efad813949779"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read current timer tick in microsecond. <a href="#gae786e76349356f2a663efad813949779">More...</a><br /></td></tr>
<tr class="separator:gae786e76349356f2a663efad813949779"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa2d47ce0c48fcf2400658380ad5e53ba"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#gaa2d47ce0c48fcf2400658380ad5e53ba">gtimer_reload</a> (gtimer_t *obj, uint32_t duration_us)</td></tr>
<tr class="memdesc:gaa2d47ce0c48fcf2400658380ad5e53ba"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reload timer. <a href="#gaa2d47ce0c48fcf2400658380ad5e53ba">More...</a><br /></td></tr>
<tr class="separator:gaa2d47ce0c48fcf2400658380ad5e53ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga59d52d9ceface7f586e01db02be13ced"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga59d52d9ceface7f586e01db02be13ced">gtimer_start</a> (gtimer_t *obj)</td></tr>
<tr class="memdesc:ga59d52d9ceface7f586e01db02be13ced"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start the timer. <a href="#ga59d52d9ceface7f586e01db02be13ced">More...</a><br /></td></tr>
<tr class="separator:ga59d52d9ceface7f586e01db02be13ced"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7162bda0f1f58b1fc576bb1e37f48caf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga7162bda0f1f58b1fc576bb1e37f48caf">gtimer_start_one_shout</a> (gtimer_t *obj, uint32_t duration_us, void *handler, uint32_t hid)</td></tr>
<tr class="memdesc:ga7162bda0f1f58b1fc576bb1e37f48caf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set up a shout timer, including clock/function/timer registers. <a href="#ga7162bda0f1f58b1fc576bb1e37f48caf">More...</a><br /></td></tr>
<tr class="separator:ga7162bda0f1f58b1fc576bb1e37f48caf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga69ae3d0ab54e6384d0059c769bfe71a5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga69ae3d0ab54e6384d0059c769bfe71a5">gtimer_start_periodical</a> (gtimer_t *obj, uint32_t duration_us, void *handler, uint32_t hid)</td></tr>
<tr class="memdesc:ga69ae3d0ab54e6384d0059c769bfe71a5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set up a periodic timer, including clock/function/timer registers. <a href="#ga69ae3d0ab54e6384d0059c769bfe71a5">More...</a><br /></td></tr>
<tr class="separator:ga69ae3d0ab54e6384d0059c769bfe71a5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1d5aa11977d4ec8ecb133a3388d1db01"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga1d5aa11977d4ec8ecb133a3388d1db01">gtimer_stop</a> (gtimer_t *obj)</td></tr>
<tr class="memdesc:ga1d5aa11977d4ec8ecb133a3388d1db01"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stop the timer, including clock/function/timer registers. <a href="#ga1d5aa11977d4ec8ecb133a3388d1db01">More...</a><br /></td></tr>
<tr class="separator:ga1d5aa11977d4ec8ecb133a3388d1db01"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Ameba Only</h2></td></tr>
<tr class="memitem:gabc6126af1d45847bc59afa0aa3216b04"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gabc6126af1d45847bc59afa0aa3216b04"></a>enum &#160;</td><td class="memItemRight" valign="bottom">{ <br />
&#160;&#160;<b>TIMER0</b> = 2,
<b>TIMER1</b> = 3,
<b>TIMER2</b> = 4,
<b>TIMER3</b> = 5,
<br />
&#160;&#160;<b>TIMER4</b> = 0,
<b>GTIMER_MAX</b> = 5
<br />
}</td></tr>
<tr class="separator:gabc6126af1d45847bc59afa0aa3216b04"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
AmebaZ Only</h2></td></tr>
<tr class="memitem:gadc29c2ff13d900c2f185ee95427fb06c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gadc29c2ff13d900c2f185ee95427fb06c"></a>enum &#160;</td><td class="memItemRight" valign="bottom">{ <br />
&#160;&#160;<b>TIMER0</b> = 2,
<b>TIMER1</b> = 3,
<b>TIMER2</b> = 4,
<b>TIMER3</b> = 5,
<br />
&#160;&#160;<b>GTIMER_MAX</b> = 5
<br />
}</td></tr>
<tr class="separator:gadc29c2ff13d900c2f185ee95427fb06c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>timer functions </p>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga314f507400989dbc81493477fc46707a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void gtimer_deinit </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Deinitializes the timer, including clock/function/timer registers. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="gaa5677feb7776f5779f4b98ce17d1cc02"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void gtimer_init </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>tid</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initializes the timer, including clock/function/timer registers. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
<tr><td class="paramname">tid</td><td>the timer struct ID defined in gtimer structure. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="gad7b1b6f347b4d33026728e95e914cbed"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t gtimer_read_tick </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Read current timer tick in Gtimer clock(0~32768). </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">32</td><td>bit tick time </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="gae786e76349356f2a663efad813949779"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint64_t gtimer_read_us </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Read current timer tick in microsecond. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">64</td><td>bit tick time </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="gaa2d47ce0c48fcf2400658380ad5e53ba"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void gtimer_reload </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>duration_us</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Reload timer. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
<tr><td class="paramname">duration_us</td><td>the time in microsecond of gtimer to reload. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga59d52d9ceface7f586e01db02be13ced"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void gtimer_start </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Start the timer. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga7162bda0f1f58b1fc576bb1e37f48caf"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void gtimer_start_one_shout </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>duration_us</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>handler</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>hid</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set up a shout timer, including clock/function/timer registers. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
<tr><td class="paramname">duration_us</td><td>the period in microsecond of gtimer. </td></tr>
<tr><td class="paramname">handler</td><td>The Pointer to the function that program runs into when timer is up. </td></tr>
<tr><td class="paramname">hid</td><td>the timer struct ID defined in gtimer structure. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga69ae3d0ab54e6384d0059c769bfe71a5"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void gtimer_start_periodical </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>duration_us</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>handler</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>hid</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set up a periodic timer, including clock/function/timer registers. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
<tr><td class="paramname">duration_us</td><td>the period in microsecond of gtimer. </td></tr>
<tr><td class="paramname">handler</td><td>The Pointer to function that program runs into when timer is up. </td></tr>
<tr><td class="paramname">hid</td><td>the timer struct ID defined in gtimer structure. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga1d5aa11977d4ec8ecb133a3388d1db01"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void gtimer_stop </td>
<td>(</td>
<td class="paramtype">gtimer_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Stop the timer, including clock/function/timer registers. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>gtimer object defined in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>