summaryrefslogtreecommitdiff
path: root/CMSIS/Documentation/RTOS/html/group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html
blob: 4adc7736e2affc6379daff39b1df6fb04219e86c (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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<!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>Kernel Information and Control</title>
<title>CMSIS-RTOS: Kernel Information and Control</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___kernel_ctrl.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">Kernel Information and Control</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>Provide version/system information and start the RTOS Kernel.  
<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:ga22f7d235bc9f783933bd5a981fd79696"><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___kernel_ctrl.html#ga22f7d235bc9f783933bd5a981fd79696">osFeature_MainThread</a>&#160;&#160;&#160;1</td></tr>
<tr class="memdesc:ga22f7d235bc9f783933bd5a981fd79696"><td class="mdescLeft">&#160;</td><td class="mdescRight">main thread 1=main can be thread, 0=not available  <a href="#ga22f7d235bc9f783933bd5a981fd79696"></a><br/></td></tr>
<tr class="separator:ga22f7d235bc9f783933bd5a981fd79696"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae554ec16c23c5b7d65affade2a351891"><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___kernel_ctrl.html#gae554ec16c23c5b7d65affade2a351891">osFeature_SysTick</a>&#160;&#160;&#160;1</td></tr>
<tr class="memdesc:gae554ec16c23c5b7d65affade2a351891"><td class="mdescLeft">&#160;</td><td class="mdescRight">osKernelSysTick functions: 1=available, 0=not available  <a href="#gae554ec16c23c5b7d65affade2a351891"></a><br/></td></tr>
<tr class="separator:gae554ec16c23c5b7d65affade2a351891"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga702196bacccbb978620c736b209387f1"><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___kernel_ctrl.html#ga702196bacccbb978620c736b209387f1">osCMSIS</a>&#160;&#160;&#160;0x10002</td></tr>
<tr class="memdesc:ga702196bacccbb978620c736b209387f1"><td class="mdescLeft">&#160;</td><td class="mdescRight">API version (main [31:16] .sub [15:0])  <a href="#ga702196bacccbb978620c736b209387f1"></a><br/></td></tr>
<tr class="separator:ga702196bacccbb978620c736b209387f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab78dce646fabec479c5f34bc5175b7de"><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___kernel_ctrl.html#gab78dce646fabec479c5f34bc5175b7de">osCMSIS_KERNEL</a>&#160;&#160;&#160;0x10000</td></tr>
<tr class="memdesc:gab78dce646fabec479c5f34bc5175b7de"><td class="mdescLeft">&#160;</td><td class="mdescRight">RTOS identification and version (main [31:16] .sub [15:0])  <a href="#gab78dce646fabec479c5f34bc5175b7de"></a><br/></td></tr>
<tr class="separator:gab78dce646fabec479c5f34bc5175b7de"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga47cf03658f01cdffca688e9096b58289"><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___kernel_ctrl.html#ga47cf03658f01cdffca688e9096b58289">osKernelSystemId</a>&#160;&#160;&#160;&quot;KERNEL V1.00&quot;</td></tr>
<tr class="memdesc:ga47cf03658f01cdffca688e9096b58289"><td class="mdescLeft">&#160;</td><td class="mdescRight">RTOS identification string.  <a href="#ga47cf03658f01cdffca688e9096b58289"></a><br/></td></tr>
<tr class="separator:ga47cf03658f01cdffca688e9096b58289"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9e0954d52722673e2031233a2ab99960"><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___kernel_ctrl.html#ga9e0954d52722673e2031233a2ab99960">osKernelSysTickFrequency</a>&#160;&#160;&#160;100000000</td></tr>
<tr class="memdesc:ga9e0954d52722673e2031233a2ab99960"><td class="mdescLeft">&#160;</td><td class="mdescRight">The RTOS kernel system timer frequency in Hz.  <a href="#ga9e0954d52722673e2031233a2ab99960"></a><br/></td></tr>
<tr class="separator:ga9e0954d52722673e2031233a2ab99960"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae12c190af42d7310d8006d64f4ed5a88"><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___kernel_ctrl.html#gae12c190af42d7310d8006d64f4ed5a88">osKernelSysTickMicroSec</a>(microsec)&#160;&#160;&#160;(((uint64_t)microsec * (<a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga9e0954d52722673e2031233a2ab99960">osKernelSysTickFrequency</a>)) / 1000000)</td></tr>
<tr class="memdesc:gae12c190af42d7310d8006d64f4ed5a88"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert a microseconds value to a RTOS kernel system timer value.  <a href="#gae12c190af42d7310d8006d64f4ed5a88"></a><br/></td></tr>
<tr class="separator:gae12c190af42d7310d8006d64f4ed5a88"><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:ga53d078a801022e202e8115c083ece68e"><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___kernel_ctrl.html#ga53d078a801022e202e8115c083ece68e">osKernelInitialize</a> (void)</td></tr>
<tr class="memdesc:ga53d078a801022e202e8115c083ece68e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the RTOS Kernel for creating objects.  <a href="#ga53d078a801022e202e8115c083ece68e"></a><br/></td></tr>
<tr class="separator:ga53d078a801022e202e8115c083ece68e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaab668ffd2ea76bb0a77ab0ab385eaef2"><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___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</a> (void)</td></tr>
<tr class="memdesc:gaab668ffd2ea76bb0a77ab0ab385eaef2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start the RTOS Kernel.  <a href="#gaab668ffd2ea76bb0a77ab0ab385eaef2"></a><br/></td></tr>
<tr class="separator:gaab668ffd2ea76bb0a77ab0ab385eaef2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3b571de44cd3094c643247a7397f86b5"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga3b571de44cd3094c643247a7397f86b5">osKernelRunning</a> (void)</td></tr>
<tr class="memdesc:ga3b571de44cd3094c643247a7397f86b5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check if the RTOS kernel is already started.  <a href="#ga3b571de44cd3094c643247a7397f86b5"></a><br/></td></tr>
<tr class="separator:ga3b571de44cd3094c643247a7397f86b5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad0262e4688e95d1e9038afd9bcc16001"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gad0262e4688e95d1e9038afd9bcc16001">osKernelSysTick</a> (void)</td></tr>
<tr class="memdesc:gad0262e4688e95d1e9038afd9bcc16001"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the RTOS kernel system timer counter.  <a href="#gad0262e4688e95d1e9038afd9bcc16001"></a><br/></td></tr>
<tr class="separator:gad0262e4688e95d1e9038afd9bcc16001"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<p>The Kernel Information and Control function group allows to:</p>
<ul>
<li>obtain information about the system and the underlying kernel.</li>
<li>obtain version information about the CMSIS-RTOS API.</li>
<li>initialize of the RTOS kernel for creating objects.</li>
<li>start the RTOS kernel and thread switching.</li>
<li>check the execution status of the RTOS kernel.</li>
</ul>
<p>The function <b>main</b> is a special thread function that may be started at system initialization. In this case it has the initial priority <em>osPriorityNormal</em>.</p>
<p>When reaching <b>main</b>, it is necessary to:</p>
<ol type="1">
<li>Call <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga53d078a801022e202e8115c083ece68e" title="Initialize the RTOS Kernel for creating objects.">osKernelInitialize()</a> to initialize the CMSIS-RTOS Kernel</li>
<li>Setup device peripherals and create other RTOS objects using the <b>os*Create</b> functions.</li>
<li>Start the Kernel and begin thread switching by calling <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2" title="Start the RTOS Kernel.">osKernelStart()</a>.</li>
</ol>
<p><b>Code Example</b> </p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>) {</div>
<div class="line">  <a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga53d078a801022e202e8115c083ece68e" title="Initialize the RTOS Kernel for creating objects.">osKernelInitialize</a> ();                    <span class="comment">// initialize CMSIS-RTOS</span></div>
<div class="line"> </div>
<div class="line">  <span class="comment">// initialize peripherals here</span></div>
<div class="line"> </div>
<div class="line">  <span class="comment">// create &#39;thread&#39; functions that start executing,</span></div>
<div class="line">  <span class="comment">// example: tid_name = osThreadCreate (osThread(name), NULL);</span></div>
<div class="line"> </div>
<div class="line">  <a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2" title="Start the RTOS Kernel.">osKernelStart</a> ();                         <span class="comment">// start thread execution </span></div>
<div class="line">}</div>
</div><!-- fragment --> <h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="ga702196bacccbb978620c736b209387f1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osCMSIS&#160;&#160;&#160;0x10002</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Version information of the CMSIS-RTOS API whereby major version is in bits [31:16] and sub version in bits [15:0]. The value 0x10000 represents version 1.00.</p>
<dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osCMSIS</b> identifies the CMSIS-RTOS API version. </dd></dl>

</div>
</div>
<a class="anchor" id="gab78dce646fabec479c5f34bc5175b7de"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osCMSIS_KERNEL&#160;&#160;&#160;0x10000</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Identifies the underlying RTOS kernel and version number. The actual name of that define depends on the RTOS Kernel used in the implementation. For example, <b>osCMSIS_FreeRTOS</b> identifies the FreeRTOS kernel and the value indicates the version number of that kernel whereby the major version is in bits [31:16] and sub version in bits [15:0]. The value 0x10000 represents version 1.00.</p>
<dl class="section note"><dt>Note</dt><dd>CAN BE CHANGED: <b>osCMSIS_KERNEL</b> identifies the underlying RTOS kernel and version number. </dd></dl>

</div>
</div>
<a class="anchor" id="ga22f7d235bc9f783933bd5a981fd79696"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osFeature_MainThread&#160;&#160;&#160;1</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>A CMSIS-RTOS implementation may support to start thread execution with the function 'main'.</p>
<ul>
<li>When <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga22f7d235bc9f783933bd5a981fd79696">osFeature_MainThread</a> is 1 the RTOS offers to start with 'main'. The RTOS kernel is in this case already started.</li>
<li>When <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga22f7d235bc9f783933bd5a981fd79696">osFeature_MainThread</a> is 0 the RTOS requires explicit start with <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</a>.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osFeature_xxx</b> shall be consistent in every CMSIS-RTOS. </dd></dl>

</div>
</div>
<a class="anchor" id="gae554ec16c23c5b7d65affade2a351891"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osFeature_SysTick&#160;&#160;&#160;1</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>A CMSIS-RTOS implementation may provide access to the RTOS kernel system timer.</p>
<ul>
<li>When <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gae554ec16c23c5b7d65affade2a351891">osFeature_SysTick</a> is 1 access to the RTOS kernel system timer is provided with <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gad0262e4688e95d1e9038afd9bcc16001">osKernelSysTick</a>, <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga9e0954d52722673e2031233a2ab99960">osKernelSysTickFrequency</a>, and <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gae12c190af42d7310d8006d64f4ed5a88">osKernelSysTickMicroSec</a>.</li>
<li>When <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gae554ec16c23c5b7d65affade2a351891">osFeature_SysTick</a> is 0 access to the RTOS kernel system timer is not implemented. </li>
</ul>

</div>
</div>
<a class="anchor" id="ga47cf03658f01cdffca688e9096b58289"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osKernelSystemId&#160;&#160;&#160;&quot;KERNEL V1.00&quot;</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Defines a string that identifies the underlying RTOS Kernel and provides version information. The length of that string is limited to 21 bytes. A valid identification string is for example, <b>"FreeRTOS V1.00"</b>.</p>
<dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osKernelSystemId</b> shall be consistent in every CMSIS-RTOS. </dd></dl>

</div>
</div>
<a class="anchor" id="ga9e0954d52722673e2031233a2ab99960"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osKernelSysTickFrequency&#160;&#160;&#160;100000000</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Specifies the frequency of the Kernel SysTick timer in Hz. The value is typically use to scale a time value and is for example used in <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gae12c190af42d7310d8006d64f4ed5a88">osKernelSysTickMicroSec</a>.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gad0262e4688e95d1e9038afd9bcc16001" title="Get the RTOS kernel system timer counter.">osKernelSysTick</a></dd></dl>
<dl class="section note"><dt>Note</dt><dd>Reflects the system timer setting and is typically defined in a configuration file. </dd></dl>

</div>
</div>
<a class="anchor" id="gae12c190af42d7310d8006d64f4ed5a88"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define osKernelSysTickMicroSec</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">microsec</td><td>)</td>
          <td>&#160;&#160;&#160;(((uint64_t)microsec * (<a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga9e0954d52722673e2031233a2ab99960">osKernelSysTickFrequency</a>)) / 1000000)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Allows you to scale a microsecond value to the frequency of the Kernel SysTick timer. This macro is typically used to check for short timeouts in polling loops.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gad0262e4688e95d1e9038afd9bcc16001" title="Get the RTOS kernel system timer counter.">osKernelSysTick</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">microsec</td><td>time value in microseconds. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>time value normalized to the <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga9e0954d52722673e2031233a2ab99960">osKernelSysTickFrequency</a> </dd></dl>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga53d078a801022e202e8115c083ece68e"></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> osKernelInitialize </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osKernelInitialize</b> shall be consistent in every CMSIS-RTOS.</dd></dl>
<p>Initialize of the RTOS Kernel to allow peripheral setup and creation of other RTOS objects with the functions:</p>
<ul>
<li><a class="el" href="group___c_m_s_i_s___r_t_o_s___thread_mgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> : Create a thread function.</li>
<li><a class="el" href="group___c_m_s_i_s___r_t_o_s___timer_mgmt.html#gaedd312bfdca04e0b8162b666e09a1ae6">osTimerCreate</a> : Define attributes of the timer callback function.</li>
<li><a class="el" href="group___c_m_s_i_s___r_t_o_s___mutex_mgmt.html#ga5c9de56e717016e39e788064e9a291cc">osMutexCreate</a> : Define and initialize a mutex.</li>
<li><a class="el" href="group___c_m_s_i_s___r_t_o_s___semaphore_mgmt.html#ga97381e8e55cd47cec390bf57c96d6edb">osSemaphoreCreate</a> : Define and initialize a semaphore.</li>
<li><a class="el" href="group___c_m_s_i_s___r_t_o_s___pool_mgmt.html#ga34af5c4f4ab38f4138ea7f1f9ece3a1a">osPoolCreate</a> : Define and initialize a fix-size memory pool.</li>
<li><a class="el" href="group___c_m_s_i_s___r_t_o_s___message.html#gaf3b9345cf426304d46565152bc26fb78">osMessageCreate</a> : Define and initialize a message queue.</li>
<li><a class="el" href="group___c_m_s_i_s___r_t_o_s___mail.html#gaa177e7fe5820dd70d8c9e46ded131174">osMailCreate</a> : Define and initialize a mail queue with fix-size memory blocks.</li>
</ul>
<p>The RTOS kernel does not start thread switching until the function <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</a> is called.</p>
<dl class="section note"><dt>Note</dt><dd>In case that the RTOS Kernel starts thread execution with the function <em>main</em> the function osKernelInitialize stops thread switching. This allows you to setup the system to a defined state before thread switching is resumed with <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</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">int</span> main (<span class="keywordtype">void</span>)  {</div>
<div class="line">  <span class="keywordflow">if</span> (!<a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga3b571de44cd3094c643247a7397f86b5" title="Check if the RTOS kernel is already started.">osKernelRunning</a> ())  {                    <span class="comment">// if kernel is not running, initialize the kernel</span></div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga53d078a801022e202e8115c083ece68e" title="Initialize the RTOS Kernel for creating objects.">osKernelInitialize</a> () != <a class="code" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99ea9e1c9e2550bb4de8969a935acffc968f" title="function completed; no error or event occurred.">osOK</a>)  {        <span class="comment">// check osStatus for other possible valid values</span></div>
<div class="line">      <span class="comment">// exit with an error message</span></div>
<div class="line">    }</div>
<div class="line">  }</div>
<div class="line">  :</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga3b571de44cd3094c643247a7397f86b5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t osKernelRunning </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osKernelRunning</b> shall be consistent in every CMSIS-RTOS. </dd></dl>
<dl class="section return"><dt>Returns</dt><dd>0 RTOS is not started, 1 RTOS is started.</dd></dl>
<p>Identifies if the RTOS kernel is started. For systems with the option to start the <em>main</em> function as a thread this allows you to identify that the RTOS kernel is already running.</p>
<dl class="section note"><dt>Note</dt><dd><a class="el" href="_function_overview.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a> can call this function.</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">int</span> main (<span class="keywordtype">void</span>) {                                <span class="comment">// program execution starts here</span></div>
<div class="line">  <span class="keywordflow">if</span> (<a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga3b571de44cd3094c643247a7397f86b5" title="Check if the RTOS kernel is already started.">osKernelRunning</a> ())  {                    </div>
<div class="line">    :                                            <span class="comment">// main is already a thread function</span></div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="gaab668ffd2ea76bb0a77ab0ab385eaef2"></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> osKernelStart </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osKernelStart</b> shall be consistent in every CMSIS-RTOS.</dd></dl>
<p>Start the RTOS Kernel and begin thread switching.</p>
<dl class="section note"><dt>Note</dt><dd>When the CMSIS-RTOS starts thread execution with the function <em>main</em> this function resumes thread switching. The <em>main</em> thread will continue executing after <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</a>.</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>osOK:</em> the RTOS kernel has been successfully started.</li>
<li><em>osErrorISR:</em> <a class="el" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</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">int</span> main (<span class="keywordtype">void</span>)  {</div>
<div class="line">  <span class="keywordflow">if</span> (<a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga53d078a801022e202e8115c083ece68e" title="Initialize the RTOS Kernel for creating objects.">osKernelInitialize</a> () != <a class="code" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99ea9e1c9e2550bb4de8969a935acffc968f" title="function completed; no error or event occurred.">osOK</a>)  {          <span class="comment">// check osStatus for other possible valid values</span></div>
<div class="line">    <span class="comment">// exit with an error message</span></div>
<div class="line">  }</div>
<div class="line"> </div>
<div class="line">  <span class="keywordflow">if</span> (!<a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#ga3b571de44cd3094c643247a7397f86b5" title="Check if the RTOS kernel is already started.">osKernelRunning</a> ())  {                    <span class="comment">// is the kernel running ?</span></div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2" title="Start the RTOS Kernel.">osKernelStart</a> () != <a class="code" href="group___c_m_s_i_s___r_t_o_s___status.html#gae2e091fefc4c767117727bd5aba4d99ea9e1c9e2550bb4de8969a935acffc968f" title="function completed; no error or event occurred.">osOK</a>)  {             <span class="comment">// start the kernel</span></div>
<div class="line">                                                 <span class="comment">// kernel could not be started</span></div>
<div class="line">    }</div>
<div class="line">  }</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="gad0262e4688e95d1e9038afd9bcc16001"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t osKernelSysTick </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osKernelSysTick</b> shall be consistent in every CMSIS-RTOS. </dd></dl>
<dl class="section return"><dt>Returns</dt><dd>RTOS kernel system timer as 32-bit value</dd></dl>
<p>Get the value of the Kernel SysTick timer for time comparison. The value is a rolling 32-bit counter that is typically composed of the kernel system interrupt timer value and an counter that counts these interrupts.</p>
<p>This function allows the implementation of timeout checks. These are for example required when checking for a busy status in a device or peripheral initialization routine.</p>
<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> SetupDevice (<span class="keywordtype">void</span>)  {</div>
<div class="line">  uint32_t tick;</div>
<div class="line">  </div>
<div class="line">  tick = <a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gad0262e4688e95d1e9038afd9bcc16001" title="Get the RTOS kernel system timer counter.">osKernelSysTick</a>();                      <span class="comment">// get start value of the Kernel system tick</span></div>
<div class="line">  Device.Setup ();                               <span class="comment">// initialize a device or peripheral</span></div>
<div class="line">  <span class="keywordflow">do</span> {                                           <span class="comment">// poll device busy status for 100 microseconds</span></div>
<div class="line">    <span class="keywordflow">if</span> (!Device.Busy) <span class="keywordflow">break</span>;                     <span class="comment">// check if device is correctly initialized</span></div>
<div class="line">  } <span class="keywordflow">while</span> ((<a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gad0262e4688e95d1e9038afd9bcc16001" title="Get the RTOS kernel system timer counter.">osKernelSysTick</a>() - tick) &lt; <a class="code" href="group___c_m_s_i_s___r_t_o_s___kernel_ctrl.html#gae12c190af42d7310d8006d64f4ed5a88" title="Convert a microseconds value to a RTOS kernel system timer value.">osKernelSysTickMicroSec</a>(100));  </div>
<div class="line">  <span class="keywordflow">if</span> (Device.Busy)  {              </div>
<div class="line">    ;                                            <span class="comment">// in case device still busy, signal error</span></div>
<div class="line">  }</div>
<div class="line">                                                 <span class="comment">// start interacting with device</span></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>