blob: 660b0aa4ac5e5cc2077b8c597fa42168ea6ce4c4 [file] [log] [blame]
<!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);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
</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.03</span>
</div>
<div id="projectbrief">Real-Time Operating System: API and RTX Reference Implementation.</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.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<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>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</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__CMSIS__RTOS__KernelCtrl.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<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>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<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 class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS API</a></div></div> </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__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.html#gae12c190af42d7310d8006d64f4ed5a88">osKernelSysTickMicroSec</a>(microsec)&#160;&#160;&#160;(((uint64_t)microsec * (<a class="el" href="group__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99e">osStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99e">osStatus</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.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">More...</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__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__KernelCtrl.html#ga53d078a801022e202e8115c083ece68e">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__CMSIS__RTOS__KernelCtrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">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__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__KernelCtrl.html#ga22f7d235bc9f783933bd5a981fd79696">osFeature_MainThread</a> is 0 the RTOS requires explicit start with <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</a>.</li>
</ul>
<p><a class="el" href="rtxImplementation.html">CMSIS-RTOS RTX</a> Setting: <b>osFeature_MainThread</b> is 1</p>
<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__CMSIS__RTOS__KernelCtrl.html#gae554ec16c23c5b7d65affade2a351891">osFeature_SysTick</a> is 1 access to the RTOS kernel system timer is provided with <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gad0262e4688e95d1e9038afd9bcc16001">osKernelSysTick</a>, <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga9e0954d52722673e2031233a2ab99960">osKernelSysTickFrequency</a>, and <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae12c190af42d7310d8006d64f4ed5a88">osKernelSysTickMicroSec</a>.</li>
<li>When <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae554ec16c23c5b7d65affade2a351891">osFeature_SysTick</a> is 0 access to the RTOS kernel system timer is not implemented.</li>
</ul>
<p><a class="el" href="rtxImplementation.html">CMSIS-RTOS RTX</a> Setting: <b>osFeature_SysTick</b> is 1 </p>
</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__CMSIS__RTOS__KernelCtrl.html#gae12c190af42d7310d8006d64f4ed5a88">osKernelSysTickMicroSec</a>.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="group__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__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__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> : Create a thread function.</li>
<li><a class="el" href="group__CMSIS__RTOS__TimerMgmt.html#gaedd312bfdca04e0b8162b666e09a1ae6">osTimerCreate</a> : Define attributes of the timer callback function.</li>
<li><a class="el" href="group__CMSIS__RTOS__MutexMgmt.html#ga5c9de56e717016e39e788064e9a291cc">osMutexCreate</a> : Define and initialize a mutex.</li>
<li><a class="el" href="group__CMSIS__RTOS__SemaphoreMgmt.html#ga97381e8e55cd47cec390bf57c96d6edb">osSemaphoreCreate</a> : Define and initialize a semaphore.</li>
<li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga34af5c4f4ab38f4138ea7f1f9ece3a1a">osPoolCreate</a> : Define and initialize a fix-size memory pool.</li>
<li><a class="el" href="group__CMSIS__RTOS__Message.html#gaf3b9345cf426304d46565152bc26fb78">osMessageCreate</a> : Define and initialize a message queue.</li>
<li><a class="el" href="group__CMSIS__RTOS__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__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__KernelCtrl.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__CMSIS__RTOS__KernelCtrl.html#ga3b571de44cd3094c643247a7397f86b5">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__CMSIS__RTOS__KernelCtrl.html#ga53d078a801022e202e8115c083ece68e">osKernelInitialize</a> () != <a class="code" href="group__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99ea9e1c9e2550bb4de8969a935acffc968f">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="functionOverview.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__CMSIS__RTOS__KernelCtrl.html#ga3b571de44cd3094c643247a7397f86b5">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__CMSIS__RTOS__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__CMSIS__RTOS__KernelCtrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</a>.</dd></dl>
<p><b><a class="el" href="group__CMSIS__RTOS__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__CMSIS__RTOS__KernelCtrl.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="functionOverview.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__CMSIS__RTOS__KernelCtrl.html#ga53d078a801022e202e8115c083ece68e">osKernelInitialize</a> () != <a class="code" href="group__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99ea9e1c9e2550bb4de8969a935acffc968f">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__CMSIS__RTOS__KernelCtrl.html#ga3b571de44cd3094c643247a7397f86b5">osKernelRunning</a> ()) { <span class="comment">// is the kernel running ?</span></div>
<div class="line"> <span class="keywordflow">if</span> (<a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#gaab668ffd2ea76bb0a77ab0ab385eaef2">osKernelStart</a> () != <a class="code" href="group__CMSIS__RTOS__Status.html#gae2e091fefc4c767117727bd5aba4d99ea9e1c9e2550bb4de8969a935acffc968f">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="functionOverview.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__CMSIS__RTOS__KernelCtrl.html#gad0262e4688e95d1e9038afd9bcc16001">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__CMSIS__RTOS__KernelCtrl.html#gad0262e4688e95d1e9038afd9bcc16001">osKernelSysTick</a>() - tick) &lt; <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#gae12c190af42d7310d8006d64f4ed5a88">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 Wed Jul 10 2019 15:21:02 for CMSIS-RTOS Version 1.03 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
-->
</li>
</ul>
</div>
</body>
</html>