xmclib/CMSIS/Documentation/RTOS2/html/theory_of_operation.html
2024-10-17 17:09:59 +02:00

856 lines
94 KiB
HTML

<!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>Theory of Operation</title>
<title>CMSIS-RTOS2: Theory of Operation</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-RTOS2
&#160;<span id="projectnumber">Version 2.1.0</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 class="current"><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('theory_of_operation.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="headertitle">
<div class="title">Theory of Operation </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Many aspects of the kernel are configurable and the configuration options are mentioned where applicable.</p>
<h1><a class="anchor" id="SystemStartup"></a>
System Startup</h1>
<p>Since main is no longer a thread RTX5 does not interfere with the system startup until main is reached. Once the execution reaches <code>main()</code> there is a recommended order to initialize the hardware and start the kernel. This is also reflected in the user code template file "CMSIS-RTOS2 'main' function" supplied with the RTX5 component.</p>
<p>Your application's <code>main()</code> should implement at least the following in the given order:</p>
<ol type="1">
<li>Initialization and configuration of hardware including peripherals, memory, pins, clocks and the interrupt system.</li>
<li>Update the system core clock using the respective <a href="../../Core/html/group__system__init__gr.html">CMSIS-CORE function</a>.</li>
<li>Initialize the CMSIS-RTOS kernel using <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>.</li>
<li>Optionally, create a new thread <code>app_main</code>, which is used as a main thread using <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>. Alternatively, threads can be created in <code>main()</code> directly.</li>
<li>Start the RTOS scheduler using <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>. This function does not return in case of successful execution. Any application code after <b>osKernelStart</b> will not be executed unless <b>osKernelStart</b> fails.</li>
</ol>
<dl class="section note"><dt>Note</dt><dd>Interrupts (like SVC for example) used by the kernel are initialized in <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>. In case priorities and groupings in the NVIC are altered by the application after the above sequence it might be necessary to call <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a> again.</dd></dl>
<h1><a class="anchor" id="MemoryAllocation"></a>
Memory Allocation</h1>
<p>RTX5 objects (thread, mutex, semaphore, timer, message queue, thread and event flags, as well as memory pool) require dedicated RAM memory. Objects can be created using os<em>object</em>New() calls and deleted using os<em>object</em>Delete() calls. The related object memory needs to be available during the lifetime of the object.</p>
<p>RTX5 offers three different memory allocation methods for objects:</p>
<ul>
<li><a class="el" href="theory_of_operation.html#GlobalMemoryPool">Global Memory Pool</a> uses a single global memory pool for all objects. It is easy to configure, but may have the disadvantage for memory fragmentation when objects with different sizes are created and destroyed.</li>
<li><a class="el" href="theory_of_operation.html#ObjectMemoryPool">Object-specific Memory Pools</a> uses a fixed-size memory pool for each object type. The method is time deterministic and avoids memory fragmentation.</li>
<li><a class="el" href="theory_of_operation.html#StaticObjectMemory">Static Object Memory</a> reserves memory during compile time and completely avoids that a system can be out of memory. This is typically a required for some safety critical systems.</li>
</ul>
<p>It possible to intermix all the memory allocation methods in the same application.</p>
<h2><a class="anchor" id="GlobalMemoryPool"></a>
Global Memory Pool</h2>
<p>The global memory pool allocates all objects from a memory area. This method of memory allocation is the default configuration setting of RTX5.</p>
<div class="image">
<img src="MemAllocGlob.png" alt="MemAllocGlob.png"/>
<div class="caption">
Global Memory Pool for all objects</div></div>
<p> When the memory pool does not provide sufficient memory, the creation of the object fails and the related os<em>object</em>New() function returns <span class="XML-Token">NULL</span>.</p>
<p>Enabled in <a class="el" href="config_rtx5.html#systemConfig">System Configuration</a>.</p>
<h2><a class="anchor" id="ObjectMemoryPool"></a>
Object-specific Memory Pools</h2>
<p>Object-specific memory pools avoids memory fragmentation with a dedicated fixed-size memory management for each object type. This type of memory pools are fully time deterministic, which means that object creation and destruction takes always the same fixed amount of time. As a fixed-size memory pool is specific to an object type, the handling of out-of-memory situations is simplified.</p>
<div class="image">
<img src="MemAllocSpec.png" alt="MemAllocSpec.png"/>
<div class="caption">
One memory pool per object type</div></div>
<p> Object-specific memory pools are selectively enabled for each object type, e.g: mutex or thread using the RTX configuration file:</p>
<ul>
<li>Enabled in <a class="el" href="config_rtx5.html#threadConfig">Thread Configuration</a> for thread objects.</li>
<li>Enabled in <a class="el" href="config_rtx5.html#timerConfig">Timer Configuration</a> for timer objects.</li>
<li>Enabled in <a class="el" href="config_rtx5.html#eventFlagsConfig">Event Flags Configuration</a> for event objects.</li>
<li>Enabled in <a class="el" href="config_rtx5.html#mutexConfig">Mutex Configuration</a> for mutex objects.</li>
<li>Enabled in <a class="el" href="config_rtx5.html#semaphoreConfig">Semaphore Configuration</a> for semaphore.</li>
<li>Enabled in <a class="el" href="config_rtx5.html#memPoolConfig">Memory Pool Configuration</a> for memory pools.</li>
<li>Enabled in <a class="el" href="config_rtx5.html#msgQueueConfig">Message Queue Configuration</a> for message objects.</li>
</ul>
<p>When the memory pool does not provide sufficient memory, the creation of the object fails and the related os<em>object</em>New() function returns <span class="XML-Token">NULL</span>.</p>
<h2><a class="anchor" id="StaticObjectMemory"></a>
Static Object Memory</h2>
<p>In contrast to the dynamic memory allocations, the static memory allocation requires compile-time allocation of object memory.</p>
<div class="image">
<img src="MemAllocStat.png" alt="MemAllocStat.png"/>
<div class="caption">
Statically allocated memory for all objects</div></div>
<p> The following code example shows how to create an OS object using static memory.</p>
<p><b> Code Example:</b> </p>
<div class="fragment"><div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment"> * CMSIS-RTOS &#39;main&#39; function template</span></div>
<div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &quot;RTE_Components.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include CMSIS_device_header</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">//include rtx_os.h for types of RTX objects</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="rtx__os_8h.html">rtx_os.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">//The thread function instanced in this example</span></div>
<div class="line"><span class="keywordtype">void</span> worker(<span class="keywordtype">void</span> *arg)</div>
<div class="line">{</div>
<div class="line"> <span class="keywordflow">while</span>(1) </div>
<div class="line"> {</div>
<div class="line"> <span class="comment">//work</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__Wait.html#gaf6055a51390ef65b6b6edc28bf47322e">osDelay</a>(10000);</div>
<div class="line"> } </div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Define objects that are statically allocated for worker thread 1</span></div>
<div class="line"><a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> worker_thread_tcb_1;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Reserve two areas for the stacks of worker thread 1</span></div>
<div class="line"><span class="comment">// uint64_t makes sure the memory alignment is 8</span></div>
<div class="line">uint64_t worker_thread_stk_1[64];</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Define the attributes which are used for thread creation</span></div>
<div class="line"><span class="comment">// Optional const saves RAM memory and includes the values in periodic ROM tests </span></div>
<div class="line"><span class="keyword">const</span> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> worker_attr_1 = {</div>
<div class="line"> <span class="stringliteral">&quot;wrk1&quot;</span>,</div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga249499c519f3f8eef5673009ab6cfcbe">osThreadJoinable</a>,</div>
<div class="line"> &amp;worker_thread_tcb_1,</div>
<div class="line"> <span class="keyword">sizeof</span>(worker_thread_tcb_1),</div>
<div class="line"> &amp;worker_thread_stk_1[0],</div>
<div class="line"> <span class="keyword">sizeof</span>(worker_thread_stk_1),</div>
<div class="line"> <a class="code" href="cmsis__os2_8h.html#gad4e3e0971b41f2d17584a8c6837342eca17b36cd9cd38652c2bc6d4803990674b">osPriorityAboveNormal</a>,</div>
<div class="line"> 0</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Define ID object for thread</span></div>
<div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> th1;</div>
<div class="line"> </div>
<div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment"> * Application main thread</span></div>
<div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
<div class="line"><span class="keywordtype">void</span> app_main (<span class="keywordtype">void</span> *argument) {</div>
<div class="line"> uint32_t param = NULL;</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Create an instance of the worker thread with static resources (TCB and stack)</span></div>
<div class="line"> th1 = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(worker, &amp;param, &amp;worker_attr_1);</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</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="comment">// System Initialization</span></div>
<div class="line"> SystemCoreClockUpdate();</div>
<div class="line"> <span class="comment">// ...</span></div>
<div class="line"></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>(); <span class="comment">// Initialize CMSIS-RTOS</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(app_main, NULL, NULL); <span class="comment">// Create application main thread</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>(); <span class="comment">// Start thread execution</span></div>
<div class="line"> <span class="keywordflow">for</span> (;;) {}</div>
<div class="line">}</div>
</div><!-- fragment --><h1><a class="anchor" id="ThreadStack"></a>
Thread Stack Management</h1>
<p>For Cortex-M processors without floating point unit the thread context requires 64 bytes on the local stack.</p>
<dl class="section note"><dt>Note</dt><dd>For Cortex-M4/M7 with FP the thread context requires 200 bytes on the local stack. For these devices the default stack space should be increased to a minimum of 300 bytes.</dd></dl>
<p>Each thread is provided with a separate stack that holds the thread context and stack space for automatic variables and return addresses for function call nesting. The stack sizes of RTX threads are flexibly configurable as explained in the section <a class="el" href="config_rtx5.html#threadConfig">Thread Configuration</a>. RTX offers a configurable checking for stack overflows and stack utilization.</p>
<h1><a class="anchor" id="lowPower"></a>
Low-Power Operation</h1>
<p>The system thread <b>osRtxIdleThread</b> can be use to switch the system into a low-power mode. The easiest form to enter a low-power mode is the execution of the <code>__WFE</code> function that puts the processor into a sleep mode where it waits for an event.</p>
<p><b>Code Example:</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;RTE_Components.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include CMSIS_device_header </span><span class="comment">/* Device definitions */</span><span class="preprocessor"></span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="group__rtx5__specific__functions.html#gacc47720b9a10fcb7d3412640c8276465">osRtxIdleThread</a> (<span class="keywordtype">void</span>) {</div>
<div class="line"> <span class="comment">/* The idle demon is a system thread, running when no other thread is */</span></div>
<div class="line"> <span class="comment">/* ready to run. */</span></div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">for</span> (;;) {</div>
<div class="line"> __WFE(); <span class="comment">/* Enter sleep mode */</span></div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><code>__WFE()</code> is not available in every Cortex-M implementation. Check device manuals for availability.</dd></dl>
<h1><a class="anchor" id="kernelTimer"></a>
RTX kernel Timer Tick</h1>
<p>By default, RTX5 uses the Cortex-M <a href="http://www.keil.com/support/man/docs/gsac/GSAC_SYSTICKtimer.htm" target="_blank">SysTick</a> timer to generate periodic interrupts for the RTX kernel timer tick. CMSIS-RTOS provides <a class="el" href="group__CMSIS__RTOS__TimerMgmt.html">Timer Management</a> functions and several CMSIS-RTOS functions have a <em>timeout</em> parameter. This periodic RTX kernel timer tick interrupt is used to derive the required time interval. RTX5 also provides configuration options for an alternative timer and tick-less operation.</p>
<p>To handle timeout and time delays for threads, the RTX5 thread management is controlled by the RTX kernel timer tick interrupt. The thread context contains all CPU registers (R0 - R12), the return address (LR), the program counter (PC), and the processor status register (xPSR). For the Cortex-M4/M7 FPU the floating point status and registers (S0 - S32, FPSCR) are also part of the thread context.</p>
<p>When a thread switch occurs:</p>
<ul>
<li>the thread context of the current running thread is stored on the local stack of this thread.</li>
<li>the stack pointer is switched to the next running thread.</li>
<li>the thread context of this next running thread is restored and this thread starts to run.</li>
</ul>
<h1><a class="anchor" id="CMSIS_RTOS_TimeOutValue"></a>
Timeout Value</h1>
<p>Timeout values are an argument to several <b>osXxx</b> functions to allow time for resolving a request. A timeout value of <b>0</b> means that the RTOS does not wait and the function returns instantly, even when no resource is available. A timeout value of <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a> means that the RTOS waits infinitely until a resource becomes available.</p>
<p>The timeout value specifies the number of timer ticks until the time delay elapses. The value is an upper bound and depends on the actual time elapsed since the last timer tick.</p>
<p>Examples:</p>
<ul>
<li>timeout value <b>0</b> : the system does not wait, even when no resource is available the RTOS function returns instantly.</li>
<li>timeout value <b>1</b> : the system waits until the next timer tick occurs; depending on the previous timer tick, it may be a very short wait time.</li>
<li>timeout value <b>2</b> : actual wait time is between 1 and 2 timer ticks.</li>
<li>timeout value <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a> : system waits infinite until a resource becomes available.</li>
</ul>
<div class="image">
<img src="TimerValues.png" alt="TimerValues.png"/>
<div class="caption">
Example of timeout using osDelay()</div></div>
<h1><a class="anchor" id="CMSIS_RTOS_ISR_Calls"></a>
Calls from Interrupt Service Routines</h1>
<p>The following CMSIS-RTOS2 functions can be called from threads and Interrupt Service Routines (ISR):</p>
<ul>
<li><a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae0fcaff6cecfb4013bb556c87afcd7d2">osKernelGetSysTimerCount</a>, <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga4d69215a93220f72be3684cad582f16a">osKernelGetSysTimerFreq</a></li>
<li><a class="el" href="group__CMSIS__RTOS__ThreadFlagsMgmt.html#ga6f89ef9caded1d9963c7b12b0f6412c9">osThreadFlagsSet</a></li>
<li><a class="el" href="group__CMSIS__RTOS__EventFlags.html#ga33b71d14cecf90b4e72639dd19f23a5e">osEventFlagsSet</a>, <a class="el" href="group__CMSIS__RTOS__EventFlags.html#ga93bf258ca0007c6641fbe8e4f2b8a1e5">osEventFlagsClear</a>, <a class="el" href="group__CMSIS__RTOS__EventFlags.html#ga8bda3185f46bfd278cea8a6cf357677d">osEventFlagsGet</a>, <a class="el" href="group__CMSIS__RTOS__EventFlags.html#ga52acb34a8322e58020227344fe662b4e">osEventFlagsWait</a></li>
<li><a class="el" href="group__CMSIS__RTOS__SemaphoreMgmt.html#ga7e94c8b242a0c81f2cc79ec22895c87b">osSemaphoreAcquire</a>, <a class="el" href="group__CMSIS__RTOS__SemaphoreMgmt.html#ga0abcee1b5449d7a6928fb9248c690bb6">osSemaphoreRelease</a>, <a class="el" href="group__CMSIS__RTOS__SemaphoreMgmt.html#ga7559d4dff3cda9992fc5ab5de3e74c70">osSemaphoreGetCount</a></li>
<li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gad696e94bfbe28f0b6613f9303fdf6a37">osMemoryPoolGetCapacity</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gab2bf059b7fa7679c3cccdaeec60b6c0e">osMemoryPoolGetBlockSize</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga958a9449bff8c95ce213de98eef5739d">osMemoryPoolGetCount</a>, <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga0394cffa9479a7994e3b03c79c1cb909">osMemoryPoolGetSpace</a></li>
<li><a class="el" href="group__CMSIS__RTOS__Message.html#gadd5c8996850d1213976ba89cda689acc">osMessageQueuePut</a>, <a class="el" href="group__CMSIS__RTOS__Message.html#gad90d4959466a7a65105061da8256ab9e">osMessageQueueGet</a>, <a class="el" href="group__CMSIS__RTOS__Message.html#gac24f87d4f395e9e9c900c320e45ade8a">osMessageQueueGetCapacity</a>, <a class="el" href="group__CMSIS__RTOS__Message.html#ga96d3d84069b20359de48109e28a1a89e">osMessageQueueGetMsgSize</a>, <a class="el" href="group__CMSIS__RTOS__Message.html#ga6a32ac394fcff568b251c160cc3014b2">osMessageQueueGetCount</a>, <a class="el" href="group__CMSIS__RTOS__Message.html#gaddf0904427436dd3880d46263c2dc9fa">osMessageQueueGetSpace</a></li>
</ul>
<p>Functions that cannot be called from an ISR are verifying the interrupt status and return the status code <b>osErrorISR</b>, in case they are called from an ISR context. In some implementations, this condition might be caught using the HARD_FAULT vector.</p>
<h1><a class="anchor" id="TickLess"></a>
Tick-less Low-Power Operation</h1>
<p>RTX5 provides extension for tick-less operation which is useful for applications that use extensively low-power modes where the SysTick timer is also disabled. To provide a time-tick in such power-saving modes, a wake-up timer is used to derive timer intervals. The CMSIS-RTOS2 functions <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae26683e1606ec633354a2876c68f0c1f">osKernelSuspend</a> and <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga8c4b4d7ed34cab73c001665d9176aced">osKernelResume</a> control the tick-less operation.</p>
<p>Using this functions allows the RTX5 thread scheduler to stop the periodic kernel tick interrupt. When all active threads are suspended, the system enters power-down and calculates how long it can stay in this power-down mode. In the power-down mode the processor and peripherals can be switched off. Only a wake-up timer must remain powered, because this timer is responsible to wake-up the system after the power-down period expires.</p>
<p>The tick-less operation is controlled from the <b>osRtxIdleThread</b> thread. The wake-up timeout value is set before the system enters the power-down mode. The function <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae26683e1606ec633354a2876c68f0c1f">osKernelSuspend</a> calculates the wake-up timeout measured in RTX Timer Ticks; this value is used to setup the wake-up timer that runs during the power-down mode of the system.</p>
<p>Once the system resumes operation (either by a wake-up time out or other interrupts) the RTX5 thread scheduler is started with the function <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga8c4b4d7ed34cab73c001665d9176aced">osKernelResume</a>. The parameter <em>sleep_time</em> specifies the time (in RTX Timer Ticks) that the system was in power-down mode.</p>
<p><b>Code Example:</b> </p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;msp.h&quot;</span> <span class="comment">// Device header</span></div>
<div class="line"></div>
<div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment"> * MSP432 Low-Power Extension Functions</span></div>
<div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> MSP432_LP_Entry(<span class="keywordtype">void</span>) {</div>
<div class="line"> <span class="comment">/* Enable PCM rude mode, which allows to device to enter LPM3 without waiting for peripherals */</span></div>
<div class="line"> PCM-&gt;CTL1 = PCM_CTL1_KEY_VAL | PCM_CTL1_FORCE_LPM_ENTRY; </div>
<div class="line"> <span class="comment">/* Enable all SRAM bank retentions prior to going to LPM3 */</span></div>
<div class="line"> SYSCTL-&gt;SRAM_BANKRET |= SYSCTL_SRAM_BANKRET_BNK7_RET;</div>
<div class="line"> __enable_interrupt();</div>
<div class="line"> NVIC_EnableIRQ(RTC_C_IRQn);</div>
<div class="line"> <span class="comment">/* Do not wake up on exit from ISR */</span></div>
<div class="line"> SCB-&gt;SCR |= SCB_SCR_SLEEPONEXIT_Msk;</div>
<div class="line"> <span class="comment">/* Setting the sleep deep bit */</span></div>
<div class="line"> SCB-&gt;SCR |= (SCB_SCR_SLEEPDEEP_Msk); </div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> tc;</div>
<div class="line"><span class="keyword">static</span> <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> tc_wakeup;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> RTC_C_IRQHandler(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line"> <span class="keywordflow">if</span> (tc++ &gt; tc_wakeup) </div>
<div class="line"> {</div>
<div class="line"> SCB-&gt;SCR &amp;= ~SCB_SCR_SLEEPONEXIT_Msk; </div>
<div class="line"> NVIC_DisableIRQ(RTC_C_IRQn);</div>
<div class="line"> NVIC_ClearPendingIRQ(RTC_C_IRQn);</div>
<div class="line"> <span class="keywordflow">return</span>;</div>
<div class="line"> }</div>
<div class="line"> <span class="keywordflow">if</span> (RTC_C-&gt;PS0CTL &amp; RTC_C_PS0CTL_RT0PSIFG)</div>
<div class="line"> {</div>
<div class="line"> RTC_C-&gt;CTL0 = RTC_C_KEY_VAL; <span class="comment">// Unlock RTC key protected registers</span></div>
<div class="line"> RTC_C-&gt;PS0CTL &amp;= ~RTC_C_PS0CTL_RT0PSIFG;</div>
<div class="line"> RTC_C-&gt;CTL0 = 0;</div>
<div class="line"> SCB-&gt;SCR |= (SCB_SCR_SLEEPDEEP_Msk);</div>
<div class="line"> }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">uint32_t g_enable_sleep = 0;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="group__rtx5__specific__functions.html#gacc47720b9a10fcb7d3412640c8276465">osRtxIdleThread</a> (<span class="keywordtype">void</span>) {</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">for</span> (;;) {</div>
<div class="line"> tc_wakeup = <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#gae26683e1606ec633354a2876c68f0c1f">osKernelSuspend</a>();</div>
<div class="line"> <span class="comment">/* Is there some time to sleep? */</span></div>
<div class="line"> <span class="keywordflow">if</span> (tc_wakeup &gt; 0) {</div>
<div class="line"> tc = 0;</div>
<div class="line"> <span class="comment">/* Enter the low power state */</span></div>
<div class="line"> MSP432_LP_Entry();</div>
<div class="line"> __WFI();</div>
<div class="line"> }</div>
<div class="line"> <span class="comment">/* Adjust the kernel ticks with the amount of ticks slept */</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__KernelCtrl.html#ga8c4b4d7ed34cab73c001665d9176aced">osKernelResume</a> (tc);</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><code>__WFI()</code> is not available in every ARM Cortex-M implementation. Check device manuals for availability.</dd></dl>
<h1><a class="anchor" id="rtx_os_h"></a>
RTX5 Header File</h1>
<p>Every implementation of the CMSIS-RTOS2 API can bring its own additional features. RTX5 adds a couple of <a class="el" href="group__rtx5__specific.html">functions</a> for the idle more, for error notifications, and special system timer functions. It also is using macros for control block and memory sizes.</p>
<p>If you require some of the RTX specific functions in your application code, #include the header file <b>rtx_os.h</b>:</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div>
<div class="line"><span class="comment"> * Copyright (c) 2013-2017 ARM Limited. All rights reserved.</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * SPDX-License-Identifier: Apache-2.0</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * Licensed under the Apache License, Version 2.0 (the License); you may</span></div>
<div class="line"><span class="comment"> * not use this file except in compliance with the License.</span></div>
<div class="line"><span class="comment"> * You may obtain a copy of the License at</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * www.apache.org/licenses/LICENSE-2.0</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></div>
<div class="line"><span class="comment"> * distributed under the License is distributed on an AS IS BASIS, WITHOUT</span></div>
<div class="line"><span class="comment"> * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<div class="line"><span class="comment"> * See the License for the specific language governing permissions and</span></div>
<div class="line"><span class="comment"> * limitations under the License.</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * -----------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * Project: CMSIS-RTOS RTX</span></div>
<div class="line"><span class="comment"> * Title: RTX OS definitions</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * -----------------------------------------------------------------------------</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#ifndef RTX_OS_H_</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define RTX_OS_H_</span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"><span class="preprocessor">#include &lt;stdint.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stddef.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span></div>
<div class="line">{</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Kernel Information</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxVersionAPI 20010000 </span><span class="comment">///&lt; API version (2.1.0)</span></div>
<div class="line"><span class="comment"></span>#define osRtxVersionKernel 50010000 <span class="comment">///&lt; Kernel version (5.1.0)</span></div>
<div class="line"><span class="comment"></span>#define osRtxKernelId &quot;RTX V5.1.0&quot; <span class="comment">///&lt; Kernel identification string</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Common definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Object Identifier definitions</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxIdInvalid 0x00U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxIdThread 0x01U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxIdTimer 0x02U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxIdEventFlags 0x03U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxIdMutex 0x04U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxIdSemaphore 0x05U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxIdMemoryPool 0x06U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxIdMessage 0x07U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxIdMessageQueue 0x08U</span></div>
<div class="line"><span class="preprocessor"></span> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Object State definitions (except for Threads and Timers)</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxObjectInactive 0x00U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxObjectActive 0x01U</span></div>
<div class="line"><span class="preprocessor"></span> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Object Flags definitions</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxFlagSystemObject 0x01U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxFlagSystemMemory 0x02U</span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Kernel definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Kernel State definitions</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxKernelInactive ((uint8_t)osKernelInactive)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxKernelReady ((uint8_t)osKernelReady)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxKernelRunning ((uint8_t)osKernelRunning)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxKernelLocked ((uint8_t)osKernelLocked)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxKernelSuspended ((uint8_t)osKernelSuspended)</span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Thread definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Thread State definitions (extending osThreadState)</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxThreadStateMask 0x0FU</span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"><span class="preprocessor">#define osRtxThreadInactive ((uint8_t)osThreadInactive)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadReady ((uint8_t)osThreadReady)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadRunning ((uint8_t)osThreadRunning)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadBlocked ((uint8_t)osThreadBlocked)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadTerminated ((uint8_t)osThreadTerminated)</span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"><span class="preprocessor">#define osRtxThreadWaitingDelay (osRtxThreadBlocked | 0x10U)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadWaitingJoin (osRtxThreadBlocked | 0x20U)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadWaitingThreadFlags (osRtxThreadBlocked | 0x30U) </span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadWaitingEventFlags (osRtxThreadBlocked | 0x40U) </span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadWaitingMutex (osRtxThreadBlocked | 0x50U)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadWaitingSemaphore (osRtxThreadBlocked | 0x60U)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadWaitingMemoryPool (osRtxThreadBlocked | 0x70U)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadWaitingMessageGet (osRtxThreadBlocked | 0x80U)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxThreadWaitingMessagePut (osRtxThreadBlocked | 0x90U)</span></div>
<div class="line"><span class="preprocessor"></span> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Thread Flags definitions</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxThreadFlagDefStack 0x10U </span><span class="comment">///&lt; Default Stack flag</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment">/// Stack Marker definitions</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxStackMagicWord 0xE25A2EA5U </span><span class="comment">///&lt; Stack Magic Word (Stack Base)</span></div>
<div class="line"><span class="comment"></span>#define osRtxStackFillPattern 0xCCCCCCCCU <span class="comment">///&lt; Stack Fill Pattern </span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment">/// Thread Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxThread_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t attr; <span class="comment">///&lt; Object Attributes</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">const</span> <span class="keywordtype">char</span> *name; <span class="comment">///&lt; Object Name</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxThread_s *thread_next; <span class="comment">///&lt; Link pointer to next Thread in Object list</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxThread_s *thread_prev; <span class="comment">///&lt; Link pointer to previous Thread in Object list</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxThread_s *delay_next; <span class="comment">///&lt; Link pointer to next Thread in Delay list</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxThread_s *delay_prev; <span class="comment">///&lt; Link pointer to previous Thread in Delay list</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxThread_s *thread_join; <span class="comment">///&lt; Thread waiting to Join</span></div>
<div class="line"><span class="comment"></span> uint32_t delay; <span class="comment">///&lt; Delay Time</span></div>
<div class="line"><span class="comment"></span> int8_t priority; <span class="comment">///&lt; Thread Priority</span></div>
<div class="line"><span class="comment"></span> int8_t priority_base; <span class="comment">///&lt; Base Priority</span></div>
<div class="line"><span class="comment"></span> uint8_t stack_frame; <span class="comment">///&lt; Stack Frame (EXC_RETURN[7..0])</span></div>
<div class="line"><span class="comment"></span> uint8_t flags_options; <span class="comment">///&lt; Thread/Event Flags Options</span></div>
<div class="line"><span class="comment"></span> uint32_t wait_flags; <span class="comment">///&lt; Waiting Thread/Event Flags</span></div>
<div class="line"><span class="comment"></span> uint32_t thread_flags; <span class="comment">///&lt; Thread Flags</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxMutex_s *mutex_list; <span class="comment">///&lt; Link pointer to list of owned Mutexes</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *stack_mem; <span class="comment">///&lt; Stack Memory</span></div>
<div class="line"><span class="comment"></span> uint32_t stack_size; <span class="comment">///&lt; Stack Size</span></div>
<div class="line"><span class="comment"></span> uint32_t sp; <span class="comment">///&lt; Current Stack Pointer</span></div>
<div class="line"><span class="comment"></span> uint32_t thread_addr; <span class="comment">///&lt; Thread entry address</span></div>
<div class="line"><span class="comment"></span> uint32_t tz_memory; <span class="comment">///&lt; TrustZone Memory Identifier</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Timer definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Timer State definitions</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxTimerInactive 0x00U </span><span class="comment">///&lt; Timer Inactive</span></div>
<div class="line"><span class="comment"></span>#define osRtxTimerStopped 0x01U <span class="comment">///&lt; Timer Stopped</span></div>
<div class="line"><span class="comment"></span>#define osRtxTimerRunning 0x02U <span class="comment">///&lt; Timer Running</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment">/// Timer Type definitions</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxTimerPeriodic ((uint8_t)osTimerPeriodic)</span></div>
<div class="line"><span class="preprocessor"></span> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Timer Function Information</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"> <span class="keywordtype">void</span> *fp; <span class="comment">///&lt; Function Pointer</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *arg; <span class="comment">///&lt; Function Argument</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="group__rtx5__specific__structs.html#structosRtxTimerFinfo__t">osRtxTimerFinfo_t</a>;</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Timer Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxTimer_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t type; <span class="comment">///&lt; Timer Type (Periodic/One-shot)</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">const</span> <span class="keywordtype">char</span> *name; <span class="comment">///&lt; Object Name</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxTimer_s *prev; <span class="comment">///&lt; Pointer to previous active Timer</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxTimer_s *next; <span class="comment">///&lt; Pointer to next active Timer</span></div>
<div class="line"><span class="comment"></span> uint32_t tick; <span class="comment">///&lt; Timer current Tick</span></div>
<div class="line"><span class="comment"></span> uint32_t load; <span class="comment">///&lt; Timer Load value</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxTimerFinfo__t">osRtxTimerFinfo_t</a> finfo; <span class="comment">///&lt; Timer Function Info</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="group__rtx5__specific__structs.html#structosRtxTimer__t">osRtxTimer_t</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Event Flags definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Event Flags Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxEventFlags_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t reserved;</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *name; <span class="comment">///&lt; Object Name</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *thread_list; <span class="comment">///&lt; Waiting Threads List</span></div>
<div class="line"><span class="comment"></span> uint32_t event_flags; <span class="comment">///&lt; Event Flags</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="group__rtx5__specific__structs.html#structosRtxEventFlags__t">osRtxEventFlags_t</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Mutex definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Mutex Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxMutex_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t attr; <span class="comment">///&lt; Object Attributes</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">const</span> <span class="keywordtype">char</span> *name; <span class="comment">///&lt; Object Name</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *thread_list; <span class="comment">///&lt; Waiting Threads List</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *owner_thread; <span class="comment">///&lt; Owner Thread</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxMutex_s *owner_prev; <span class="comment">///&lt; Pointer to previous owned Mutex</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxMutex_s *owner_next; <span class="comment">///&lt; Pointer to next owned Mutex</span></div>
<div class="line"><span class="comment"></span> uint8_t lock; <span class="comment">///&lt; Lock counter</span></div>
<div class="line"><span class="comment"></span> uint8_t padding[3];</div>
<div class="line">} <a class="code" href="group__rtx5__specific__structs.html#structosRtxMutex__t">osRtxMutex_t</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Semaphore definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Semaphore Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxSemaphore_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t reserved;</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *name; <span class="comment">///&lt; Object Name</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *thread_list; <span class="comment">///&lt; Waiting Threads List</span></div>
<div class="line"><span class="comment"></span> uint16_t tokens; <span class="comment">///&lt; Current number of tokens</span></div>
<div class="line"><span class="comment"></span> uint16_t max_tokens; <span class="comment">///&lt; Maximum number of tokens</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="group__rtx5__specific__structs.html#structosRtxSemaphore__t">osRtxSemaphore_t</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Memory Pool definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Memory Pool Information</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxMpInfo_s {</div>
<div class="line"> uint32_t max_blocks; <span class="comment">///&lt; Maximum number of Blocks</span></div>
<div class="line"><span class="comment"></span> uint32_t used_blocks; <span class="comment">///&lt; Number of used Blocks</span></div>
<div class="line"><span class="comment"></span> uint32_t block_size; <span class="comment">///&lt; Block Size</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *block_base; <span class="comment">///&lt; Block Memory Base Address</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *block_lim; <span class="comment">///&lt; Block Memory Limit Address</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *block_free; <span class="comment">///&lt; First free Block Address</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a>;</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Memory Pool Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxMemoryPool_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t reserved;</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *name; <span class="comment">///&lt; Object Name</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *thread_list; <span class="comment">///&lt; Waiting Threads List</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> mp_info; <span class="comment">///&lt; Memory Pool Info</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="group__rtx5__specific__structs.html#structosRtxMemoryPool__t">osRtxMemoryPool_t</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Message Queue definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Message Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxMessage_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t priority; <span class="comment">///&lt; Message Priority</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxMessage_s *prev; <span class="comment">///&lt; Pointer to previous Message</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>osRtxMessage_s *next; <span class="comment">///&lt; Pointer to next Message</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="rtx__os_8h.html#structosRtxMessage__t">osRtxMessage_t</a>;</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Message Queue Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxMessageQueue_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t reserved;</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *name; <span class="comment">///&lt; Object Name</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *thread_list; <span class="comment">///&lt; Waiting Threads List</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> mp_info; <span class="comment">///&lt; Memory Pool Info</span></div>
<div class="line"><span class="comment"></span> uint32_t msg_size; <span class="comment">///&lt; Message Size</span></div>
<div class="line"><span class="comment"></span> uint32_t msg_count; <span class="comment">///&lt; Number of queued Messages</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMessage__t">osRtxMessage_t</a> *msg_first; <span class="comment">///&lt; Pointer to first Message</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMessage__t">osRtxMessage_t</a> *msg_last; <span class="comment">///&lt; Pointer to last Message</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="group__rtx5__specific__structs.html#structosRtxMessageQueue__t">osRtxMessageQueue_t</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== Generic Object definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Generic Object Control Block</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>osRtxObject_s {</div>
<div class="line"> uint8_t id; <span class="comment">///&lt; Object Identifier</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; Object State</span></div>
<div class="line"><span class="comment"></span> uint8_t flags; <span class="comment">///&lt; Object Flags</span></div>
<div class="line"><span class="comment"></span> uint8_t reserved;</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *name; <span class="comment">///&lt; Object Name</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *thread_list; <span class="comment">///&lt; Threads List</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="rtx__os_8h.html#structosRtxObject__t">osRtxObject_t</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== OS Runtime Information definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// OS Runtime Information structure</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *os_id; <span class="comment">///&lt; OS Identification</span></div>
<div class="line"><span class="comment"></span> uint32_t version; <span class="comment">///&lt; OS Version</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>{ <span class="comment">///&lt; Kernel Info</span></div>
<div class="line"><span class="comment"></span> uint8_t state; <span class="comment">///&lt; State</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">volatile</span> uint8_t blocked; <span class="comment">///&lt; Blocked</span></div>
<div class="line"><span class="comment"></span> uint8_t pendISR; <span class="comment">///&lt; Pending ISR (SV and SysTick)</span></div>
<div class="line"><span class="comment"></span> uint8_t pendSV; <span class="comment">///&lt; Pending SV</span></div>
<div class="line"><span class="comment"></span> uint32_t sys_freq; <span class="comment">///&lt; System Frequency</span></div>
<div class="line"><span class="comment"></span> uint64_t tick; <span class="comment">///&lt; Tick counter</span></div>
<div class="line"><span class="comment"></span> } kernel;</div>
<div class="line"> int32_t tick_irqn; <span class="comment">///&lt; Tick Timer IRQ Number</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>{ <span class="comment">///&lt; Thread Info</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>{ <span class="comment">///&lt; Thread Run Info</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *curr; <span class="comment">///&lt; Current running Thread</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *next; <span class="comment">///&lt; Next Thread to Run</span></div>
<div class="line"><span class="comment"></span> } run;</div>
<div class="line"> <span class="keyword">volatile</span> <a class="code" href="rtx__os_8h.html#structosRtxObject__t">osRtxObject_t</a> ready; <span class="comment">///&lt; Ready List Object</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *idle; <span class="comment">///&lt; Idle Thread</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *delay_list; <span class="comment">///&lt; Delay List</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *wait_list; <span class="comment">///&lt; Wait List (no Timeout)</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *terminate_list; <span class="comment">///&lt; Terminate Thread List</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>{ <span class="comment">///&lt; Thread Round Robin Info</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *thread; <span class="comment">///&lt; Round Robin Thread</span></div>
<div class="line"><span class="comment"></span> uint32_t tick; <span class="comment">///&lt; Round Robin Time Tick</span></div>
<div class="line"><span class="comment"></span> uint32_t timeout; <span class="comment">///&lt; Round Robin Timeout</span></div>
<div class="line"><span class="comment"></span> } robin;</div>
<div class="line"> } thread;</div>
<div class="line"> <span class="keyword">struct </span>{ <span class="comment">///&lt; Timer Info</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxTimer__t">osRtxTimer_t</a> *list; <span class="comment">///&lt; Active Timer List</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a> *thread; <span class="comment">///&lt; Timer Thread</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="group__rtx5__specific__structs.html#structosRtxMessageQueue__t">osRtxMessageQueue_t</a> *mq; <span class="comment">///&lt; Timer Message Queue</span></div>
<div class="line"><span class="comment"></span> } timer;</div>
<div class="line"> <span class="keyword">struct </span>{ <span class="comment">///&lt; ISR Post Processing Queue</span></div>
<div class="line"><span class="comment"></span> uint16_t max; <span class="comment">///&lt; Maximum Items</span></div>
<div class="line"><span class="comment"></span> uint16_t cnt; <span class="comment">///&lt; Item Count</span></div>
<div class="line"><span class="comment"></span> uint16_t in; <span class="comment">///&lt; Incoming Item Index</span></div>
<div class="line"><span class="comment"></span> uint16_t out; <span class="comment">///&lt; Outgoing Item Index</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> **data; <span class="comment">///&lt; Queue Data</span></div>
<div class="line"><span class="comment"></span> } isr_queue;</div>
<div class="line"> <span class="keyword">struct </span>{ <span class="comment">///&lt; ISR Post Processing functions</span></div>
<div class="line"><span class="comment"></span> void (*thread)(<a class="code" href="group__rtx5__specific__structs.html#structosRtxThread__t">osRtxThread_t</a>*); <span class="comment">///&lt; Thread Post Processing function</span></div>
<div class="line"><span class="comment"></span> void (*event_flags)(<a class="code" href="group__rtx5__specific__structs.html#structosRtxEventFlags__t">osRtxEventFlags_t</a>*); <span class="comment">///&lt; Event Flags Post Processing function</span></div>
<div class="line"><span class="comment"></span> void (*semaphore)(<a class="code" href="group__rtx5__specific__structs.html#structosRtxSemaphore__t">osRtxSemaphore_t</a>*); <span class="comment">///&lt; Semaphore Post Processing function</span></div>
<div class="line"><span class="comment"></span> void (*memory_pool)(<a class="code" href="group__rtx5__specific__structs.html#structosRtxMemoryPool__t">osRtxMemoryPool_t</a>*); <span class="comment">///&lt; Memory Pool Post Processing function</span></div>
<div class="line"><span class="comment"></span> void (*message_queue)(<a class="code" href="rtx__os_8h.html#structosRtxMessage__t">osRtxMessage_t</a>*); <span class="comment">///&lt; Message Queue Post Processing function</span></div>
<div class="line"><span class="comment"></span> } post_process;</div>
<div class="line"> <span class="keyword">struct </span>{ <span class="comment">///&lt; Memory Pools (Variable Block Size)</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *stack; <span class="comment">///&lt; Stack Memory</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *mp_data; <span class="comment">///&lt; Memory Pool Data Memory</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *mq_data; <span class="comment">///&lt; Message Queue Data Memory</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *common; <span class="comment">///&lt; Common Memory</span></div>
<div class="line"><span class="comment"></span> } mem;</div>
<div class="line"> <span class="keyword">struct </span>{ <span class="comment">///&lt; Memory Pools (Fixed Block Size)</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *stack; <span class="comment">///&lt; Stack for Threads</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *thread; <span class="comment">///&lt; Thread Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *timer; <span class="comment">///&lt; Timer Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *event_flags; <span class="comment">///&lt; Event Flags Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *mutex; <span class="comment">///&lt; Mutex Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *semaphore; <span class="comment">///&lt; Semaphore Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *memory_pool; <span class="comment">///&lt; Memory Pool Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *message_queue; <span class="comment">///&lt; Message Queue Control Blocks</span></div>
<div class="line"><span class="comment"></span> } mpi;</div>
<div class="line">} <a class="code" href="rtx__os_8h.html#structosRtxInfo__t">osRtxInfo_t</a>;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">extern</span> <a class="code" href="rtx__os_8h.html#structosRtxInfo__t">osRtxInfo_t</a> <a class="code" href="rtx__os_8h.html#ad2270125c4e4991c3231d752b6ee5f3f">osRtxInfo</a>; <span class="comment">///&lt; OS Runtime Information</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== OS API definitions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Object Limits definitions</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxThreadFlagsLimit 31U </span><span class="comment">///&lt; number of Thread Flags available per thread</span></div>
<div class="line"><span class="comment"></span>#define osRtxEventFlagsLimit 31U <span class="comment">///&lt; number of Event Flags available per object</span></div>
<div class="line"><span class="comment"></span>#define osRtxMutexLockLimit 255U <span class="comment">///&lt; maximum number of recursive mutex locks</span></div>
<div class="line"><span class="comment"></span>#define osRtxSemaphoreTokenLimit 65535U <span class="comment">///&lt; maximum number of tokens per semaphore</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment">/// Control Block sizes</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxThreadCbSize sizeof(osRtxThread_t)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxTimerCbSize sizeof(osRtxTimer_t)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxEventFlagsCbSize sizeof(osRtxEventFlags_t)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxMutexCbSize sizeof(osRtxMutex_t)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxSemaphoreCbSize sizeof(osRtxSemaphore_t)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxMemoryPoolCbSize sizeof(osRtxMemoryPool_t)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxMessageQueueCbSize sizeof(osRtxMessageQueue_t)</span></div>
<div class="line"><span class="preprocessor"></span> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Memory size in bytes for Memory Pool storage.</span></div>
<div class="line"><span class="comment">/// \param block_count maximum number of memory blocks in memory pool.</span></div>
<div class="line"><span class="comment">/// \param block_size memory block size in bytes.</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxMemoryPoolMemSize(block_count, block_size) \</span></div>
<div class="line"><span class="preprocessor"> (4*(block_count)*(((block_size)+3)/4))</span></div>
<div class="line"><span class="preprocessor"></span> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Memory size in bytes for Message Queue storage.</span></div>
<div class="line"><span class="comment">/// \param msg_count maximum number of messages in queue.</span></div>
<div class="line"><span class="comment">/// \param msg_size maximum message size in bytes.</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxMessageQueueMemSize(msg_count, msg_size) \</span></div>
<div class="line"><span class="preprocessor"> (4*(msg_count)*(3+(((msg_size)+3)/4)))</span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== OS External Functions ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// OS Error Codes</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxErrorStackUnderflow 1U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxErrorISRQueueOverflow 2U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxErrorTimerQueueOverflow 3U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxErrorClibSpace 4U</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define osRtxErrorClibMutex 5U</span></div>
<div class="line"><span class="preprocessor"></span> <span class="comment"></span></div>
<div class="line"><span class="comment">/// OS Error Callback function</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> uint32_t <a class="code" href="group__rtx5__specific__functions.html#gaf1745a88f9cc60b609ab1c8076bd346d">osRtxErrorNotify</a> (uint32_t code, <span class="keywordtype">void</span> *object_id);</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// OS Idle Thread</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="group__rtx5__specific__functions.html#gacc47720b9a10fcb7d3412640c8276465">osRtxIdleThread</a> (<span class="keywordtype">void</span> *argument);</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// OS Exception handlers</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="rtx__os_8h.html#a3e5ddb3df0d62f2dc357e64a3f04a6ce">SVC_Handler</a> (<span class="keywordtype">void</span>);</div>
<div class="line"><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="rtx__os_8h.html#a6303e1f258cbdc1f970ce579cc015623">PendSV_Handler</a> (<span class="keywordtype">void</span>);</div>
<div class="line"><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="rtx__os_8h.html#ab5e09814056d617c521549e542639b7e">SysTick_Handler</a> (<span class="keywordtype">void</span>);</div>
<div class="line"> </div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// OS System Timer functions (default implementation uses SysTick)</span></div>
<div class="line"><span class="comment"></span> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Setup System Timer.</span></div>
<div class="line"><span class="comment">/// \return system timer IRQ number.</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> int32_t <a class="code" href="group__rtx5__specific__functions.html#gaa10ba9022d27bfbf2f76c40663f4598d">osRtxSysTimerSetup</a> (<span class="keywordtype">void</span>);</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Enable System Timer.</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="group__rtx5__specific__functions.html#ga186a61d27c68b3ae841dded8f1289857">osRtxSysTimerEnable</a> (<span class="keywordtype">void</span>);</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Disable System Timer.</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="group__rtx5__specific__functions.html#gaf8200a879df96753af1af391fadd9f9e">osRtxSysTimerDisable</a> (<span class="keywordtype">void</span>);</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Acknowledge System Timer IRQ.</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="group__rtx5__specific__functions.html#ga9194d74a1170a6107fb8a9bb3783dace">osRtxSysTimerAckIRQ</a> (<span class="keywordtype">void</span>);</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Get System Timer count.</span></div>
<div class="line"><span class="comment">/// \return system timer count.</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> uint32_t <a class="code" href="group__rtx5__specific__functions.html#gaa1b9fdcae08625c1f32e230051c3601f">osRtxSysTimerGetCount</a> (<span class="keywordtype">void</span>);</div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// Get System Timer frequency.</span></div>
<div class="line"><span class="comment">/// \return system timer frequency.</span></div>
<div class="line"><span class="comment"></span><span class="keyword">extern</span> uint32_t <a class="code" href="group__rtx5__specific__functions.html#gaa15aeddbccbc909c2ea88f9e2fe98ccf">osRtxSysTimerGetFreq</a> (<span class="keywordtype">void</span>);</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="comment">// ==== OS External Configuration ====</span></div>
<div class="line"> <span class="comment"></span></div>
<div class="line"><span class="comment">/// OS Configuration flags</span></div>
<div class="line"><span class="comment"></span><span class="preprocessor">#define osRtxConfigPrivilegedMode (1UL&lt;&lt;0) </span><span class="comment">///&lt; Threads in Privileged mode</span></div>
<div class="line"><span class="comment"></span>#define osRtxConfigStackCheck (1UL&lt;&lt;1) <span class="comment">///&lt; Stack overrun checking</span></div>
<div class="line"><span class="comment"></span>#define osRtxConfigStackWatermark (1UL&lt;&lt;2) <span class="comment">///&lt; Stack usage Watermark</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"><span class="comment">/// OS Configuration structure</span></div>
<div class="line"><span class="comment"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"> uint32_t flags; <span class="comment">///&lt; OS Configuration Flags</span></div>
<div class="line"><span class="comment"></span> uint32_t tick_freq; <span class="comment">///&lt; Kernel Tick Frequency</span></div>
<div class="line"><span class="comment"></span> uint32_t robin_timeout; <span class="comment">///&lt; Round Robin Timeout Tick</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">struct </span>{ <span class="comment">///&lt; ISR Post Processing Queue</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> **data; <span class="comment">///&lt; Queue Data</span></div>
<div class="line"><span class="comment"></span> uint16_t max; <span class="comment">///&lt; Maximum Items</span></div>
<div class="line"><span class="comment"></span> uint16_t padding;</div>
<div class="line"> } isr_queue;</div>
<div class="line"> <span class="keyword">struct </span>{ <span class="comment">///&lt; Memory Pools (Variable Block Size)</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *stack_addr; <span class="comment">///&lt; Stack Memory Address</span></div>
<div class="line"><span class="comment"></span> uint32_t stack_size; <span class="comment">///&lt; Stack Memory Size</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *mp_data_addr; <span class="comment">///&lt; Memory Pool Memory Address</span></div>
<div class="line"><span class="comment"></span> uint32_t mp_data_size; <span class="comment">///&lt; Memory Pool Memory Size</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *mq_data_addr; <span class="comment">///&lt; Message Queue Data Memory Address</span></div>
<div class="line"><span class="comment"></span> uint32_t mq_data_size; <span class="comment">///&lt; Message Queue Data Memory Size</span></div>
<div class="line"><span class="comment"></span> <span class="keywordtype">void</span> *common_addr; <span class="comment">///&lt; Common Memory Address</span></div>
<div class="line"><span class="comment"></span> uint32_t common_size; <span class="comment">///&lt; Common Memory Size</span></div>
<div class="line"><span class="comment"></span> } mem;</div>
<div class="line"> <span class="keyword">struct </span>{ <span class="comment">///&lt; Memory Pools (Fixed Block Size)</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *stack; <span class="comment">///&lt; Stack for Threads</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *thread; <span class="comment">///&lt; Thread Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *timer; <span class="comment">///&lt; Timer Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *event_flags; <span class="comment">///&lt; Event Flags Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *mutex; <span class="comment">///&lt; Mutex Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *semaphore; <span class="comment">///&lt; Semaphore Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *memory_pool; <span class="comment">///&lt; Memory Pool Control Blocks</span></div>
<div class="line"><span class="comment"></span> <a class="code" href="rtx__os_8h.html#structosRtxMpInfo__t">osRtxMpInfo_t</a> *message_queue; <span class="comment">///&lt; Message Queue Control Blocks</span></div>
<div class="line"><span class="comment"></span> } mpi;</div>
<div class="line"> uint32_t thread_stack_size; <span class="comment">///&lt; Default Thread Stack Size</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">const</span> </div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> *idle_thread_attr; <span class="comment">///&lt; Idle Thread Attributes</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">const</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#structosThreadAttr__t">osThreadAttr_t</a> *timer_thread_attr; <span class="comment">///&lt; Timer Thread Attributes</span></div>
<div class="line"><span class="comment"></span> <span class="keyword">const</span></div>
<div class="line"> <a class="code" href="group__CMSIS__RTOS__Message.html#structosMessageQueueAttr__t">osMessageQueueAttr_t</a> *timer_mq_attr; <span class="comment">///&lt; Timer Message Queue Attributes</span></div>
<div class="line"><span class="comment"></span> uint32_t timer_mq_mcnt; <span class="comment">///&lt; Timer Message Queue maximum Messages</span></div>
<div class="line"><span class="comment"></span>} <a class="code" href="rtx__os_8h.html#structosRtxConfig__t">osRtxConfig_t</a>;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">extern</span> <span class="keyword">const</span> <a class="code" href="rtx__os_8h.html#structosRtxConfig__t">osRtxConfig_t</a> <a class="code" href="rtx__os_8h.html#a489fda965fa634809f401ae6458a6f45">osRtxConfig</a>; <span class="comment">///&lt; OS Configuration</span></div>
<div class="line"><span class="comment"></span> </div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><span class="preprocessor"></span>}</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor"></span> </div>
<div class="line"><span class="preprocessor">#endif // RTX_OS_H_</span></div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="rtx5_impl.html">RTX v5 Implementation</a></li>
<li class="footer">Generated on Wed Feb 8 2017 10:21:03 for CMSIS-RTOS2 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>