group__CMSIS__RTOS__SignalMgmt.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <title>Signal Events</title>
  7. <title>CMSIS-RTOS: Signal Events</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <link href="cmsis.css" rel="stylesheet" type="text/css" />
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <script type="text/javascript" src="printComponentTabs.js"></script>
  13. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  14. <script type="text/javascript" src="resize.js"></script>
  15. <script type="text/javascript" src="navtree.js"></script>
  16. <script type="text/javascript">
  17. $(document).ready(initResizable);
  18. $(window).load(resizeHeight);
  19. </script>
  20. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  21. <script type="text/javascript" src="search/search.js"></script>
  22. <script type="text/javascript">
  23. $(document).ready(function() { searchBox.OnSelectItem(0); });
  24. </script>
  25. </head>
  26. <body>
  27. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  28. <div id="titlearea">
  29. <table cellspacing="0" cellpadding="0">
  30. <tbody>
  31. <tr style="height: 46px;">
  32. <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  33. <td style="padding-left: 0.5em;">
  34. <div id="projectname">CMSIS-RTOS
  35. &#160;<span id="projectnumber">Version 1.03</span>
  36. </div>
  37. <div id="projectbrief">Real-Time Operating System: API and RTX Reference Implementation.</div>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. <!-- end header part -->
  44. <div id="CMSISnav" class="tabs1">
  45. <ul class="tablist">
  46. <script type="text/javascript">
  47. <!--
  48. writeComponentTabs.call(this);
  49. //-->
  50. </script>
  51. </ul>
  52. </div>
  53. <!-- Generated by Doxygen 1.8.6 -->
  54. <script type="text/javascript">
  55. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  56. </script>
  57. <div id="navrow1" class="tabs">
  58. <ul class="tablist">
  59. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  60. <li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
  61. <li><a href="modules.html"><span>Reference</span></a></li>
  62. <li>
  63. <div id="MSearchBox" class="MSearchBoxInactive">
  64. <span class="left">
  65. <img id="MSearchSelect" src="search/mag_sel.png"
  66. onmouseover="return searchBox.OnSearchSelectShow()"
  67. onmouseout="return searchBox.OnSearchSelectHide()"
  68. alt=""/>
  69. <input type="text" id="MSearchField" value="Search" accesskey="S"
  70. onfocus="searchBox.OnSearchFieldFocus(true)"
  71. onblur="searchBox.OnSearchFieldFocus(false)"
  72. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  73. </span><span class="right">
  74. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  75. </span>
  76. </div>
  77. </li>
  78. </ul>
  79. </div>
  80. </div><!-- top -->
  81. <div id="side-nav" class="ui-resizable side-nav-resizable">
  82. <div id="nav-tree">
  83. <div id="nav-tree-contents">
  84. <div id="nav-sync" class="sync"></div>
  85. </div>
  86. </div>
  87. <div id="splitbar" style="-moz-user-select:none;"
  88. class="ui-resizable-handle">
  89. </div>
  90. </div>
  91. <script type="text/javascript">
  92. $(document).ready(function(){initNavTree('group__CMSIS__RTOS__SignalMgmt.html','');});
  93. </script>
  94. <div id="doc-content">
  95. <!-- window showing the filter options -->
  96. <div id="MSearchSelectWindow"
  97. onmouseover="return searchBox.OnSearchSelectShow()"
  98. onmouseout="return searchBox.OnSearchSelectHide()"
  99. onkeydown="return searchBox.OnSearchSelectKey(event)">
  100. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>
  101. <!-- iframe showing the search results (closed by default) -->
  102. <div id="MSearchResultsWindow">
  103. <iframe src="javascript:void(0)" frameborder="0"
  104. name="MSearchResults" id="MSearchResults">
  105. </iframe>
  106. </div>
  107. <div class="header">
  108. <div class="summary">
  109. <a href="#define-members">Macros</a> &#124;
  110. <a href="#func-members">Functions</a> </div>
  111. <div class="headertitle">
  112. <div class="title">Signal Events<div class="ingroups"><a class="el" href="group__CMSIS__RTOS__InterThread.html">Inter-Thread Communication and Resource Sharing</a></div></div> </div>
  113. </div><!--header-->
  114. <div class="contents">
  115. <p>Synchronize threads using signals.
  116. <a href="#details">More...</a></p>
  117. <table class="memberdecls">
  118. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
  119. Macros</h2></td></tr>
  120. <tr class="memitem:ga01edde265710d883b6e237d34a6ef4a6"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga01edde265710d883b6e237d34a6ef4a6">osFeature_Signals</a>&#160;&#160;&#160;8</td></tr>
  121. <tr class="memdesc:ga01edde265710d883b6e237d34a6ef4a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">maximum number of Signal Flags available per thread <a href="#ga01edde265710d883b6e237d34a6ef4a6">More...</a><br/></td></tr>
  122. <tr class="separator:ga01edde265710d883b6e237d34a6ef4a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
  123. </table><table class="memberdecls">
  124. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  125. Functions</h2></td></tr>
  126. <tr class="memitem:ga3de2730654589d6c3559c4b9e2825553"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga3de2730654589d6c3559c4b9e2825553">osSignalSet</a> (<a class="el" href="cmsis__os_8h.html#adfeb153a84a81309e2d958268197617f">osThreadId</a> thread_id, int32_t signals)</td></tr>
  127. <tr class="memdesc:ga3de2730654589d6c3559c4b9e2825553"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the specified Signal Flags of an active thread. <a href="#ga3de2730654589d6c3559c4b9e2825553">More...</a><br/></td></tr>
  128. <tr class="separator:ga3de2730654589d6c3559c4b9e2825553"><td class="memSeparator" colspan="2">&#160;</td></tr>
  129. <tr class="memitem:ga87283a6ebc31ce9ed42baf3ea7e4eab6"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga87283a6ebc31ce9ed42baf3ea7e4eab6">osSignalClear</a> (<a class="el" href="cmsis__os_8h.html#adfeb153a84a81309e2d958268197617f">osThreadId</a> thread_id, int32_t signals)</td></tr>
  130. <tr class="memdesc:ga87283a6ebc31ce9ed42baf3ea7e4eab6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clear the specified Signal Flags of an active thread. <a href="#ga87283a6ebc31ce9ed42baf3ea7e4eab6">More...</a><br/></td></tr>
  131. <tr class="separator:ga87283a6ebc31ce9ed42baf3ea7e4eab6"><td class="memSeparator" colspan="2">&#160;</td></tr>
  132. <tr class="memitem:ga38860acda96df47da6923348d96fc4c9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#structosEvent">osEvent</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a> (int32_t signals, uint32_t millisec)</td></tr>
  133. <tr class="memdesc:ga38860acda96df47da6923348d96fc4c9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait for one or more Signal Flags to become signaled for the current <b>RUNNING</b> thread. <a href="#ga38860acda96df47da6923348d96fc4c9">More...</a><br/></td></tr>
  134. <tr class="separator:ga38860acda96df47da6923348d96fc4c9"><td class="memSeparator" colspan="2">&#160;</td></tr>
  135. </table>
  136. <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
  137. <p>Signals are used to trigger execution states between threads. The signal management functions in CMSIS-RTOS allow you to control or wait for signal flags. Each thread has up to 31 assigned signal flags. The maximum number of signal flags is defined in the <a class="el" href="cmsis__os_8h.html">cmsis_os.h</a> file (<b>#define osFeature_Signals</b>).</p>
  138. <p>A thread</p>
  139. <ul>
  140. <li>can wait for signals to be set (using <a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a>). Using this function, it enters the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">WAITING</a> state. The <a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a> parameter <em>signals</em> defines the signals that are required to put the thread back into <b>READY</b> state.</li>
  141. <li>may set one or more flags in any other given thread (using <a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga3de2730654589d6c3559c4b9e2825553">osSignalSet</a>).</li>
  142. <li>may clear its own signals or the signals of other threads (using <a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga87283a6ebc31ce9ed42baf3ea7e4eab6">osSignalClear</a>).</li>
  143. </ul>
  144. <p>When a thread wakes up and resumes execution, its signal flags are automatically cleared.</p>
  145. <h2>Working with Signals </h2>
  146. <p>Here is a simple example that shows how two thread can communicate with each others using signals:</p>
  147. <div class="image">
  148. <img src="simple_signal.png" alt="simple_signal.png"/>
  149. <div class="caption">
  150. Simple signal event communication</div></div>
  151. <p> The following steps are required to use signals:</p>
  152. <ol type="1">
  153. <li>In the thread (for example thread ID <code>tid_thread1</code>) that is supposed to wait for a signal, call the wait function: <div class="fragment"><div class="line"><a class="code" href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a> (0x0001, <a class="code" href="cmsis__os_8h.html#a9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>); <span class="comment">// wait forever for the signal 0x0001</span></div>
  154. </div><!-- fragment --></li>
  155. <li>In another thread (or threads) that are supposed to wake the waiting thread up call: <div class="fragment"><div class="line"><a class="code" href="group__CMSIS__RTOS__SignalMgmt.html#ga3de2730654589d6c3559c4b9e2825553">osSignalSet</a> (tid_thread1, 0x0001); <span class="comment">// set the signal 0x0001 for thread tid_thread1</span></div>
  156. <div class="line"><a class="code" href="group__CMSIS__RTOS__Wait.html#ga02e19d5e723bfb06ba9324d625162255">osDelay</a> (1000); <span class="comment">// wait for 1 second</span></div>
  157. </div><!-- fragment --> </li>
  158. </ol>
  159. <h2 class="groupheader">Macro Definition Documentation</h2>
  160. <a class="anchor" id="ga01edde265710d883b6e237d34a6ef4a6"></a>
  161. <div class="memitem">
  162. <div class="memproto">
  163. <table class="memname">
  164. <tr>
  165. <td class="memname">#define osFeature_Signals&#160;&#160;&#160;8</td>
  166. </tr>
  167. </table>
  168. </div><div class="memdoc">
  169. <p>The CMSIS-RTOS API may support a variable number of signal flags. This define specifies the number of signal flags available per thread. The maximum value is 32 signal flags per thread.</p>
  170. <p><a class="el" href="rtxImplementation.html">CMSIS-RTOS RTX</a> Setting: <b>osFeature_Signals</b> is 16 </p>
  171. </div>
  172. </div>
  173. <h2 class="groupheader">Function Documentation</h2>
  174. <a class="anchor" id="ga87283a6ebc31ce9ed42baf3ea7e4eab6"></a>
  175. <div class="memitem">
  176. <div class="memproto">
  177. <table class="memname">
  178. <tr>
  179. <td class="memname">int32_t osSignalClear </td>
  180. <td>(</td>
  181. <td class="paramtype"><a class="el" href="cmsis__os_8h.html#adfeb153a84a81309e2d958268197617f">osThreadId</a>&#160;</td>
  182. <td class="paramname"><em>thread_id</em>, </td>
  183. </tr>
  184. <tr>
  185. <td class="paramkey"></td>
  186. <td></td>
  187. <td class="paramtype">int32_t&#160;</td>
  188. <td class="paramname"><em>signals</em>&#160;</td>
  189. </tr>
  190. <tr>
  191. <td></td>
  192. <td>)</td>
  193. <td></td><td></td>
  194. </tr>
  195. </table>
  196. </div><div class="memdoc">
  197. <dl class="params"><dt>Parameters</dt><dd>
  198. <table class="params">
  199. <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gab1df2a28925862ef8f9cf4e1c995c5a7">osThreadGetId</a>. </td></tr>
  200. <tr><td class="paramdir">[in]</td><td class="paramname">signals</td><td>specifies the signal flags of the thread that shall be cleared. </td></tr>
  201. </table>
  202. </dd>
  203. </dl>
  204. <dl class="section return"><dt>Returns</dt><dd>previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters or call from ISR. </dd></dl>
  205. <dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osSignalClear</b> shall be consistent in every CMSIS-RTOS.</dd></dl>
  206. <p>Clear the signal flags of an active thread.</p>
  207. <dl class="section note"><dt>Note</dt><dd>Cannot be called from <a class="el" href="functionOverview.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
  208. <p><b>Code Example</b> </p>
  209. <div class="fragment"><div class="line"><span class="keywordtype">void</span> Thread_2 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg);</div>
  210. <div class="line"></div>
  211. <div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaee93d929beb350f16e5cc7fa602e229f">osThreadDef</a> (Thread_2, <a class="code" href="cmsis__os_8h.html#ga7f2b42f1983b9107775ec2a1c69a849aa914433934143a9ba767e59577c56e6c2">osPriorityHigh</a>, 1, 0);</div>
  212. <div class="line"> </div>
  213. <div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> EX_Signal_1 (<span class="keywordtype">void</span>) {</div>
  214. <div class="line"> int32_t signals;</div>
  215. <div class="line"> <a class="code" href="cmsis__os_8h.html#adfeb153a84a81309e2d958268197617f">osThreadId</a> thread_id;</div>
  216. <div class="line"> </div>
  217. <div class="line"> thread_id = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> (<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaf0c7c6b5e09f8be198312144b5c9e453">osThread</a>(Thread_2), NULL);</div>
  218. <div class="line"> <span class="keywordflow">if</span> (thread_id == NULL) {</div>
  219. <div class="line"> <span class="comment">// Failed to create a thread.</span></div>
  220. <div class="line"> }</div>
  221. <div class="line"> <span class="keywordflow">else</span> {</div>
  222. <div class="line">f :</div>
  223. <div class="line"> signals = <a class="code" href="group__CMSIS__RTOS__SignalMgmt.html#ga87283a6ebc31ce9ed42baf3ea7e4eab6">osSignalClear</a> (thread_id, 0x01);</div>
  224. <div class="line"> }</div>
  225. <div class="line">}</div>
  226. </div><!-- fragment -->
  227. </div>
  228. </div>
  229. <a class="anchor" id="ga3de2730654589d6c3559c4b9e2825553"></a>
  230. <div class="memitem">
  231. <div class="memproto">
  232. <table class="memname">
  233. <tr>
  234. <td class="memname">int32_t osSignalSet </td>
  235. <td>(</td>
  236. <td class="paramtype"><a class="el" href="cmsis__os_8h.html#adfeb153a84a81309e2d958268197617f">osThreadId</a>&#160;</td>
  237. <td class="paramname"><em>thread_id</em>, </td>
  238. </tr>
  239. <tr>
  240. <td class="paramkey"></td>
  241. <td></td>
  242. <td class="paramtype">int32_t&#160;</td>
  243. <td class="paramname"><em>signals</em>&#160;</td>
  244. </tr>
  245. <tr>
  246. <td></td>
  247. <td>)</td>
  248. <td></td><td></td>
  249. </tr>
  250. </table>
  251. </div><div class="memdoc">
  252. <dl class="params"><dt>Parameters</dt><dd>
  253. <table class="params">
  254. <tr><td class="paramdir">[in]</td><td class="paramname">thread_id</td><td>thread ID obtained by <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> or <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#gab1df2a28925862ef8f9cf4e1c995c5a7">osThreadGetId</a>. </td></tr>
  255. <tr><td class="paramdir">[in]</td><td class="paramname">signals</td><td>specifies the signal flags of the thread that should be set. </td></tr>
  256. </table>
  257. </dd>
  258. </dl>
  259. <dl class="section return"><dt>Returns</dt><dd>previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters. </dd></dl>
  260. <dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osSignalSet</b> shall be consistent in every CMSIS-RTOS.</dd></dl>
  261. <p>Set the signal flags of an active thread. This function may be used also within interrupt service routines.</p>
  262. <dl class="section note"><dt>Note</dt><dd><a class="el" href="functionOverview.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a> can call this function.</dd></dl>
  263. <p><b>Code Example</b> </p>
  264. <div class="fragment"><div class="line"><span class="keywordtype">void</span> Thread_2 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg);</div>
  265. <div class="line"> </div>
  266. <div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaee93d929beb350f16e5cc7fa602e229f">osThreadDef</a> (Thread_2, <a class="code" href="cmsis__os_8h.html#ga7f2b42f1983b9107775ec2a1c69a849aa914433934143a9ba767e59577c56e6c2">osPriorityHigh</a>, 1, 0);</div>
  267. <div class="line"> </div>
  268. <div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> EX_Signal_1 (<span class="keywordtype">void</span>) {</div>
  269. <div class="line"> int32_t signals;</div>
  270. <div class="line"> uint32_t exec;</div>
  271. <div class="line"> <a class="code" href="cmsis__os_8h.html#adfeb153a84a81309e2d958268197617f">osThreadId</a> thread_id;</div>
  272. <div class="line"> </div>
  273. <div class="line"> thread_id = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> (<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaf0c7c6b5e09f8be198312144b5c9e453">osThread</a>(Thread_2), NULL);</div>
  274. <div class="line"> <span class="keywordflow">if</span> (thread_id == NULL) {</div>
  275. <div class="line"> <span class="comment">// Failed to create a thread.</span></div>
  276. <div class="line"> }</div>
  277. <div class="line"> <span class="keywordflow">else</span> {</div>
  278. <div class="line"> signals = <a class="code" href="group__CMSIS__RTOS__SignalMgmt.html#ga3de2730654589d6c3559c4b9e2825553">osSignalSet</a> (thread_id, 0x00000005); <span class="comment">// Send signals to the created thread</span></div>
  279. <div class="line"> }</div>
  280. <div class="line">}</div>
  281. </div><!-- fragment -->
  282. </div>
  283. </div>
  284. <a class="anchor" id="ga38860acda96df47da6923348d96fc4c9"></a>
  285. <div class="memitem">
  286. <div class="memproto">
  287. <table class="memname">
  288. <tr>
  289. <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#structosEvent">osEvent</a> osSignalWait </td>
  290. <td>(</td>
  291. <td class="paramtype">int32_t&#160;</td>
  292. <td class="paramname"><em>signals</em>, </td>
  293. </tr>
  294. <tr>
  295. <td class="paramkey"></td>
  296. <td></td>
  297. <td class="paramtype">uint32_t&#160;</td>
  298. <td class="paramname"><em>millisec</em>&#160;</td>
  299. </tr>
  300. <tr>
  301. <td></td>
  302. <td>)</td>
  303. <td></td><td></td>
  304. </tr>
  305. </table>
  306. </div><div class="memdoc">
  307. <dl class="params"><dt>Parameters</dt><dd>
  308. <table class="params">
  309. <tr><td class="paramdir">[in]</td><td class="paramname">signals</td><td>wait until all specified signal flags set or 0 for any single signal flag. </td></tr>
  310. <tr><td class="paramdir">[in]</td><td class="paramname">millisec</td><td><a class="el" href="functionOverview.html#CMSIS_RTOS_TimeOutValue">Timout Value</a> or 0 in case of no time-out. </td></tr>
  311. </table>
  312. </dd>
  313. </dl>
  314. <dl class="section return"><dt>Returns</dt><dd>event flag information or error code. </dd></dl>
  315. <dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osSignalWait</b> shall be consistent in every CMSIS-RTOS.</dd></dl>
  316. <p>Suspend the execution of the current <b>RUNNING</b> thread until all specified signal flags with the parameter <em>signals</em> are set. When the parameter <em>signals</em> is 0 the current <b>RUNNING</b> thread is suspended until any signal is set. When these signal flags are already set, the function returns instantly. Otherwise the thread is put into the state <b>WAITING</b>. Signal flags that are reported as event are automatically cleared.</p>
  317. <p>The argument <em>millisec</em> specifies how long the system waits for the specified signal flags. While the system waits the thread calling this function is put into the state <b>WAITING</b>. The timeout value can have the following values:</p>
  318. <ul>
  319. <li>when <em>millisec</em> is 0, the function returns instantly.</li>
  320. <li>when <em>millisec</em> is set to <b>osWaitForever</b> the function will wait for an infinite time until a specified signal is set.</li>
  321. <li>all other values specify a time in millisecond for a timeout.</li>
  322. </ul>
  323. <p><b><a class="el" href="group__CMSIS__RTOS__Status.html">Status and Error Codes</a></b><br/>
  324. </p>
  325. <ul>
  326. <li><em>osOK:</em> no signal received when the timeout value <em>millisec</em> was 0.</li>
  327. <li><em>osEventTimeout:</em> signal not occurred within timeout</li>
  328. <li><em>osEventSignal:</em> signal occurred, <em>value.signals</em> contains the signal flags; these signal flags are cleared.</li>
  329. <li><em>osErrorValue:</em> the value <em>signals</em> is outside of the permitted range.</li>
  330. <li><em>osErrorISR:</em> <a class="el" href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a> cannot be called from interrupt service routines.</li>
  331. </ul>
  332. <dl class="section note"><dt>Note</dt><dd>Cannot be called from <a class="el" href="functionOverview.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
  333. <p><b>Code Example</b> </p>
  334. <div class="fragment"><div class="line"><span class="keywordtype">void</span> Thread_2 (<span class="keywordtype">void</span> <span class="keyword">const</span> *arg);</div>
  335. <div class="line"> </div>
  336. <div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaee93d929beb350f16e5cc7fa602e229f">osThreadDef</a> (Thread_2, <a class="code" href="cmsis__os_8h.html#ga7f2b42f1983b9107775ec2a1c69a849aa914433934143a9ba767e59577c56e6c2">osPriorityHigh</a>, 1, 0);</div>
  337. <div class="line"> </div>
  338. <div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> EX_Signal_1 (<span class="keywordtype">void</span>) {</div>
  339. <div class="line"> <a class="code" href="cmsis__os_8h.html#adfeb153a84a81309e2d958268197617f">osThreadId</a> thread_id;</div>
  340. <div class="line"> <a class="code" href="group__CMSIS__RTOS__Definitions.html#structosEvent">osEvent</a> evt;</div>
  341. <div class="line"> </div>
  342. <div class="line"> thread_id = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> (<a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaf0c7c6b5e09f8be198312144b5c9e453">osThread</a>(Thread_2), NULL);</div>
  343. <div class="line"> <span class="keywordflow">if</span> (thread_id == NULL) {</div>
  344. <div class="line"> <span class="comment">// Failed to create a thread.</span></div>
  345. <div class="line"> }</div>
  346. <div class="line"> <span class="keywordflow">else</span> {</div>
  347. <div class="line"> :</div>
  348. <div class="line"> <span class="comment">// wait for a signal</span></div>
  349. <div class="line"> evt = <a class="code" href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a> (0x01, 100);</div>
  350. <div class="line"> <span class="keywordflow">if</span> (evt.<a class="code" href="group__CMSIS__RTOS__Definitions.html#ad477a289f1f03ac45407b64268d707d3">status</a> == <a class="code" href="group__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99ea5df7e9643aa8a2f5f3a6f6ec59758518">osEventSignal</a>) {</div>
  351. <div class="line"> <span class="comment">// handle event status</span></div>
  352. <div class="line"> }</div>
  353. <div class="line"> }</div>
  354. <div class="line">}</div>
  355. </div><!-- fragment -->
  356. </div>
  357. </div>
  358. </div><!-- contents -->
  359. </div><!-- doc-content -->
  360. <!-- start footer part -->
  361. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  362. <ul>
  363. <li class="footer">Generated on Mon Mar 18 2019 16:06:29 for CMSIS-RTOS by Arm Ltd. All rights reserved.
  364. <!--
  365. <a href="http://www.doxygen.org/index.html">
  366. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
  367. -->
  368. </li>
  369. </ul>
  370. </div>
  371. </body>
  372. </html>