diff options
author | Ali Labbene <ali.labbene@st.com> | 2019-12-11 08:59:21 +0100 |
---|---|---|
committer | Ali Labbene <ali.labbene@st.com> | 2019-12-16 16:35:24 +0100 |
commit | 9f95ff5b6ba01db09552b84a0ab79607060a2666 (patch) | |
tree | 8a6e0dda832555c692307869aed49d07ee7facfe /docs/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html | |
parent | 76177aa280494bb36d7a0bcbda1078d4db717020 (diff) | |
download | st-cmsis-core-lowfat-9f95ff5b6ba01db09552b84a0ab79607060a2666.tar.gz st-cmsis-core-lowfat-9f95ff5b6ba01db09552b84a0ab79607060a2666.tar.bz2 st-cmsis-core-lowfat-9f95ff5b6ba01db09552b84a0ab79607060a2666.zip |
Official ARM version: v5.4.0
Add CMSIS V5.4.0, please refer to index.html available under \docs folder.
Note: content of \CMSIS\Core\Include has been copied under \Include to keep the same structure
used in existing projects, and thus avoid projects mass update
Note: the following components have been removed from ARM original delivery (as not used in ST packages)
- CMSIS_EW2018.pdf
- .gitattributes
- .gitignore
- \Device
- \CMSIS
- \CoreValidation
- \DAP
- \Documentation
- \DoxyGen
- \Driver
- \Pack
- \RTOS\CMSIS_RTOS_Tutorial.pdf
- \RTOS\RTX
- \RTOS\Template
- \RTOS2\RTX
- \Utilities
- All ARM/GCC projects files are deleted from \DSP, \RTOS and \RTOS2
Change-Id: Ia026c3f0f0d016627a4fb5a9032852c33d24b4d3
Diffstat (limited to 'docs/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html')
-rw-r--r-- | docs/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html | 646 |
1 files changed, 646 insertions, 0 deletions
diff --git a/docs/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html b/docs/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html new file mode 100644 index 0000000..4ef2b0b --- /dev/null +++ b/docs/RTOS2/html/group__CMSIS__RTOS__TimerMgmt.html @@ -0,0 +1,646 @@ +<!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"/> +<title>Timer Management</title> +<title>CMSIS-RTOS2: Timer Management</title> +<link href="tabs.css" rel="stylesheet" type="text/css"/> +<link href="cmsis.css" rel="stylesheet" type="text/css" /> +<script type="text/javascript" src="jquery.js"></script> +<script type="text/javascript" src="dynsections.js"></script> +<script type="text/javascript" src="printComponentTabs.js"></script> +<link href="navtree.css" rel="stylesheet" type="text/css"/> +<script type="text/javascript" src="resize.js"></script> +<script type="text/javascript" src="navtree.js"></script> +<script type="text/javascript"> + $(document).ready(initResizable); + $(window).load(resizeHeight); +</script> +<link href="search/search.css" rel="stylesheet" type="text/css"/> +<script type="text/javascript" src="search/search.js"></script> +<script type="text/javascript"> + $(document).ready(function() { searchBox.OnSelectItem(0); }); +</script> +</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: 46px;"> + <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td> + <td style="padding-left: 0.5em;"> + <div id="projectname">CMSIS-RTOS2 +  <span id="projectnumber">Version 2.1.3</span> + </div> + <div id="projectbrief">Real-Time Operating System: API and RTX Reference Implementation</div> + </td> + </tr> + </tbody> +</table> +</div> +<!-- end header part --> +<div id="CMSISnav" class="tabs1"> + <ul class="tablist"> + <script type="text/javascript"> + <!-- + writeComponentTabs.call(this); + //--> + </script> + </ul> +</div> +<!-- Generated by Doxygen 1.8.6 --> +<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 Page</span></a></li> + <li><a href="pages.html"><span>Usage and Description</span></a></li> + <li><a href="modules.html"><span>Reference</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 --> +<div id="side-nav" class="ui-resizable side-nav-resizable"> + <div id="nav-tree"> + <div id="nav-tree-contents"> + <div id="nav-sync" class="sync"></div> + </div> + </div> + <div id="splitbar" style="-moz-user-select:none;" + class="ui-resizable-handle"> + </div> +</div> +<script type="text/javascript"> +$(document).ready(function(){initNavTree('group__CMSIS__RTOS__TimerMgmt.html','');}); +</script> +<div id="doc-content"> +<!-- window showing the filter options --> +<div id="MSearchSelectWindow" + onmouseover="return searchBox.OnSearchSelectShow()" + onmouseout="return searchBox.OnSearchSelectHide()" + onkeydown="return searchBox.OnSearchSelectKey(event)"> +<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Pages</a></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="#nested-classes">Data Structures</a> | +<a href="#typedef-members">Typedefs</a> | +<a href="#enum-members">Enumerations</a> | +<a href="#enumval-members">Enumerator</a> | +<a href="#func-members">Functions</a> </div> + <div class="headertitle"> +<div class="title">Timer Management<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS API v2</a></div></div> </div> +</div><!--header--> +<div class="contents"> + +<p>Create and control timer and timer callback functions. +<a href="#details">More...</a></p> +<table class="memberdecls"> +<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a> +Data Structures</h2></td></tr> +<tr class="memitem:structosTimerAttr__t"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#structosTimerAttr__t">osTimerAttr_t</a></td></tr> +<tr class="memdesc:structosTimerAttr__t"><td class="mdescLeft"> </td><td class="mdescRight">Attributes structure for timer. <a href="group__CMSIS__RTOS__TimerMgmt.html#structosTimerAttr__t">More...</a><br/></td></tr> +<tr class="separator:structosTimerAttr__t"><td class="memSeparator" colspan="2"> </td></tr> +</table><table class="memberdecls"> +<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a> +Typedefs</h2></td></tr> +<tr class="memitem:gaad5409379689ee27bb0a0b56ea4a4b34"><td class="memItemLeft" align="right" valign="top">typedef void * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a></td></tr> +<tr class="separator:gaad5409379689ee27bb0a0b56ea4a4b34"><td class="memSeparator" colspan="2"> </td></tr> +<tr class="memitem:gaacf768c1ec64b020598afb985d7b30be"><td class="memItemLeft" align="right" valign="top">typedef void(* </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaacf768c1ec64b020598afb985d7b30be">osTimerFunc_t</a> )(void *argument)</td></tr> +<tr class="memdesc:gaacf768c1ec64b020598afb985d7b30be"><td class="mdescLeft"> </td><td class="mdescRight">Timer callback function. <a href="#gaacf768c1ec64b020598afb985d7b30be">More...</a><br/></td></tr> +<tr class="separator:gaacf768c1ec64b020598afb985d7b30be"><td class="memSeparator" colspan="2"> </td></tr> +</table><table class="memberdecls"> +<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a> +Enumerations</h2></td></tr> +<tr class="memitem:ga7dc24a4c2b90334427081c3da7a71915"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#ga7dc24a4c2b90334427081c3da7a71915">osTimerType_t</a> { <br/> +  <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915a2e0e1f31c742c84b497c4d7143357bdb">osTimerOnce</a> = 0, +<br/> +  <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35">osTimerPeriodic</a> = 1 +<br/> + }</td></tr> +<tr class="memdesc:ga7dc24a4c2b90334427081c3da7a71915"><td class="mdescLeft"> </td><td class="mdescRight">Timer type. <a href="group__CMSIS__RTOS__TimerMgmt.html#ga7dc24a4c2b90334427081c3da7a71915">More...</a><br/></td></tr> +<tr class="separator:ga7dc24a4c2b90334427081c3da7a71915"><td class="memSeparator" colspan="2"> </td></tr> +</table><table class="memberdecls"> +<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> +Functions</h2></td></tr> +<tr class="memitem:gad4e7f785c5f700a509f55a3bf6a62bec"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a> (<a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaacf768c1ec64b020598afb985d7b30be">osTimerFunc_t</a> func, <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#ga7dc24a4c2b90334427081c3da7a71915">osTimerType_t</a> type, void *argument, const <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#structosTimerAttr__t">osTimerAttr_t</a> *attr)</td></tr> +<tr class="memdesc:gad4e7f785c5f700a509f55a3bf6a62bec"><td class="mdescLeft"> </td><td class="mdescRight">Create and Initialize a timer. <a href="#gad4e7f785c5f700a509f55a3bf6a62bec">More...</a><br/></td></tr> +<tr class="separator:gad4e7f785c5f700a509f55a3bf6a62bec"><td class="memSeparator" colspan="2"> </td></tr> +<tr class="memitem:ga4f82a98eee4d9ea79507e44340d3d319"><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#ga4f82a98eee4d9ea79507e44340d3d319">osTimerGetName</a> (<a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> timer_id)</td></tr> +<tr class="memdesc:ga4f82a98eee4d9ea79507e44340d3d319"><td class="mdescLeft"> </td><td class="mdescRight">Get name of a timer. <a href="#ga4f82a98eee4d9ea79507e44340d3d319">More...</a><br/></td></tr> +<tr class="separator:ga4f82a98eee4d9ea79507e44340d3d319"><td class="memSeparator" colspan="2"> </td></tr> +<tr class="memitem:gab6ee2859ea657641b7adfac599b8121d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a> (<a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> timer_id, uint32_t ticks)</td></tr> +<tr class="memdesc:gab6ee2859ea657641b7adfac599b8121d"><td class="mdescLeft"> </td><td class="mdescRight">Start or restart a timer. <a href="#gab6ee2859ea657641b7adfac599b8121d">More...</a><br/></td></tr> +<tr class="separator:gab6ee2859ea657641b7adfac599b8121d"><td class="memSeparator" colspan="2"> </td></tr> +<tr class="memitem:gabd7a89356da7717293eb0bc5d87b8ac9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gabd7a89356da7717293eb0bc5d87b8ac9">osTimerStop</a> (<a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> timer_id)</td></tr> +<tr class="memdesc:gabd7a89356da7717293eb0bc5d87b8ac9"><td class="mdescLeft"> </td><td class="mdescRight">Stop a timer. <a href="#gabd7a89356da7717293eb0bc5d87b8ac9">More...</a><br/></td></tr> +<tr class="separator:gabd7a89356da7717293eb0bc5d87b8ac9"><td class="memSeparator" colspan="2"> </td></tr> +<tr class="memitem:ga69d3589f54194022c30dd01e45ec6741"><td class="memItemLeft" align="right" valign="top">uint32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#ga69d3589f54194022c30dd01e45ec6741">osTimerIsRunning</a> (<a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> timer_id)</td></tr> +<tr class="memdesc:ga69d3589f54194022c30dd01e45ec6741"><td class="mdescLeft"> </td><td class="mdescRight">Check if a timer is running. <a href="#ga69d3589f54194022c30dd01e45ec6741">More...</a><br/></td></tr> +<tr class="separator:ga69d3589f54194022c30dd01e45ec6741"><td class="memSeparator" colspan="2"> </td></tr> +<tr class="memitem:gad0001dd74721ab461789324806db2453"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad0001dd74721ab461789324806db2453">osTimerDelete</a> (<a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> timer_id)</td></tr> +<tr class="memdesc:gad0001dd74721ab461789324806db2453"><td class="mdescLeft"> </td><td class="mdescRight">Delete a timer. <a href="#gad0001dd74721ab461789324806db2453">More...</a><br/></td></tr> +<tr class="separator:gad0001dd74721ab461789324806db2453"><td class="memSeparator" colspan="2"> </td></tr> +</table> +<a name="details" id="details"></a><h2 class="groupheader">Description</h2> +<p>In addition to the <a class="el" href="group__CMSIS__RTOS__Wait.html">Generic Wait Functions</a> CMSIS-RTOS also supports virtual timer objects. These timer objects can trigger the execution of a function (not threads). When a timer expires, a callback function is executed to run associated code with the timer. Each timer can be configured as a one-shot or a periodic timer. A periodic timer repeats its operation until it is <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad0001dd74721ab461789324806db2453">deleted</a> or <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gabd7a89356da7717293eb0bc5d87b8ac9">stopped</a>. All timers can be <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">started, restarted</a>, or <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gabd7a89356da7717293eb0bc5d87b8ac9">stopped</a>.</p> +<dl class="section note"><dt>Note</dt><dd>RTX handles Timers in the thread <b>osRtxTimerThread</b>. Callback functions run under control of this thread and may use other CMSIS-RTOS API calls. The <b>osRtxTimerThread</b> is configured in <a class="el" href="config_rtx5.html#timerConfig">Timer Configuration</a>. </dd> +<dd> +Timer management functions cannot be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl> +<p>The figure below shows the behavior of a periodic timer. For one-shot timers, the timer stops after execution of the callback function.</p> +<div class="image"> +<img src="Timer.png" alt="Timer.png"/> +<div class="caption"> +Behavior of a Periodic Timer</div></div> +<h2>Working with Timers </h2> +<p>The following steps are required to use a software timer:</p> +<ol type="1"> +<li>Define the timers: <div class="fragment"><div class="line"><a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> one_shot_id, periodic_id;</div> +</div><!-- fragment --></li> +<li>Define callback functions: <div class="fragment"><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> one_shot_Callback (<span class="keywordtype">void</span> *argument) {</div> +<div class="line"> int32_t arg = (int32_t)argument; <span class="comment">// cast back argument '0' </span></div> +<div class="line"> <span class="comment">// do something, i.e. set thread/event flags</span></div> +<div class="line">}</div> +<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> periodic_Callback (<span class="keywordtype">void</span> *argument) {</div> +<div class="line"> int32_t arg = (int32_t)argument; <span class="comment">// cast back argument '5'</span></div> +<div class="line"> <span class="comment">// do something, i.e. set thread/event flags</span></div> +<div class="line">}</div> +</div><!-- fragment --></li> +<li>Instantiate and start the timers: <div class="fragment"><div class="line"><span class="comment">// creates a one-shot timer:</span></div> +<div class="line">one_shot_id = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>(one_shot_Callback, <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915a2e0e1f31c742c84b497c4d7143357bdb">osTimerOnce</a>, (<span class="keywordtype">void</span> *)0, NULL); <span class="comment">// (void*)0 is passed as an argument</span></div> +<div class="line"> <span class="comment">// to the callback function</span></div> +<div class="line"><span class="comment">// creates a periodic timer:</span></div> +<div class="line">periodic_id = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>(periodic_Callback, <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35">osTimerPeriodic</a>, (<span class="keywordtype">void</span> *)5, NULL); <span class="comment">// (void*)5 is passed as an argument</span></div> +<div class="line"> <span class="comment">// to the callback function</span></div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a>(one_shot_id, 500);</div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a>(periodic_id, 1500);</div> +<div class="line"> </div> +<div class="line"><span class="comment">// start the one-shot timer again after it has triggered the first time:</span></div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a>(one_shot_id, 500);</div> +<div class="line"> </div> +<div class="line"><span class="comment">// when timers are not needed any longer free the resources:</span></div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad0001dd74721ab461789324806db2453">osTimerDelete</a>(one_shot_id);</div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad0001dd74721ab461789324806db2453">osTimerDelete</a>(periodic_id);</div> +</div><!-- fragment --> </li> +</ol> +<hr/><h2 class="groupheader">Data Structure Documentation</h2> +<a name="structosTimerAttr__t" id="structosTimerAttr__t"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname">struct osTimerAttr_t</td> + </tr> + </table> +</div><div class="memdoc"> +<div class="textblock"><p>Specifies the following attributes for the <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a> function. </p> +</div><table class="fieldtable"> +<tr><th colspan="3">Data Fields</th></tr> +<tr><td class="fieldtype"> +<a class="anchor" id="ab74e6bf80237ddc4109968cedc58c151"></a>const char *</td> +<td class="fieldname"> +name</td> +<td class="fielddoc"> +name of the timer <p>Pointer to a constant string with a human readable name (displayed during debugging) of the timer object.</p> +<p>Default: <span class="XML-Token">NULL</span> no name specified. </p> +</td></tr> +<tr><td class="fieldtype"> +<a class="anchor" id="a6e93b49cb79c12f768d72580c7731f30"></a>uint32_t</td> +<td class="fieldname"> +attr_bits</td> +<td class="fielddoc"> +attribute bits <p>Reserved for future use (must be set to '0' for future compatibility). </p> +</td></tr> +<tr><td class="fieldtype"> +<a class="anchor" id="a1e100dc33d403841ed3c344e3397868e"></a>void *</td> +<td class="fieldname"> +cb_mem</td> +<td class="fielddoc"> +memory for control block <p>Pointer to a memory for the timer control block object. Refer to <a class="el" href="theory_of_operation.html#StaticObjectMemory">Static Object Memory</a> for more information.</p> +<p>Default: <span class="XML-Token">NULL</span> to use <a class="el" href="group__CMSIS__RTOS__MemoryMgmt.html#CMSIS_RTOS_MemoryMgmt_Automatic">Automatic Dynamic Allocation</a> for the timer control block. </p> +</td></tr> +<tr><td class="fieldtype"> +<a class="anchor" id="aa55a4335d12dc2785dc00fdc292d1159"></a>uint32_t</td> +<td class="fieldname"> +cb_size</td> +<td class="fielddoc"> +size of provided memory for control block <p>The size (in bytes) of memory block passed with <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. For RTX, the minimum value is defined with <a class="el" href="group__rtx5__specific__defines.html#gaf8a145fdeb24fd912971f0671b1a3603">osRtxTimerCbSize</a> (higher values are permitted).</p> +<p>Default: <span class="XML-Token">0</span> as the default is no memory provided with <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. </p> +</td></tr> +</table> + +</div> +</div> +<h2 class="groupheader">Typedef Documentation</h2> +<a class="anchor" id="gaad5409379689ee27bb0a0b56ea4a4b34"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a></td> + </tr> + </table> +</div><div class="memdoc"> +<p>Timer ID identifies the timer.</p> +<p>Instances of this type hold a reference to a timer object. <br/> +Returned by:</p> +<ul> +<li><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a> </li> +</ul> + +</div> +</div> +<a class="anchor" id="gaacf768c1ec64b020598afb985d7b30be"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname">void(* osTimerFunc_t)(void *argument)</td> + </tr> + </table> +</div><div class="memdoc"> +<p>The timer callback function is called every time the timer elapses.</p> +<p>The callback might be executed either in a dedicated timer thread or in interrupt context. Thus it is recommended to only use ISR callable functions from the timer callback.</p> +<dl class="params"><dt>Parameters</dt><dd> + <table class="params"> + <tr><td class="paramdir">[in]</td><td class="paramname">argument</td><td>The argument provided to <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>. </td></tr> + </table> + </dd> +</dl> + +</div> +</div> +<h2 class="groupheader">Enumeration Type Documentation</h2> +<a class="anchor" id="ga7dc24a4c2b90334427081c3da7a71915"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname">enum <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#ga7dc24a4c2b90334427081c3da7a71915">osTimerType_t</a></td> + </tr> + </table> +</div><div class="memdoc"> +<p>The <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#ga7dc24a4c2b90334427081c3da7a71915">osTimerType_t</a> specifies the a repeating (periodic) or one-shot timer for the function <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>. </p> +<table class="fieldtable"> +<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="gga7dc24a4c2b90334427081c3da7a71915a2e0e1f31c742c84b497c4d7143357bdb"></a>osTimerOnce</em> </td><td class="fielddoc"> +<p>One-shot timer. </p> +<p>The timer is not automatically restarted once it has elapsed. It can be restarted manually using <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a> as needed. </p> +</td></tr> +<tr><td class="fieldname"><em><a class="anchor" id="gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35"></a>osTimerPeriodic</em> </td><td class="fielddoc"> +<p>Repeating timer. </p> +<p>The timer repeats automatically and triggers the callback continuously while running, see <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a> and <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gabd7a89356da7717293eb0bc5d87b8ac9">osTimerStop</a>. </p> +</td></tr> +</table> + +</div> +</div> +<h2 class="groupheader">Function Documentation</h2> +<a class="anchor" id="gad4e7f785c5f700a509f55a3bf6a62bec"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> osTimerNew </td> + <td>(</td> + <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaacf768c1ec64b020598afb985d7b30be">osTimerFunc_t</a> </td> + <td class="paramname"><em>func</em>, </td> + </tr> + <tr> + <td class="paramkey"></td> + <td></td> + <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#ga7dc24a4c2b90334427081c3da7a71915">osTimerType_t</a> </td> + <td class="paramname"><em>type</em>, </td> + </tr> + <tr> + <td class="paramkey"></td> + <td></td> + <td class="paramtype">void * </td> + <td class="paramname"><em>argument</em>, </td> + </tr> + <tr> + <td class="paramkey"></td> + <td></td> + <td class="paramtype">const <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#structosTimerAttr__t">osTimerAttr_t</a> * </td> + <td class="paramname"><em>attr</em> </td> + </tr> + <tr> + <td></td> + <td>)</td> + <td></td><td></td> + </tr> + </table> +</div><div class="memdoc"> +<dl class="params"><dt>Parameters</dt><dd> + <table class="params"> + <tr><td class="paramdir">[in]</td><td class="paramname">func</td><td>function pointer to callback function. </td></tr> + <tr><td class="paramdir">[in]</td><td class="paramname">type</td><td><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915a2e0e1f31c742c84b497c4d7143357bdb">osTimerOnce</a> for one-shot or <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35">osTimerPeriodic</a> for periodic behavior. </td></tr> + <tr><td class="paramdir">[in]</td><td class="paramname">argument</td><td>argument to the timer callback function. </td></tr> + <tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>timer attributes; NULL: default values. </td></tr> + </table> + </dd> +</dl> +<dl class="section return"><dt>Returns</dt><dd>timer ID for reference by other functions or NULL in case of error.</dd></dl> +<p>The function <b>osTimerNew</b> creates an one-shot or periodic timer and associates it with a callback function with <em>argument</em>. The timer is in stopped state until it is started with <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a>. The function can be safely called before the RTOS is started (call to <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>), but not before it is initialized (call to <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>).</p> +<p>The function <b>osTimerNew</b> returns the pointer to the timer object identifier or <span class="XML-Token">NULL</span> in case of an error.</p> +<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl> +<p><b>Code Example</b> </p> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div> +<div class="line"> </div> +<div class="line"><span class="keywordtype">void</span> Timer1_Callback (<span class="keywordtype">void</span> *arg); <span class="comment">// prototypes for timer callback function</span></div> +<div class="line"><span class="keywordtype">void</span> Timer2_Callback (<span class="keywordtype">void</span> *arg); </div> +<div class="line"> </div> +<div class="line">uint32_t exec1; <span class="comment">// argument for the timer call back function</span></div> +<div class="line">uint32_t exec2; <span class="comment">// argument for the timer call back function</span></div> +<div class="line"> </div> +<div class="line"><span class="keywordtype">void</span> TimerCreate_example (<span class="keywordtype">void</span>) {</div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> id1; <span class="comment">// timer id</span></div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> id2; <span class="comment">// timer id</span></div> +<div class="line"> </div> +<div class="line"> <span class="comment">// Create one-shoot timer</span></div> +<div class="line"> exec1 = 1;</div> +<div class="line"> id1 = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a> (Timer1_Callback, <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915a2e0e1f31c742c84b497c4d7143357bdb">osTimerOnce</a>, &exec1, NULL);</div> +<div class="line"> <span class="keywordflow">if</span> (id1 != NULL) {</div> +<div class="line"> <span class="comment">// One-shoot timer created</span></div> +<div class="line"> }</div> +<div class="line"> </div> +<div class="line"> <span class="comment">// Create periodic timer</span></div> +<div class="line"> exec2 = 2;</div> +<div class="line"> id2 = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a> (Timer2_Callback, <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35">osTimerPeriodic</a>, &exec2, NULL);</div> +<div class="line"> <span class="keywordflow">if</span> (id2 != NULL) {</div> +<div class="line"> <span class="comment">// Periodic timer created</span></div> +<div class="line"> }</div> +<div class="line"> :</div> +<div class="line">}</div> +</div><!-- fragment --> +</div> +</div> +<a class="anchor" id="ga4f82a98eee4d9ea79507e44340d3d319"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname">*const char * osTimerGetName </td> + <td>(</td> + <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> </td> + <td class="paramname"><em>timer_id</em></td><td>)</td> + <td></td> + </tr> + </table> +</div><div class="memdoc"> +<dl class="params"><dt>Parameters</dt><dd> + <table class="params"> + <tr><td class="paramdir">[in]</td><td class="paramname">timer_id</td><td>timer ID obtained by <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>. </td></tr> + </table> + </dd> +</dl> +<dl class="section return"><dt>Returns</dt><dd>name as null-terminated string.</dd></dl> +<p>The function <b>osTimerGetName</b> returns the pointer to the name string of the timer identified by parameter <em>timer_id</em> or <span class="XML-Token">NULL</span> in case of an error.</p> +<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl> + +</div> +</div> +<a class="anchor" id="gab6ee2859ea657641b7adfac599b8121d"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osTimerStart </td> + <td>(</td> + <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> </td> + <td class="paramname"><em>timer_id</em>, </td> + </tr> + <tr> + <td class="paramkey"></td> + <td></td> + <td class="paramtype">uint32_t </td> + <td class="paramname"><em>ticks</em> </td> + </tr> + <tr> + <td></td> + <td>)</td> + <td></td><td></td> + </tr> + </table> +</div><div class="memdoc"> +<dl class="params"><dt>Parameters</dt><dd> + <table class="params"> + <tr><td class="paramdir">[in]</td><td class="paramname">timer_id</td><td>timer ID obtained by <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>. </td></tr> + <tr><td class="paramdir">[in]</td><td class="paramname">ticks</td><td><a class="el" href="theory_of_operation.html#CMSIS_RTOS_TimeOutValue">time ticks</a> value of the timer. </td></tr> + </table> + </dd> +</dl> +<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl> +<p>The function <b>osTimerStart</b> starts or restarts a timer specified by the parameter <em>timer_id</em>. The parameter <em>ticks</em> specifies the value of the timer in <a class="el" href="theory_of_operation.html#CMSIS_RTOS_TimeOutValue">time ticks</a>.</p> +<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p> +<ul> +<li><em>osOK:</em> the specified timer has been started or restarted.</li> +<li><em>osErrorISR:</em> <b>osTimerStart</b> cannot be called from interrupt service routines.</li> +<li><em>osErrorParameter:</em> parameter <em>timer_id</em> is either <span class="XML-Token">NULL</span> or invalid or <em>ticks</em> is incorrect.</li> +<li><em>osErrorResource:</em> the timer specified by parameter <em>timer_id</em> is in an invalid timer state.</li> +</ul> +<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl> +<p><b>Code Example</b> </p> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div> +<div class="line"> </div> +<div class="line"><span class="keywordtype">void</span> Timer_Callback (<span class="keywordtype">void</span> *arg) { <span class="comment">// timer callback function</span></div> +<div class="line"> <span class="comment">// arg contains &exec</span></div> +<div class="line"> <span class="comment">// called every second after osTimerStart</span></div> +<div class="line">} </div> +<div class="line"> </div> +<div class="line">uint32_t exec; <span class="comment">// argument for the timer call back function</span></div> +<div class="line"> </div> +<div class="line"><span class="keywordtype">void</span> TimerStart_example (<span class="keywordtype">void</span>) {</div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> id; <span class="comment">// timer id</span></div> +<div class="line"> uint32_t timerDelay; <span class="comment">// timer value</span></div> +<div class="line"> osStatus_t status; <span class="comment">// function return status</span></div> +<div class="line"> </div> +<div class="line"> <span class="comment">// Create periodic timer</span></div> +<div class="line"> exec = 1;</div> +<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a> (Timer_Callback, <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35">osTimerPeriodic</a>, &exec, NULL);</div> +<div class="line"> <span class="keywordflow">if</span> (<span class="keywordtype">id</span>) {</div> +<div class="line"> timerDelay = 1000;</div> +<div class="line"> status = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a> (<span class="keywordtype">id</span>, timerDelay); <span class="comment">// start timer</span></div> +<div class="line"> <span class="keywordflow">if</span> (status != <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div> +<div class="line"> <span class="comment">// Timer could not be started</span></div> +<div class="line"> } </div> +<div class="line"> }</div> +<div class="line"> ;</div> +<div class="line">}</div> +</div><!-- fragment --> +</div> +</div> +<a class="anchor" id="gabd7a89356da7717293eb0bc5d87b8ac9"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osTimerStop </td> + <td>(</td> + <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> </td> + <td class="paramname"><em>timer_id</em></td><td>)</td> + <td></td> + </tr> + </table> +</div><div class="memdoc"> +<dl class="params"><dt>Parameters</dt><dd> + <table class="params"> + <tr><td class="paramdir">[in]</td><td class="paramname">timer_id</td><td>timer ID obtained by <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>. </td></tr> + </table> + </dd> +</dl> +<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl> +<p>The function <b>osTimerStop</b> stops a timer specified by the parameter <em>timer_id</em>.</p> +<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p> +<ul> +<li><em>osOK:</em> the specified timer has been stopped.</li> +<li><em>osErrorISR:</em> <b>osTimerStop</b> cannot be called from interrupt service routines.</li> +<li><em>osErrorParameter:</em> parameter <em>timer_id</em> is either <span class="XML-Token">NULL</span> or invalid.</li> +<li><em>osErrorResource:</em> the timer specified by parameter <em>timer_id</em> is not running (you can only stop a running timer).</li> +</ul> +<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl> +<p><b>Code Example</b> </p> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div> +<div class="line"> </div> +<div class="line"><span class="keywordtype">void</span> Timer_Callback (<span class="keywordtype">void</span> *arg); <span class="comment">// prototype for timer callback function</span></div> +<div class="line"> </div> +<div class="line">uint32_t exec; <span class="comment">// argument for the timer call back function</span></div> +<div class="line"></div> +<div class="line"><span class="keywordtype">void</span> TimerStop_example (<span class="keywordtype">void</span>) {</div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> id; <span class="comment">// timer id</span></div> +<div class="line"> osStatus_t status; <span class="comment">// function return status</span></div> +<div class="line"> </div> +<div class="line"> <span class="comment">// Create periodic timer</span></div> +<div class="line"> exec = 1;</div> +<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a> (Timer_Callback, <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35">osTimerPeriodic</a>, &exec, NULL);</div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a> (<span class="keywordtype">id</span>, 1000); <span class="comment">// start timer</span></div> +<div class="line"> :</div> +<div class="line"> status = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gabd7a89356da7717293eb0bc5d87b8ac9">osTimerStop</a> (<span class="keywordtype">id</span>); <span class="comment">// stop timer</span></div> +<div class="line"> <span class="keywordflow">if</span> (status != <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div> +<div class="line"> <span class="comment">// Timer could not be stopped</span></div> +<div class="line"> } </div> +<div class="line"> ;</div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a> (<span class="keywordtype">id</span>, 1000); <span class="comment">// start timer again</span></div> +<div class="line"> ;</div> +<div class="line">}</div> +</div><!-- fragment --> +</div> +</div> +<a class="anchor" id="ga69d3589f54194022c30dd01e45ec6741"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname">uint32_t osTimerIsRunning </td> + <td>(</td> + <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> </td> + <td class="paramname"><em>timer_id</em></td><td>)</td> + <td></td> + </tr> + </table> +</div><div class="memdoc"> +<dl class="params"><dt>Parameters</dt><dd> + <table class="params"> + <tr><td class="paramdir">[in]</td><td class="paramname">timer_id</td><td>timer ID obtained by <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>. </td></tr> + </table> + </dd> +</dl> +<dl class="section return"><dt>Returns</dt><dd>0 not running, 1 running.</dd></dl> +<p>The function <b>osTimerIsRunning</b> checks whether a timer specified by parameter <em>timer_id</em> is running. It returns <span class="XML-Token">1</span> if the timer is running and <span class="XML-Token">0</span> if the timer is stopped or an error occurred.</p> +<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl> + +</div> +</div> +<a class="anchor" id="gad0001dd74721ab461789324806db2453"></a> +<div class="memitem"> +<div class="memproto"> + <table class="memname"> + <tr> + <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osTimerDelete </td> + <td>(</td> + <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> </td> + <td class="paramname"><em>timer_id</em></td><td>)</td> + <td></td> + </tr> + </table> +</div><div class="memdoc"> +<dl class="params"><dt>Parameters</dt><dd> + <table class="params"> + <tr><td class="paramdir">[in]</td><td class="paramname">timer_id</td><td>timer ID obtained by <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a>. </td></tr> + </table> + </dd> +</dl> +<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl> +<p>The function <b>osTimerDelete</b> deletes the timer specified by parameter <em>timer_id</em>.</p> +<p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p> +<ul> +<li><em>osOK:</em> the specified timer has been deleted.</li> +<li><em>osErrorISR:</em> <b>osTimerDelete</b> cannot be called from interrupt service routines.</li> +<li><em>osErrorParameter:</em> parameter <em>timer_id</em> is either <span class="XML-Token">NULL</span> or invalid.</li> +<li><em>osErrorResource:</em> the timer specified by parameter <em>timer_id</em> is in an invalid timer state.</li> +</ul> +<dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl> +<p><b>Code Example</b> </p> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span></div> +<div class="line"></div> +<div class="line"><span class="keywordtype">void</span> Timer_Callback (<span class="keywordtype">void</span> *arg); <span class="comment">// prototype for timer callback function</span></div> +<div class="line"> </div> +<div class="line">uint32_t exec; <span class="comment">// argument for the timer call back function</span></div> +<div class="line"></div> +<div class="line"><span class="keywordtype">void</span> TimerDelete_example (<span class="keywordtype">void</span>) {</div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gaad5409379689ee27bb0a0b56ea4a4b34">osTimerId_t</a> id; <span class="comment">// timer id</span></div> +<div class="line"> osStatus_t status; <span class="comment">// function return status </span></div> +<div class="line"> </div> +<div class="line"> <span class="comment">// Create periodic timer</span></div> +<div class="line"> exec = 1;</div> +<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad4e7f785c5f700a509f55a3bf6a62bec">osTimerNew</a> (Timer_Callback, <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gga7dc24a4c2b90334427081c3da7a71915ab3463d921dc310938094745c230f2b35">osTimerPeriodic</a>, &exec, NULL);</div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gab6ee2859ea657641b7adfac599b8121d">osTimerStart</a> (<span class="keywordtype">id</span>, 1000UL); <span class="comment">// start timer</span></div> +<div class="line"> ;</div> +<div class="line"> status = <a class="code" href="group__CMSIS__RTOS__TimerMgmt.html#gad0001dd74721ab461789324806db2453">osTimerDelete</a> (<span class="keywordtype">id</span>); <span class="comment">// stop and delete timer</span></div> +<div class="line"> <span class="keywordflow">if</span> (status != <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>) {</div> +<div class="line"> <span class="comment">// Timer could not be deleted</span></div> +<div class="line"> } </div> +<div class="line"> ;</div> +<div class="line">}</div> +</div><!-- fragment --> +</div> +</div> +</div><!-- contents --> +</div><!-- doc-content --> +<!-- start footer part --> +<div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> + <ul> + <li class="footer">Generated on Wed Aug 1 2018 17:12:45 for CMSIS-RTOS2 by Arm Ltd. All rights reserved. + <!-- + <a href="http://www.doxygen.org/index.html"> + <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 + --> + </li> + </ul> +</div> +</body> +</html> |