summaryrefslogtreecommitdiff
path: root/CMSIS/Documentation/RTOS/html/group___c_m_s_i_s___r_t_o_s___wait.html
blob: c0eafec2c7421132901f948d00abff56b37bc853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<!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>Generic Wait Functions</title>
<title>CMSIS-RTOS: Generic Wait Functions</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);
</script>
<link href="stylsheetf" 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: 46px;">
  <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">CMSIS-RTOS
   &#160;<span id="projectnumber">Version 1.02</span>
   </div>
   <div id="projectbrief">CMSIS-RTOS API: Generic RTOS interface for Cortex-M processor-based devices.</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.2 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
      <li><a href="modules.html"><span>Reference</span></a></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___c_m_s_i_s___r_t_o_s___wait.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Generic Wait Functions</div>  </div>
<div class="ingroups"><a class="el" href="group___c_m_s_i_s___r_t_o_s.html">CMSIS-RTOS API</a></div></div><!--header-->
<div class="contents">

<p>Wait for a time period or unspecified events.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga6c97d38879ae86491628f6e647639bad"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga6c97d38879ae86491628f6e647639bad">osFeature_Wait</a>&#160;&#160;&#160;1</td></tr>
<tr class="memdesc:ga6c97d38879ae86491628f6e647639bad"><td class="mdescLeft">&#160;</td><td class="mdescRight">osWait function: 1=available, 0=not available  <a href="#ga6c97d38879ae86491628f6e647639bad"></a><br/></td></tr>
<tr class="separator:ga6c97d38879ae86491628f6e647639bad"><td class="memSeparator" colspan="2">&#160;</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:ga02e19d5e723bfb06ba9324d625162255"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99e">osStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga02e19d5e723bfb06ba9324d625162255">osDelay</a> (uint32_t millisec)</td></tr>
<tr class="memdesc:ga02e19d5e723bfb06ba9324d625162255"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait for Timeout (Time Delay).  <a href="#ga02e19d5e723bfb06ba9324d625162255"></a><br/></td></tr>
<tr class="separator:ga02e19d5e723bfb06ba9324d625162255"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8470c8aaedfde524a44e22e5b2328285"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group___c_m_s_i_s___r_t_o_s___definitions.html#structos_event">osEvent</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga8470c8aaedfde524a44e22e5b2328285">osWait</a> (uint32_t millisec)</td></tr>
<tr class="memdesc:ga8470c8aaedfde524a44e22e5b2328285"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait for Signal, Message, Mail, or Timeout.  <a href="#ga8470c8aaedfde524a44e22e5b2328285"></a><br/></td></tr>
<tr class="separator:ga8470c8aaedfde524a44e22e5b2328285"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<p>The Generic Wait function group provides means for a time delay and allow to wait for unspecified events. </p>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ga6c97d38879ae86491628f6e647639bad"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osFeature_Wait&#160;&#160;&#160;1</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>A CMSIS-RTOS implementation may support the generic wait function <a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga8470c8aaedfde524a44e22e5b2328285">osWait</a>.</p>
<ul>
<li>When <a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga6c97d38879ae86491628f6e647639bad">osFeature_Wait</a> is 1 a generic wait function <a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga8470c8aaedfde524a44e22e5b2328285">osWait</a> is available.</li>
<li>When <a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga6c97d38879ae86491628f6e647639bad">osFeature_Wait</a> is 0 no generic wait function <a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga8470c8aaedfde524a44e22e5b2328285">osWait</a> is available. </li>
</ul>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga02e19d5e723bfb06ba9324d625162255"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99e">osStatus</a> osDelay </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>millisec</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">millisec</td><td><a class="el" href="_function_overview.html#CMSIS_RTOS_TimeOutValue">time delay</a> value </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>Wait for a specified time period in <em>millisec</em>.</p>
<p>The <a class="el" href="_function_overview.html#CMSIS_RTOS_TimeOutValue">millisec</a> value specifies the number of timer ticks and is therefore an upper bound. The exact time delay depends on the actual time elapsed since the last timer tick.</p>
<p>For a value of <b>1</b>, the system waits until the next timer tick occurs. That means that the actual time delay may be up to one timer tick less.</p>
<p><b><a class="el" href="group___c_m_s_i_s___r_t_o_s___status.html">Status and Error Codes</a></b><br/>
</p>
<ul>
<li><em>osEventTimeout:</em> the time delay is executed.</li>
<li><em>osErrorISR:</em> <a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga02e19d5e723bfb06ba9324d625162255">osDelay</a> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>Cannot be called from <a class="el" href="_function_overview.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 &quot;<a class="code" href="cmsis__os_8h.html">cmsis_os.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg)  {               <span class="comment">// Thread function</span></div>
<div class="line">  <a class="code" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99e">osStatus</a> status;                               <span class="comment">// capture the return status</span></div>
<div class="line">  uint32_t delayTime;                            <span class="comment">// delay time in milliseconds</span></div>
<div class="line"> </div>
<div class="line">  delayTime = 1000;                              <span class="comment">// delay 1 second</span></div>
<div class="line">  :</div>
<div class="line">  status = <a class="code" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga02e19d5e723bfb06ba9324d625162255" title="Wait for Timeout (Time Delay).">osDelay</a> (delayTime);                  <span class="comment">// suspend thread execution</span></div>
<div class="line">    <span class="comment">// handle error code</span></div>
<div class="line">  :  </div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga8470c8aaedfde524a44e22e5b2328285"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group___c_m_s_i_s___r_t_o_s___definitions.html#structos_event">osEvent</a> osWait </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>millisec</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">millisec</td><td><a class="el" href="_function_overview.html#CMSIS_RTOS_TimeOutValue">Timout Value</a> or 0 in case of no time-out </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>event that contains signal, message, or mail information or error code. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osWait</b> shall be consistent in every CMSIS-RTOS.</dd></dl>
<p>Wait for any event of the type Signal, Message, Mail for a specified time period in <em>millisec</em>. While the system waits, the thread that is calling this function is put into the state <b>WAITING</b>. When <em>millisec</em> is set to <b>osWaitForever</b>, the function will wait for an infinite time until an event occurs.</p>
<p>The osWait function puts a thread into the state <b>WAITING</b> and waits for any of the following events:</p>
<ul>
<li>A <b>signal</b> sent to that thread explicitly</li>
<li>A <b>message</b> from a message object that is registered to that thread</li>
<li>A <b>mail</b> from a mail object that is registered to that thread</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>This function is optional and may not be provided by all CMSIS-RTOS implementations.</dd></dl>
<p><b><a class="el" href="group___c_m_s_i_s___r_t_o_s___status.html">Status and Error Codes</a></b><br/>
</p>
<ul>
<li><em>osEventSignal:</em> a signal event occurred and is returned.</li>
<li><em>osEventMessage:</em> a message event occurred and is returned.</li>
<li><em>osEventMail:</em> a mail event occurred and is returned.</li>
<li><em>osEventTimeout:</em> the time delay is executed.</li>
<li><em>osErrorISR:</em> <a class="el" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga02e19d5e723bfb06ba9324d625162255">osDelay</a> cannot be called from interrupt service routines.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>Cannot be called from <a class="el" href="_function_overview.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 &quot;<a class="code" href="cmsis__os_8h.html">cmsis_os.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> Thread_1 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg)  {               <span class="comment">// Thread function</span></div>
<div class="line">  <a class="code" href="group___c_m_s_i_s___r_t_o_s___definitions.html#structos_event" title="Event structure contains detailed information about an event.">osEvent</a>  Event;                                <span class="comment">// capture the event</span></div>
<div class="line">  uint32_t waitTime;                             <span class="comment">// wait time in milliseconds</span></div>
<div class="line">  </div>
<div class="line">  :</div>
<div class="line">  waitTime = <a class="code" href="cmsis__os_8h.html#a9eb9a7a797a42e4b55eb171ecc609ddb" title="Timeout value.">osWaitForever</a>;                      <span class="comment">// special &quot;wait&quot; value</span></div>
<div class="line">  Event = <a class="code" href="group___c_m_s_i_s___r_t_o_s___wait.html#ga8470c8aaedfde524a44e22e5b2328285" title="Wait for Signal, Message, Mail, or Timeout.">osWait</a> (waitTime);                     <span class="comment">// wait forever and until an event occurred</span></div>
<div class="line">  <span class="keywordflow">switch</span> (Event.<a class="code" href="group___c_m_s_i_s___r_t_o_s___definitions.html#ad477a289f1f03ac45407b64268d707d3" title="status code: event or error information">status</a>)  {</div>
<div class="line">    <span class="keywordflow">case</span> <a class="code" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99ea5df7e9643aa8a2f5f3a6f6ec59758518" title="function completed; signal event occurred.">osEventSignal</a>:                          <span class="comment">// Signal arrived</span></div>
<div class="line">        :                                        <span class="comment">// Event.value.signals contains the signal flags</span></div>
<div class="line">      <span class="keywordflow">break</span>;</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">case</span> <a class="code" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99ead604f3673359dd4ac643b16dc5a2c342" title="function completed; message event occurred.">osEventMessage</a>:                         <span class="comment">// Message arrived</span></div>
<div class="line">        :                                        <span class="comment">// Event.value.p contains the message pointer</span></div>
<div class="line">        :                                        <span class="comment">// Event.def.message_id contains the message Id</span></div>
<div class="line">      <span class="keywordflow">break</span>;</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">case</span> <a class="code" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99ea15b12e42b42b53f35fb8a2724ad02926" title="function completed; mail event occurred.">osEventMail</a>:                            <span class="comment">// Mail arrived</span></div>
<div class="line">        :                                        <span class="comment">// Event.value.p contains the mail pointer</span></div>
<div class="line">        :                                        <span class="comment">// Event.def.mail_id contains the mail Id</span></div>
<div class="line">      <span class="keywordflow">break</span>;</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">case</span> <a class="code" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99ea78f477732375c0e1fca814e369618177" title="function completed; timeout occurred.">osEventTimeout</a>:                         <span class="comment">// Timeout occurred</span></div>
<div class="line">      <span class="keywordflow">break</span>;</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">default</span>:                                     <span class="comment">// Error occurred</span></div>
<div class="line">      <span class="keywordflow">break</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 Tue Oct 27 2015 14:35:43 for CMSIS-RTOS 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.2 
	-->
	</li>
  </ul>
</div>
</body>
</html>