diff options
Diffstat (limited to 'docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html')
-rw-r--r-- | docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html | 179 |
1 files changed, 83 insertions, 96 deletions
diff --git a/docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html b/docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html index 9d7271b..cfc501e 100644 --- a/docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html +++ b/docs/RTOS2/html/group__CMSIS__RTOS__EventFlags.html @@ -174,50 +174,62 @@ Refer to <a class="el" href="config_rtx5.html#eventFlagsConfig">Event Flags Conf Simple event communication</div></div> <p> The following steps are required to use event flags:</p> <ol type="1"> -<li>In the thread that is supposed to send a event with id sig1_id, call the set function: <div class="fragment"><div class="line"><a class="code" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a> (1000); <span class="comment">// wait for 1 second</span></div> -<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga33b71d14cecf90b4e72639dd19f23a5e">osEventFlagsSet</a> (sig1_id, 0x0001U); <span class="comment">// set the flag 0x0001U for event sig1_id</span></div> +<li>In the thread that is supposed to send a event with id sig1_id, call the set function: <div class="fragment"><div class="line"><a class="code" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(1000U); <span class="comment">// wait for 1 second</span></div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga33b71d14cecf90b4e72639dd19f23a5e">osEventFlagsSet</a>(sig1_id, 0x0001U); <span class="comment">// set the flag 0x0001U for event sig1_id</span></div> </div><!-- fragment --></li> -<li>In another thread (or threads) that are supposed to wait for the event, call the wait function: <div class="fragment"><div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a> (sig1_id, 0x0001U, NULL, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>); <span class="comment">// wait forever for any flag</span></div> +<li>In another thread (or threads) that are supposed to wait for the event, call the wait function: <div class="fragment"><div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a>(sig1_id, 0x0001U, NULL, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>); <span class="comment">// wait forever for any flag</span></div> </div><!-- fragment --></li> </ol> <p>The following complete example code can be directly used with the "CMSIS-RTOS2 main template" and is also provided as a stand-alone template for RTX5:</p> <p><b>Code Example</b> </p> -<div class="fragment"><div class="line"><span class="keywordtype">void</span> Thread_EventSender (<span class="keywordtype">void</span> *argument); <span class="comment">// thread function 1</span></div> -<div class="line"><span class="keywordtype">void</span> Thread_EventReceiver (<span class="keywordtype">void</span> *argument); <span class="comment">// thread function 2</span></div> -<div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> tid_Thread_EventSender; <span class="comment">// thread id 1</span></div> -<div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> tid_Thread_EventReceiver; <span class="comment">// thread id 2</span></div> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span> <span class="comment">// CMSIS RTOS header file</span></div> <div class="line"> </div> -<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// message queue id</span></div> +<div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div> +<div class="line"><span class="comment"> * Event Flags creation & usage</span></div> +<div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div> <div class="line"> </div> -<div class="line"><span class="preprocessor">#define FLAGS_MSK1 0x00000001ul</span></div> +<div class="line"><span class="preprocessor">#define FLAGS_MSK1 0x00000001U</span></div> <div class="line"><span class="preprocessor"></span> </div> -<div class="line"><span class="keywordtype">void</span> app_main (<span class="keywordtype">void</span>)</div> -<div class="line">{</div> -<div class="line"> tid_Thread_EventSender = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> (Thread_EventSender, NULL, NULL);</div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// event flags id</span></div> +<div class="line"> </div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> tid_Thread_EventSender; <span class="comment">// thread id 1</span></div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> tid_Thread_EventReceiver; <span class="comment">// thread id 2</span></div> +<div class="line"> </div> +<div class="line"><span class="keywordtype">void</span> Thread_EventSender (<span class="keywordtype">void</span> *argument); <span class="comment">// thread function 1</span></div> +<div class="line"><span class="keywordtype">void</span> Thread_EventReceiver (<span class="keywordtype">void</span> *argument); <span class="comment">// thread function 2</span></div> +<div class="line"> </div> +<div class="line"><span class="keywordtype">int</span> Init_Events (<span class="keywordtype">void</span>) {</div> +<div class="line"> </div> +<div class="line"> evt_id = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#gab14b1caeb12ffa42cce1bfe889cd07df">osEventFlagsNew</a>(NULL);</div> +<div class="line"> <span class="keywordflow">if</span> (evt_id == NULL) {</div> +<div class="line"> ; <span class="comment">// Event Flags object not created, handle failure</span></div> +<div class="line"> }</div> +<div class="line"> </div> +<div class="line"> tid_Thread_EventSender = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(Thread_EventSender, NULL, NULL);</div> <div class="line"> <span class="keywordflow">if</span> (tid_Thread_EventSender == NULL) {</div> -<div class="line"> ; <span class="comment">// do something</span></div> +<div class="line"> <span class="keywordflow">return</span>(-1);</div> <div class="line"> }</div> -<div class="line"> tid_Thread_EventReceiver = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> (Thread_EventReceiver, NULL, NULL);</div> +<div class="line"> tid_Thread_EventReceiver = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(Thread_EventReceiver, NULL, NULL);</div> <div class="line"> <span class="keywordflow">if</span> (tid_Thread_EventReceiver == NULL) {</div> -<div class="line"> ; <span class="comment">// do something</span></div> +<div class="line"> <span class="keywordflow">return</span>(-1);</div> <div class="line"> }</div> -<div class="line"> ; <span class="comment">// do something</span></div> +<div class="line"></div> +<div class="line"> <span class="keywordflow">return</span>(0);</div> <div class="line">}</div> <div class="line"> </div> -<div class="line"><span class="keywordtype">void</span> Thread_EventSender (<span class="keywordtype">void</span> *argument)</div> -<div class="line">{</div> -<div class="line"> evt_id = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#gab14b1caeb12ffa42cce1bfe889cd07df">osEventFlagsNew</a>(NULL);</div> +<div class="line"><span class="keywordtype">void</span> Thread_EventSender (<span class="keywordtype">void</span> *argument) {</div> +<div class="line"> </div> <div class="line"> <span class="keywordflow">while</span> (1) { </div> <div class="line"> <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga33b71d14cecf90b4e72639dd19f23a5e">osEventFlagsSet</a>(evt_id, FLAGS_MSK1);</div> -<div class="line"> <a class="code" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a> (1000); <span class="comment">// suspend thread</span></div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a>(); <span class="comment">// suspend thread</span></div> <div class="line"> }</div> <div class="line">}</div> <div class="line"> </div> -<div class="line"><span class="keywordtype">void</span> Thread_EventReceiver (<span class="keywordtype">void</span> *argument)</div> -<div class="line">{</div> +<div class="line"><span class="keywordtype">void</span> Thread_EventReceiver (<span class="keywordtype">void</span> *argument) {</div> <div class="line"> uint32_t flags;</div> +<div class="line"> </div> <div class="line"> <span class="keywordflow">while</span> (1) {</div> -<div class="line"> flags = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a> (evt_id,FLAGS_MSK1,<a class="code" href="group__CMSIS__RTOS__Definitions.html#ga18e63587b8450d5b8798b6f6ec04e012">osFlagsWaitAny</a>, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>);</div> +<div class="line"> flags = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a>(evt_id, FLAGS_MSK1, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga18e63587b8450d5b8798b6f6ec04e012">osFlagsWaitAny</a>, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>);</div> <div class="line"> <span class="comment">//handle event</span></div> <div class="line"> }</div> <div class="line">}</div> @@ -244,31 +256,31 @@ Simple event communication</div></div> <td class="fieldname"> name</td> <td class="fielddoc"> -name of the event flags <p>Pointer to a string with a human readable name of the event object.<br/> -Default: <span class="XML-Token">NULL</span>. </p> +name of the event flags <p>Pointer to a constant string with a human readable name (displayed during debugging) of the event flag 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 (set to '0').<br/> -Default: <span class="XML-Token">0</span>. </p> +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 location for the event control block object. This can optionally be used for custom memory management systems.<br/> -Default: <span class="XML-Token">NULL</span> (uses kernel memory management). </p> +memory for control block <p>Pointer to a memory for the event flag 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 event flag 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 of the memory block passed with <a class="el" href="group__CMSIS__RTOS__EventFlags.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. Must be the size of an event control block object or larger. </p> +size of provided memory for control block <p>The size (in bytes) of memory block passed with <a class="el" href="group__CMSIS__RTOS__EventFlags.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. For RTX, the minimum value is defined with <a class="el" href="group__rtx5__specific__defines.html#ga68100c8c44931f03547973294c433075">osRtxEventFlagsCbSize</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__EventFlags.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. </p> </td></tr> </table> @@ -317,27 +329,19 @@ size of provided memory for control block <p>The size of the memory block passed <p>The parameter <em>attr</em> sets the event flags attributes (refer to <a class="el" href="group__CMSIS__RTOS__EventFlags.html#structosEventFlagsAttr__t">osEventFlagsAttr_t</a>). Default attributes will be used if set to <span class="XML-Token">NULL</span>, i.e. kernel memory allocation is used for the event control block.</p> <dl class="section note"><dt>Note</dt><dd>Cannot 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> <span class="comment">// CMSIS RTOS header file</span></div> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span> <span class="comment">// CMSIS RTOS header file</span></div> <div class="line"> </div> -<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// message queue id</span></div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// message queue id</span></div> <div class="line"> </div> -<div class="line"><span class="keywordtype">void</span> Thread_EventSender (<span class="keywordtype">void</span> *argument)</div> -<div class="line">{</div> -<div class="line"> evt_id = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#gab14b1caeb12ffa42cce1bfe889cd07df">osEventFlagsNew</a>(NULL);</div> -<div class="line"> <span class="keywordflow">while</span> (1) { </div> -<div class="line"> <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga33b71d14cecf90b4e72639dd19f23a5e">osEventFlagsSet</a>(evt_id, FLAGS_MSK1);</div> -<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a> (); <span class="comment">// suspend thread</span></div> -<div class="line"> }</div> -<div class="line">}</div> +<div class="line"><span class="keywordtype">int</span> Init_Events (<span class="keywordtype">void</span>) {</div> <div class="line"> </div> -<div class="line"><span class="keywordtype">void</span> Thread_EventReceiver (<span class="keywordtype">void</span> *argument)</div> -<div class="line">{</div> -<div class="line"> uint32_t flags;</div> -<div class="line"> </div> -<div class="line"> <span class="keywordflow">while</span> (1) {</div> -<div class="line"> flags = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a> (evt_id,FLAGS_MSK1,<a class="code" href="group__CMSIS__RTOS__Definitions.html#ga18e63587b8450d5b8798b6f6ec04e012">osFlagsWaitAny</a>, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>);</div> -<div class="line"> <span class="comment">//handle event</span></div> +<div class="line"> evt_id = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#gab14b1caeb12ffa42cce1bfe889cd07df">osEventFlagsNew</a>(NULL);</div> +<div class="line"> <span class="keywordflow">if</span> (evt_id == NULL) {</div> +<div class="line"> ; <span class="comment">// Event Flags object not created, handle failure</span></div> +<div class="line"> <span class="keywordflow">return</span>(-1);</div> <div class="line"> }</div> +<div class="line"></div> +<div class="line"> <span class="keywordflow">return</span>(0);</div> <div class="line">}</div> </div><!-- fragment --> </div> @@ -376,32 +380,21 @@ size of provided memory for control block <p>The size of the memory block passed <p>The function <b>osEventFlagsSet</b> sets the event flags specified by the parameter <em>flags</em> in an event flags object specified by parameter <em>ef_id</em>. All threads waiting for the flag set will be notified to resume from <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state. The function returns the event flags after setting or an error code (highest bit is set, refer to <a class="el" href="group__flags__error__codes.html">Flags Functions Error Codes</a>).</p> <p>Possible <a class="el" href="group__flags__error__codes.html">Flags Functions Error Codes</a> return values:</p> <ul> -<li><em>osFlagsErrorUnknown:</em> Unspecified error.</li> -<li><em>osFlagsErrorResource:</em> Event flags object specified by parameter <em>ef_id</em> is not ready to be used.</li> -<li><em>osFlagsErrorParameter:</em> Parameter <em>ef_id</em> does not identify a valid event flags object or <em>flags</em> has highest bit set.</li> +<li><em>osFlagsErrorUnknown:</em> unspecified error.</li> +<li><em>osFlagsErrorParameter:</em> parameter <em>ef_id</em> does not identify a valid event flags object or <em>flags</em> has highest bit set.</li> +<li><em>osFlagsErrorResource:</em> the event flags object is in an invalid state.</li> </ul> <dl class="section note"><dt>Note</dt><dd>This function may 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> <span class="comment">// CMSIS RTOS header file</span></div> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span> <span class="comment">// CMSIS RTOS header file</span></div> <div class="line"> </div> -<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// message queue id</span></div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// event flasg id</span></div> <div class="line"> </div> -<div class="line"><span class="keywordtype">void</span> Thread_EventSender (<span class="keywordtype">void</span> *argument)</div> -<div class="line">{</div> -<div class="line"> evt_id = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#gab14b1caeb12ffa42cce1bfe889cd07df">osEventFlagsNew</a>(NULL);</div> -<div class="line"> <span class="keywordflow">while</span> (1) { </div> -<div class="line"> <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga33b71d14cecf90b4e72639dd19f23a5e">osEventFlagsSet</a>(evt_id, FLAGS_MSK1);</div> -<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a> (); <span class="comment">// suspend thread</span></div> -<div class="line"> }</div> -<div class="line">}</div> +<div class="line"><span class="keywordtype">void</span> Thread_EventSender (<span class="keywordtype">void</span> *argument) {</div> <div class="line"> </div> -<div class="line"><span class="keywordtype">void</span> Thread_EventReceiver (<span class="keywordtype">void</span> *argument)</div> -<div class="line">{</div> -<div class="line"> uint32_t flags;</div> -<div class="line"> </div> -<div class="line"> <span class="keywordflow">while</span> (1) {</div> -<div class="line"> flags = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a> (evt_id,FLAGS_MSK1,<a class="code" href="group__CMSIS__RTOS__Definitions.html#ga18e63587b8450d5b8798b6f6ec04e012">osFlagsWaitAny</a>, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>);</div> -<div class="line"> <span class="comment">//handle event</span></div> +<div class="line"> <span class="keywordflow">while</span> (1) { </div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga33b71d14cecf90b4e72639dd19f23a5e">osEventFlagsSet</a>(evt_id, 0x00000001U);</div> +<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a>(); <span class="comment">// suspend thread</span></div> <div class="line"> }</div> <div class="line">}</div> </div><!-- fragment --> @@ -441,9 +434,9 @@ size of provided memory for control block <p>The size of the memory block passed <p>The function <b>osEventFlagsClear</b> clears the event flags specified by the parameter <em>flags</em> in an event flags object specified by parameter <em>ef_id</em>. The function returns the event flags before clearing or an error code (highest bit is set, refer to <a class="el" href="group__flags__error__codes.html">Flags Functions Error Codes</a>).</p> <p>Possible <a class="el" href="group__flags__error__codes.html">Flags Functions Error Codes</a> return values:</p> <ul> -<li><em>osFlagsErrorUnknown:</em> Unspecified error.</li> -<li><em>osFlagsErrorResource:</em> Event flags object specified by parameter <em>ef_id</em> is not ready to be used.</li> -<li><em>osFlagsErrorParameter:</em> Parameter <em>ef_id</em> does not identify a valid event flags object or <em>flags</em> has highest bit set.</li> +<li><em>osFlagsErrorUnknown:</em> unspecified error.</li> +<li><em>osFlagsErrorParameter:</em> parameter <em>ef_id</em> does not identify a valid event flags object or <em>flags</em> has highest bit set.</li> +<li><em>osFlagsErrorResource:</em> the event flags object is in an invalid state.</li> </ul> <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl> @@ -541,32 +534,22 @@ size of provided memory for control block <p>The size of the memory block passed <p>The function returns the event flags before clearing or an error code (highest bit is set, refer to <a class="el" href="group__flags__error__codes.html">Flags Functions Error Codes</a>).</p> <p>Possible <a class="el" href="group__flags__error__codes.html">Flags Functions Error Codes</a> return values:</p> <ul> -<li><em>osFlagsErrorUnknown:</em> Unspecified error.</li> -<li><em>osFlagsErrorTimeout:</em> The awaited flags has not been set during given timeout.</li> -<li><em>osFlagsErrorResource:</em> Event flags object specified by parameter <em>ef_id</em> is not ready to be used.</li> -<li><em>osFlagsErrorParameter:</em> Parameter <em>ef_id</em> does not identify a valid event flags object or <em>flags</em> has highest bit set.</li> +<li><em>osFlagsErrorUnknown:</em> unspecified error.</li> +<li><em>osFlagsErrorTimeout:</em> awaited flags have not been set in the given time.</li> +<li><em>osFlagsErrorResource:</em> awaited flags have not been set when no <em>timeout</em> was specified.</li> +<li><em>osFlagsErrorParameter:</em> parameter <em>ef_id</em> does not identify a valid event flags object or <em>flags</em> has highest bit set.</li> </ul> <dl class="section note"><dt>Note</dt><dd>May be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a> if the parameter <em>timeout</em> is set to <span class="XML-Token">0</span>.</dd></dl> <p><b>Code</b> <b>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> <span class="comment">// CMSIS RTOS header file</span></div> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span> <span class="comment">// CMSIS RTOS header file</span></div> <div class="line"> </div> -<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// message queue id</span></div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// event flasg id</span></div> <div class="line"> </div> -<div class="line"><span class="keywordtype">void</span> Thread_EventSender (<span class="keywordtype">void</span> *argument)</div> -<div class="line">{</div> -<div class="line"> evt_id = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#gab14b1caeb12ffa42cce1bfe889cd07df">osEventFlagsNew</a>(NULL);</div> -<div class="line"> <span class="keywordflow">while</span> (1) { </div> -<div class="line"> <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga33b71d14cecf90b4e72639dd19f23a5e">osEventFlagsSet</a>(evt_id, FLAGS_MSK1);</div> -<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a> (); <span class="comment">// suspend thread</span></div> -<div class="line"> }</div> -<div class="line">}</div> -<div class="line"> </div> -<div class="line"><span class="keywordtype">void</span> Thread_EventReceiver (<span class="keywordtype">void</span> *argument)</div> -<div class="line">{</div> -<div class="line"> uint32_t flags;</div> +<div class="line"><span class="keywordtype">void</span> Thread_EventReceiver (<span class="keywordtype">void</span> *argument) {</div> +<div class="line"> uint32_t flags;</div> <div class="line"> </div> <div class="line"> <span class="keywordflow">while</span> (1) {</div> -<div class="line"> flags = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a> (evt_id,FLAGS_MSK1,<a class="code" href="group__CMSIS__RTOS__Definitions.html#ga18e63587b8450d5b8798b6f6ec04e012">osFlagsWaitAny</a>, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>);</div> +<div class="line"> flags = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a>(evt_id, 0x00000001U, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga18e63587b8450d5b8798b6f6ec04e012">osFlagsWaitAny</a>, <a class="code" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>);</div> <div class="line"> <span class="comment">//handle event</span></div> <div class="line"> }</div> <div class="line">}</div> @@ -598,8 +581,8 @@ size of provided memory for control block <p>The size of the memory block passed <ul> <li><em>osOK:</em> the specified event flags object has been deleted.</li> <li><em>osErrorISR:</em> <b>osEventFlagsDelete</b> cannot be called from interrupt service routines.</li> -<li><em>osErrorParameter:</em> the value of the parameter <em>ef_id</em> is incorrect.</li> -<li><em>osErrorResource:</em> parameter <em>ef_id</em> is <span class="XML-Token">NULL</span> or wrong.</li> +<li><em>osErrorParameter:</em> parameter <em>ef_id</em> is <span class="XML-Token">NULL</span> or invalid.</li> +<li><em>osErrorResource:</em> the event flags object is in an invalid 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> @@ -628,11 +611,15 @@ size of provided memory for control block <p>The size of the memory block passed <p>The function <b>osEventFlagsGetName</b> returns the pointer to the name string of the event flags object identified by parameter <em>ef_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> <p><b>Code Example</b> </p> -<div class="fragment"><div class="line"><span class="keywordtype">void</span> EvtFlagsGetName_example (<span class="keywordtype">void</span>) {</div> -<div class="line"> <span class="keywordtype">char</span> id; <span class="comment">// id of the event flags object</span></div> +<div class="fragment"><div class="line"><span class="preprocessor">#include "<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>"</span> <span class="comment">// CMSIS RTOS header file</span></div> +<div class="line"> </div> +<div class="line"><a class="code" href="group__CMSIS__RTOS__EventFlags.html#gafdbab933146d6d81d7cca7287e267a50">osEventFlagsId_t</a> evt_id; <span class="comment">// event flasg id</span></div> +<div class="line"> </div> +<div class="line"><span class="keywordtype">void</span> EvtFlagsGetName_example (<span class="keywordtype">void</span>) {</div> +<div class="line"> <span class="keywordtype">char</span> *name;</div> <div class="line"> </div> -<div class="line"> <span class="keywordtype">id</span> = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga59f4ddf0ee8c395b1672bb978d1cfc88">osEventFlagsGetName</a> ();</div> -<div class="line"> <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == NULL) {</div> +<div class="line"> name = <a class="code" href="group__CMSIS__RTOS__EventFlags.html#ga59f4ddf0ee8c395b1672bb978d1cfc88">osEventFlagsGetName</a>(evt_id);</div> +<div class="line"> <span class="keywordflow">if</span> (name == NULL) {</div> <div class="line"> <span class="comment">// Failed to get the event flags object name</span></div> <div class="line"> }</div> <div class="line">}</div> @@ -644,7 +631,7 @@ size of provided memory for control block <p>The size of the memory block passed <!-- 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. + <li class="footer">Generated on Wed Jul 10 2019 15:21:04 for CMSIS-RTOS2 Version 2.1.3 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 |