1 <!-- HTML header for doxygen 1.9.6-->
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
5 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6 <meta http-equiv="X-UA-Compatible" content="IE=11"/>
7 <meta name="viewport" content="width=device-width, initial-scale=1"/>
8 <title>CMSIS-RTOS2: Generic Wait Functions</title>
9 <link href="doxygen.css" rel="stylesheet" type="text/css"/>
10 <link href="tabs.css" rel="stylesheet" type="text/css"/>
11 <link href="extra_navtree.css" rel="stylesheet" type="text/css"/>
12 <link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
13 <link href="extra_search.css" rel="stylesheet" type="text/css"/>
14 <script type="text/javascript" src="jquery.js"></script>
15 <script type="text/javascript" src="dynsections.js"></script>
16 <script type="text/javascript" src="printComponentTabs.js"></script>
17 <script type="text/javascript" src="footer.js"></script>
18 <script type="text/javascript" src="navtree.js"></script>
19 <link href="navtree.css" rel="stylesheet" type="text/css"/>
20 <script type="text/javascript" src="resize.js"></script>
21 <script type="text/javascript" src="navtreedata.js"></script>
22 <script type="text/javascript" src="navtree.js"></script>
23 <link href="search/search.css" rel="stylesheet" type="text/css"/>
24 <script type="text/javascript" src="search/searchdata.js"></script>
25 <script type="text/javascript" src="search/search.js"></script>
26 <script type="text/javascript">
27 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
28 $(document).ready(function() { init_search(); });
31 <script type="text/javascript" src="darkmode_toggle.js"></script>
32 <link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
33 <link href="extra_navtree.css" rel="stylesheet" type="text/css"/>
34 <link href="extra_search.css" rel="stylesheet" type="text/css"/>
35 <link href="version.css" rel="stylesheet" type="text/css" />
36 <script type="text/javascript" src="../../../version.js"></script>
39 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
41 <table cellspacing="0" cellpadding="0">
43 <tr style="height: 55px;">
44 <td id="projectlogo" style="padding: 1.5em;"><img alt="Logo" src="cmsis_logo_white_small.png"/></td>
45 <td style="padding-left: 1em; padding-bottom: 1em;padding-top: 1em;">
46 <div id="projectname">CMSIS-RTOS2
47  <span id="projectnumber"><script type="text/javascript">
49 writeHeader.call(this);
50 writeVersionDropdown.call(this);
55 <div id="projectbrief">Real-Time Operating System API</div>
57 <td> <div id="MSearchBox" class="MSearchBoxInactive">
59 <span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()"> </span>
60 <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
61 onfocus="searchBox.OnSearchFieldFocus(true)"
62 onblur="searchBox.OnSearchFieldFocus(false)"
63 onkeyup="searchBox.OnSearchFieldChange(event)"/>
64 </span><span class="right">
65 <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
69 <!--END !PROJECT_NAME-->
74 <!-- end header part -->
75 <div id="CMSISnav" class="tabs1">
77 <script type="text/javascript">
78 writeComponentTabs.call(this);
82 <script type="text/javascript">
83 writeSubComponentTabs.call(this);
85 <!-- Generated by Doxygen 1.9.6 -->
86 <script type="text/javascript">
87 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
88 var searchBox = new SearchBox("searchBox", "search/",'.html');
92 <div id="side-nav" class="ui-resizable side-nav-resizable">
94 <div id="nav-tree-contents">
95 <div id="nav-sync" class="sync"></div>
98 <div id="splitbar" style="-moz-user-select:none;"
99 class="ui-resizable-handle">
102 <script type="text/javascript">
103 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
104 $(document).ready(function(){initNavTree('group__CMSIS__RTOS__Wait.html',''); initResizable(); });
107 <div id="doc-content">
108 <!-- window showing the filter options -->
109 <div id="MSearchSelectWindow"
110 onmouseover="return searchBox.OnSearchSelectShow()"
111 onmouseout="return searchBox.OnSearchSelectHide()"
112 onkeydown="return searchBox.OnSearchSelectKey(event)">
115 <!-- iframe showing the search results (closed by default) -->
116 <div id="MSearchResultsWindow">
117 <div id="MSearchResults">
120 <div id="SRResults"></div>
121 <div class="SRStatus" id="Loading">Loading...</div>
122 <div class="SRStatus" id="Searching">Searching...</div>
123 <div class="SRStatus" id="NoMatches">No Matches</div>
130 <div class="summary">
131 <a href="#func-members">Functions</a> </div>
132 <div class="headertitle"><div class="title">Generic Wait Functions<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS API v2</a></div></div></div>
134 <div class="contents">
136 <p>Wait for a certain period of time.
137 <a href="#details">More...</a></p>
138 <table class="memberdecls">
139 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
140 Functions</h2></td></tr>
141 <tr class="memitem:gaf6055a51390ef65b6b6edc28bf47322e"><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__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a> (uint32_t ticks)</td></tr>
142 <tr class="memdesc:gaf6055a51390ef65b6b6edc28bf47322e"><td class="mdescLeft"> </td><td class="mdescRight">Wait for Timeout (Time Delay). <br /></td></tr>
143 <tr class="separator:gaf6055a51390ef65b6b6edc28bf47322e"><td class="memSeparator" colspan="2"> </td></tr>
144 <tr class="memitem:ga3c807924c2d6d43bc2ffb49da3f7f3a1"><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__Wait.html#ga3c807924c2d6d43bc2ffb49da3f7f3a1">osDelayUntil</a> (uint32_t ticks)</td></tr>
145 <tr class="memdesc:ga3c807924c2d6d43bc2ffb49da3f7f3a1"><td class="mdescLeft"> </td><td class="mdescRight">Wait until specified time. <br /></td></tr>
146 <tr class="separator:ga3c807924c2d6d43bc2ffb49da3f7f3a1"><td class="memSeparator" colspan="2"> </td></tr>
148 <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
149 <p>The generic wait functions provide means for a time delay.</p>
150 <dl class="section note"><dt>Note</dt><dd>Generic wait functions cannot be called from Interrupt Service Routines. </dd></dl>
151 <h2 class="groupheader">Function Documentation</h2>
152 <a id="gaf6055a51390ef65b6b6edc28bf47322e" name="gaf6055a51390ef65b6b6edc28bf47322e"></a>
153 <h2 class="memtitle"><span class="permalink"><a href="#gaf6055a51390ef65b6b6edc28bf47322e">◆ </a></span>osDelay()</h2>
155 <div class="memitem">
156 <div class="memproto">
157 <table class="memname">
159 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osDelay </td>
161 <td class="paramtype">uint32_t </td>
162 <td class="paramname"><em>ticks</em></td><td>)</td>
166 </div><div class="memdoc">
167 <dl class="params"><dt>Parameters</dt><dd>
168 <table class="params">
169 <tr><td class="paramdir">[in]</td><td class="paramname">ticks</td><td>time ticks value </td></tr>
173 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
174 <p>The function <b>osDelay</b> waits for a time period specified in kernel <em>ticks</em>. For a value of <span class="XML-Token">1</span> the system waits until the next timer tick occurs. The actual time delay may be up to one timer tick less than specified, i.e. calling <code>osDelay(1)</code> right before the next system tick occurs the thread is rescheduled immediately.</p>
175 <p>The delayed thread is put into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state and a context switch occurs immediately. The thread is automatically put back to the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state after the given amount of ticks has elapsed. If the thread will have the highest priority in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state it will be scheduled immediately.</p>
176 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
177 <li><em>osOK:</em> the time delay is executed.</li>
178 <li><em>osErrorParameter:</em> the time cannot be handled (zero value).</li>
179 <li><em>osErrorISR:</em> <a class="el" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a> cannot be called from Interrupt Service Routines.</li>
180 <li><em>osError:</em> <a class="el" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a> cannot be executed (kernel not running or no <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread exists).</li>
182 <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from Interrupt Service Routines.</dd></dl>
183 <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>
184 <div class="line"> </div>
185 <div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> *arg) { <span class="comment">// Thread function</span></div>
186 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status; <span class="comment">// capture the return status</span></div>
187 <div class="line"> uint32_t delayTime; <span class="comment">// delay time in milliseconds</span></div>
188 <div class="line"> </div>
189 <div class="line"> delayTime = 1000U; <span class="comment">// delay 1 second</span></div>
190 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(delayTime); <span class="comment">// suspend thread execution</span></div>
191 <div class="line">}</div>
192 <div class="ttc" id="acmsis__os2_8h_html"><div class="ttname"><a href="cmsis__os2_8h.html">cmsis_os2.h</a></div></div>
193 <div class="ttc" id="agroup__CMSIS__RTOS__Definitions_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813e"><div class="ttname"><a href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a></div><div class="ttdeci">osStatus_t</div><div class="ttdoc">Status code values returned by CMSIS-RTOS functions.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:246</div></div>
194 <div class="ttc" id="agroup__CMSIS__RTOS__Wait_html_gaf6055a51390ef65b6b6edc28bf47322e"><div class="ttname"><a href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a></div><div class="ttdeci">osStatus_t osDelay(uint32_t ticks)</div><div class="ttdoc">Wait for Timeout (Time Delay).</div></div>
195 </div><!-- fragment -->
198 <a id="ga3c807924c2d6d43bc2ffb49da3f7f3a1" name="ga3c807924c2d6d43bc2ffb49da3f7f3a1"></a>
199 <h2 class="memtitle"><span class="permalink"><a href="#ga3c807924c2d6d43bc2ffb49da3f7f3a1">◆ </a></span>osDelayUntil()</h2>
201 <div class="memitem">
202 <div class="memproto">
203 <table class="memname">
205 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osDelayUntil </td>
207 <td class="paramtype">uint32_t </td>
208 <td class="paramname"><em>ticks</em></td><td>)</td>
212 </div><div class="memdoc">
213 <dl class="params"><dt>Parameters</dt><dd>
214 <table class="params">
215 <tr><td class="paramdir">[in]</td><td class="paramname">ticks</td><td>absolute time in ticks </td></tr>
219 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
220 <p>The function <b>osDelayUntil</b> waits until an absolute time (specified in kernel <em>ticks</em>) is reached.</p>
221 <p>The corner case when the kernel tick counter overflows is handled by <b>osDelayUntil</b>. Thus it is absolutely legal to provide a value which is lower than the current tick value, i.e. returned by <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga84bcdbf2fb76b10c8df4e439f0c7e11b">osKernelGetTickCount</a>. Typically as a user you do not have to take care about the overflow. The only limitation you have to have in mind is that the maximum delay is limited to (2<sup>31</sup>)-1 ticks.</p>
222 <p>The delayed thread is put into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state and a context switch occurs immediately. The thread is automatically put back to the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state when the given time is reached. If the thread will have the highest priority in <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state it will be scheduled immediately.</p>
223 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
224 <li><em>osOK:</em> the time delay is executed.</li>
225 <li><em>osErrorParameter:</em> the time cannot be handled (out of bounds).</li>
226 <li><em>osErrorISR:</em> <a class="el" href="group__CMSIS__RTOS__Wait.html#ga3c807924c2d6d43bc2ffb49da3f7f3a1">osDelayUntil</a> cannot be called from Interrupt Service Routines.</li>
227 <li><em>osError:</em> <a class="el" href="group__CMSIS__RTOS__Wait.html#ga3c807924c2d6d43bc2ffb49da3f7f3a1">osDelayUntil</a> cannot be executed (kernel not running or no <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> thread exists).</li>
229 <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from Interrupt Service Routines.</dd></dl>
230 <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>
231 <div class="line"> </div>
232 <div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> *arg) { <span class="comment">// Thread function</span></div>
233 <div class="line"> uint32_t tick;</div>
234 <div class="line"> </div>
235 <div class="line"> tick = <a class="code hl_function" href="group__CMSIS__RTOS__KernelCtrl.html#ga84bcdbf2fb76b10c8df4e439f0c7e11b">osKernelGetTickCount</a>(); <span class="comment">// retrieve the number of system ticks</span></div>
236 <div class="line"> <span class="keywordflow">for</span> (;;) {</div>
237 <div class="line"> tick += 1000U; <span class="comment">// delay 1000 ticks periodically</span></div>
238 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__Wait.html#ga3c807924c2d6d43bc2ffb49da3f7f3a1">osDelayUntil</a>(tick);</div>
239 <div class="line"> <span class="comment">// ...</span></div>
240 <div class="line"> }</div>
241 <div class="line">}</div>
242 <div class="ttc" id="agroup__CMSIS__RTOS__KernelCtrl_html_ga84bcdbf2fb76b10c8df4e439f0c7e11b"><div class="ttname"><a href="group__CMSIS__RTOS__KernelCtrl.html#ga84bcdbf2fb76b10c8df4e439f0c7e11b">osKernelGetTickCount</a></div><div class="ttdeci">uint32_t osKernelGetTickCount(void)</div><div class="ttdoc">Get the RTOS kernel tick count.</div></div>
243 <div class="ttc" id="agroup__CMSIS__RTOS__Wait_html_ga3c807924c2d6d43bc2ffb49da3f7f3a1"><div class="ttname"><a href="group__CMSIS__RTOS__Wait.html#ga3c807924c2d6d43bc2ffb49da3f7f3a1">osDelayUntil</a></div><div class="ttdeci">osStatus_t osDelayUntil(uint32_t ticks)</div><div class="ttdoc">Wait until specified time.</div></div>
244 </div><!-- fragment -->
247 </div><!-- contents -->
248 </div><!-- doc-content -->
249 <!-- start footer part -->
250 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
253 <script type="text/javascript">
255 writeFooter.call(this);