]> begriffs open source - cmsis/blob - main/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html
Update documentation for branch main
[cmsis] / main / RTOS2 / html / group__CMSIS__RTOS__PoolMgmt.html
1 <!-- HTML header for doxygen 1.9.6-->
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
4 <head>
5 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6 <meta http-equiv="X-UA-Compatible" content="IE=11"/>
7 <meta name="viewport" content="width=device-width, initial-scale=1"/>
8 <title>CMSIS-RTOS2: Memory Pool</title>
9 <link href="doxygen.css" rel="stylesheet" type="text/css"/>
10 <link href="tabs.css" rel="stylesheet" type="text/css"/>
11 <link href="extra_navtree.css" rel="stylesheet" type="text/css"/>
12 <link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
13 <link href="extra_search.css" rel="stylesheet" type="text/css"/>
14 <script type="text/javascript" src="jquery.js"></script>
15 <script type="text/javascript" src="dynsections.js"></script>
16 <script type="text/javascript" src="printComponentTabs.js"></script>
17 <script type="text/javascript" src="footer.js"></script>
18 <script type="text/javascript" src="navtree.js"></script>
19 <link href="navtree.css" rel="stylesheet" type="text/css"/>
20 <script type="text/javascript" src="resize.js"></script>
21 <script type="text/javascript" src="navtreedata.js"></script>
22 <script type="text/javascript" src="navtree.js"></script>
23 <link href="search/search.css" rel="stylesheet" type="text/css"/>
24 <script type="text/javascript" src="search/searchdata.js"></script>
25 <script type="text/javascript" src="search/search.js"></script>
26 <script type="text/javascript">
27 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
28   $(document).ready(function() { init_search(); });
29 /* @license-end */
30 </script>
31 <script type="text/javascript" src="darkmode_toggle.js"></script>
32 <link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
33 <link href="extra_navtree.css" rel="stylesheet" type="text/css"/>
34 <link href="extra_search.css" rel="stylesheet" type="text/css"/>
35 <link href="version.css" rel="stylesheet" type="text/css" />
36 <script type="text/javascript" src="../../version.js"></script>
37 </head>
38 <body>
39 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
40 <div id="titlearea">
41 <table cellspacing="0" cellpadding="0">
42  <tbody>
43  <tr style="height: 55px;">
44   <td id="projectlogo" style="padding: 1.5em;"><img alt="Logo" src="cmsis_logo_white_small.png"/></td>
45   <td style="padding-left: 1em; padding-bottom: 1em;padding-top: 1em;">
46    <div id="projectname">CMSIS-RTOS2
47    &#160;<span id="projectnumber"><script type="text/javascript">
48      <!--
49      writeHeader.call(this);
50      writeVersionDropdown.call(this, "CMSIS-RTOS2");
51      //-->
52     </script>
53    </span>
54    </div>
55    <div id="projectbrief">Real-Time Operating System API</div>
56   </td>
57    <td>        <div id="MSearchBox" class="MSearchBoxInactive">
58         <span class="left">
59           <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
60           <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
61                onfocus="searchBox.OnSearchFieldFocus(true)" 
62                onblur="searchBox.OnSearchFieldFocus(false)" 
63                onkeyup="searchBox.OnSearchFieldChange(event)"/>
64           </span><span class="right">
65             <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
66           </span>
67         </div>
68 </td>
69   <!--END !PROJECT_NAME-->
70  </tr>
71  </tbody>
72 </table>
73 </div>
74 <!-- end header part -->
75 <div id="CMSISnav" class="tabs1">
76   <ul class="tablist">
77     <script type="text/javascript">
78       writeComponentTabs.call(this);
79     </script>
80   </ul>
81 </div>
82 <script type="text/javascript">
83   writeSubComponentTabs.call(this);
84 </script>
85 <!-- Generated by Doxygen 1.9.6 -->
86 <script type="text/javascript">
87 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
88 var searchBox = new SearchBox("searchBox", "search/",'.html');
89 /* @license-end */
90 </script>
91 </div><!-- top -->
92 <div id="side-nav" class="ui-resizable side-nav-resizable">
93   <div id="nav-tree">
94     <div id="nav-tree-contents">
95       <div id="nav-sync" class="sync"></div>
96     </div>
97   </div>
98   <div id="splitbar" style="-moz-user-select:none;" 
99        class="ui-resizable-handle">
100   </div>
101 </div>
102 <script type="text/javascript">
103 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
104 $(document).ready(function(){initNavTree('group__CMSIS__RTOS__PoolMgmt.html',''); initResizable(); });
105 /* @license-end */
106 </script>
107 <div id="doc-content">
108 <!-- window showing the filter options -->
109 <div id="MSearchSelectWindow"
110      onmouseover="return searchBox.OnSearchSelectShow()"
111      onmouseout="return searchBox.OnSearchSelectHide()"
112      onkeydown="return searchBox.OnSearchSelectKey(event)">
113 </div>
114
115 <!-- iframe showing the search results (closed by default) -->
116 <div id="MSearchResultsWindow">
117 <div id="MSearchResults">
118 <div class="SRPage">
119 <div id="SRIndex">
120 <div id="SRResults"></div>
121 <div class="SRStatus" id="Loading">Loading...</div>
122 <div class="SRStatus" id="Searching">Searching...</div>
123 <div class="SRStatus" id="NoMatches">No Matches</div>
124 </div>
125 </div>
126 </div>
127 </div>
128
129 <div class="header">
130   <div class="summary">
131 <a href="#nested-classes">Data Structures</a> &#124;
132 <a href="#typedef-members">Typedefs</a> &#124;
133 <a href="#func-members">Functions</a>  </div>
134   <div class="headertitle"><div class="title">Memory Pool<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS API v2</a></div></div></div>
135 </div><!--header-->
136 <div class="contents">
137
138 <p>Manage thread-safe fixed-size blocks of dynamic memory.  
139 <a href="#details">More...</a></p>
140 <table class="memberdecls">
141 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
142 Data Structures</h2></td></tr>
143 <tr class="memitem:structosMemoryPoolAttr__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a></td></tr>
144 <tr class="memdesc:structosMemoryPoolAttr__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attributes structure for memory pool.  <a href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">More...</a><br /></td></tr>
145 <tr class="separator:structosMemoryPoolAttr__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
146 </table><table class="memberdecls">
147 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
148 Typedefs</h2></td></tr>
149 <tr class="memitem:ga2e44473caf338266f56800960294f960"><td class="memItemLeft" align="right" valign="top">typedef void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></td></tr>
150 <tr class="separator:ga2e44473caf338266f56800960294f960"><td class="memSeparator" colspan="2">&#160;</td></tr>
151 </table><table class="memberdecls">
152 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
153 Functions</h2></td></tr>
154 <tr class="memitem:ga497ced5d72dc5cd405c4c418516220dc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a> (uint32_t block_count, uint32_t block_size, const <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a> *attr)</td></tr>
155 <tr class="memdesc:ga497ced5d72dc5cd405c4c418516220dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create and Initialize a Memory Pool object.  <br /></td></tr>
156 <tr class="separator:ga497ced5d72dc5cd405c4c418516220dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
157 <tr class="memitem:gab414a1e138205a55820acfa277c8f386"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gab414a1e138205a55820acfa277c8f386">osMemoryPoolGetName</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
158 <tr class="memdesc:gab414a1e138205a55820acfa277c8f386"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get name of a Memory Pool object.  <br /></td></tr>
159 <tr class="separator:gab414a1e138205a55820acfa277c8f386"><td class="memSeparator" colspan="2">&#160;</td></tr>
160 <tr class="memitem:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id, uint32_t timeout)</td></tr>
161 <tr class="memdesc:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate a memory block from a Memory Pool.  <br /></td></tr>
162 <tr class="separator:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
163 <tr class="memitem:gabb4f4560daa6d1f8c8789082ee186d16"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id, void *block)</td></tr>
164 <tr class="memdesc:gabb4f4560daa6d1f8c8789082ee186d16"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return an allocated memory block back to a Memory Pool.  <br /></td></tr>
165 <tr class="separator:gabb4f4560daa6d1f8c8789082ee186d16"><td class="memSeparator" colspan="2">&#160;</td></tr>
166 <tr class="memitem:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gad696e94bfbe28f0b6613f9303fdf6a37">osMemoryPoolGetCapacity</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
167 <tr class="memdesc:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get maximum number of memory blocks in a Memory Pool.  <br /></td></tr>
168 <tr class="separator:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="memSeparator" colspan="2">&#160;</td></tr>
169 <tr class="memitem:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gab2bf059b7fa7679c3cccdaeec60b6c0e">osMemoryPoolGetBlockSize</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
170 <tr class="memdesc:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get memory block size in a Memory Pool.  <br /></td></tr>
171 <tr class="separator:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="memSeparator" colspan="2">&#160;</td></tr>
172 <tr class="memitem:ga958a9449bff8c95ce213de98eef5739d"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga958a9449bff8c95ce213de98eef5739d">osMemoryPoolGetCount</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
173 <tr class="memdesc:ga958a9449bff8c95ce213de98eef5739d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of memory blocks used in a Memory Pool.  <br /></td></tr>
174 <tr class="separator:ga958a9449bff8c95ce213de98eef5739d"><td class="memSeparator" colspan="2">&#160;</td></tr>
175 <tr class="memitem:ga0394cffa9479a7994e3b03c79c1cb909"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga0394cffa9479a7994e3b03c79c1cb909">osMemoryPoolGetSpace</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
176 <tr class="memdesc:ga0394cffa9479a7994e3b03c79c1cb909"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of memory blocks available in a Memory Pool.  <br /></td></tr>
177 <tr class="separator:ga0394cffa9479a7994e3b03c79c1cb909"><td class="memSeparator" colspan="2">&#160;</td></tr>
178 <tr class="memitem:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8c39e7e5cd2b9eda907466808e59d62e">osMemoryPoolDelete</a> (<a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mp_id)</td></tr>
179 <tr class="memdesc:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete a Memory Pool object.  <br /></td></tr>
180 <tr class="separator:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="memSeparator" colspan="2">&#160;</td></tr>
181 </table>
182 <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
183 <p><b>Memory</b> <b>Pools</b> are fixed-size blocks of memory that are thread-safe. They operate much faster than the dynamically allocated heap and do not suffer from fragmentation. Being thread-safe, they can be accessed from threads and ISRs alike.</p>
184 <p>A Memory Pool can be seen as a linked list of available (unused) memory blocks of fixed and equal size. Allocating memory from a pool (using <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a>) simply unchains a block from the list and hands over control to the user. Freeing memory to the pool (using <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a>) simply rechains the block into the list.</p>
185 <div class="image">
186 <img src="mempool.png" alt=""/>
187 <div class="caption">
188 CMSIS-RTOS Memory Pools</div></div>
189 <dl class="section note"><dt>Note</dt><dd>One must not write to freed block. It is up to the implementation to reuse the memory of unused blocks for internal control data, i.e. linked list pointers.</dd></dl>
190 <p><b>Shared</b> <b>memory</b> is one of the basic models to exchange information between threads. Using memory pools for exchanging data, you can share more complex objects between threads if compared to a <a class="el" href="group__CMSIS__RTOS__Message.html">Message Queue</a>. Memory pool management functions are used to define and manage such fixed-sized memory pools.</p>
191 <dl class="section note"><dt>Note</dt><dd>The functions <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> can be called from Interrupt Service Routines. </dd>
192 <dd>
193 Refer to memPoolConfig for RTX5 configuration options. </dd></dl>
194 <hr/><h2 class="groupheader">Data Structure Documentation</h2>
195 <a name="structosMemoryPoolAttr__t" id="structosMemoryPoolAttr__t"></a>
196 <h2 class="memtitle"><span class="permalink"><a href="#structosMemoryPoolAttr__t">&#9670;&#160;</a></span>osMemoryPoolAttr_t</h2>
197
198 <div class="memitem">
199 <div class="memproto">
200       <table class="memname">
201         <tr>
202           <td class="memname">struct osMemoryPoolAttr_t</td>
203         </tr>
204       </table>
205 </div><div class="memdoc">
206 <div class="textblock"><p>Attributes to configure a memory pool.</p>
207 <p>Refer to <a class="el" href="group__CMSIS__RTOS__MemoryMgmt.html">Memory Management</a> for details about usage of</p><ul>
208 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a1e100dc33d403841ed3c344e3397868e" title="memory for control block">osMemoryPoolAttr_t::cb_mem</a></li>
209 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#aa55a4335d12dc2785dc00fdc292d1159" title="size of provided memory for control block">osMemoryPoolAttr_t::cb_size</a></li>
210 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a5799465cca9c71c5587ceb0986f5b06a" title="memory for data storage">osMemoryPoolAttr_t::mp_mem</a></li>
211 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a66c26015c0ac8e88a4ad907c120aee4f" title="size of provided memory for data storage">osMemoryPoolAttr_t::mp_size</a> </li>
212 </ul>
213 </div><table class="fieldtable">
214 <tr><th colspan="3">Data Fields</th></tr>
215 <tr><td class="fieldtype">
216 <a id="ab74e6bf80237ddc4109968cedc58c151" name="ab74e6bf80237ddc4109968cedc58c151"></a>const char *</td>
217 <td class="fieldname">
218 name</td>
219 <td class="fielddoc">
220 name of the memory pool <p>Pointer to a string with a human readable name of the memory pool object.<br  />
221 Default: <span class="XML-Token">NULL</span>. </p>
222 </td></tr>
223 <tr><td class="fieldtype">
224 <a id="a6e93b49cb79c12f768d72580c7731f30" name="a6e93b49cb79c12f768d72580c7731f30"></a>uint32_t</td>
225 <td class="fieldname">
226 attr_bits</td>
227 <td class="fielddoc">
228 attribute bits <p>Reserved for future use (set to '0').<br  />
229 Default: <span class="XML-Token">0</span>. </p>
230 </td></tr>
231 <tr><td class="fieldtype">
232 <a id="a1e100dc33d403841ed3c344e3397868e" name="a1e100dc33d403841ed3c344e3397868e"></a>void *</td>
233 <td class="fieldname">
234 cb_mem</td>
235 <td class="fielddoc">
236 memory for control block <p>Pointer to a memory location for the memory pool control block object. This can optionally be used for custom memory management systems.<br  />
237 Default: <span class="XML-Token">NULL</span> (uses kernel memory management). </p>
238 </td></tr>
239 <tr><td class="fieldtype">
240 <a id="aa55a4335d12dc2785dc00fdc292d1159" name="aa55a4335d12dc2785dc00fdc292d1159"></a>uint32_t</td>
241 <td class="fieldname">
242 cb_size</td>
243 <td class="fielddoc">
244 size of provided memory for control block <p>The size of the memory block passed with <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a1e100dc33d403841ed3c344e3397868e">cb_mem</a>. Must be the size of a memory pool control block object or larger. </p>
245 </td></tr>
246 <tr><td class="fieldtype">
247 <a id="a5799465cca9c71c5587ceb0986f5b06a" name="a5799465cca9c71c5587ceb0986f5b06a"></a>void *</td>
248 <td class="fieldname">
249 mp_mem</td>
250 <td class="fielddoc">
251 memory for data storage <p>Pointer to a memory location for the data of the memory pool object.<br  />
252 Default: <span class="XML-Token">NULL</span>. </p>
253 </td></tr>
254 <tr><td class="fieldtype">
255 <a id="a66c26015c0ac8e88a4ad907c120aee4f" name="a66c26015c0ac8e88a4ad907c120aee4f"></a>uint32_t</td>
256 <td class="fieldname">
257 mp_size</td>
258 <td class="fielddoc">
259 size of provided memory for data storage <p>The size of the memory passed with <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a5799465cca9c71c5587ceb0986f5b06a">mp_mem</a>. </p>
260 </td></tr>
261 </table>
262
263 </div>
264 </div>
265 <h2 class="groupheader">Typedef Documentation</h2>
266 <a id="ga2e44473caf338266f56800960294f960" name="ga2e44473caf338266f56800960294f960"></a>
267 <h2 class="memtitle"><span class="permalink"><a href="#ga2e44473caf338266f56800960294f960">&#9670;&#160;</a></span>osMemoryPoolId_t</h2>
268
269 <div class="memitem">
270 <div class="memproto">
271       <table class="memname">
272         <tr>
273           <td class="memname"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></td>
274         </tr>
275       </table>
276 </div><div class="memdoc">
277 <p>Memory Pool ID identifies the memory pool.</p>
278 <p>Returned by:</p><ul>
279 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a> </li>
280 </ul>
281
282 </div>
283 </div>
284 <h2 class="groupheader">Function Documentation</h2>
285 <a id="ga497ced5d72dc5cd405c4c418516220dc" name="ga497ced5d72dc5cd405c4c418516220dc"></a>
286 <h2 class="memtitle"><span class="permalink"><a href="#ga497ced5d72dc5cd405c4c418516220dc">&#9670;&#160;</a></span>osMemoryPoolNew()</h2>
287
288 <div class="memitem">
289 <div class="memproto">
290       <table class="memname">
291         <tr>
292           <td class="memname"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> osMemoryPoolNew </td>
293           <td>(</td>
294           <td class="paramtype">uint32_t&#160;</td>
295           <td class="paramname"><em>block_count</em>, </td>
296         </tr>
297         <tr>
298           <td class="paramkey"></td>
299           <td></td>
300           <td class="paramtype">uint32_t&#160;</td>
301           <td class="paramname"><em>block_size</em>, </td>
302         </tr>
303         <tr>
304           <td class="paramkey"></td>
305           <td></td>
306           <td class="paramtype">const <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a> *&#160;</td>
307           <td class="paramname"><em>attr</em>&#160;</td>
308         </tr>
309         <tr>
310           <td></td>
311           <td>)</td>
312           <td></td><td></td>
313         </tr>
314       </table>
315 </div><div class="memdoc">
316 <dl class="params"><dt>Parameters</dt><dd>
317   <table class="params">
318     <tr><td class="paramdir">[in]</td><td class="paramname">block_count</td><td>maximum number of memory blocks in memory pool. </td></tr>
319     <tr><td class="paramdir">[in]</td><td class="paramname">block_size</td><td>memory block size in bytes. </td></tr>
320     <tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>memory pool attributes; NULL: default values. </td></tr>
321   </table>
322   </dd>
323 </dl>
324 <dl class="section return"><dt>Returns</dt><dd>memory pool ID for reference by other functions or NULL in case of error.</dd></dl>
325 <p>The function <b>osMemoryPoolNew</b> creates and initializes a memory pool object and returns the pointer to the memory pool object identifier or <span class="XML-Token">NULL</span> in case of an error. It can be safely called before the RTOS is started (call to <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#ga9ae2cc00f0d89d7b6a307bba942b5221">osKernelStart</a>), but not before it is initialized (call to <a class="el" href="group__CMSIS__RTOS__KernelCtrl.html#gae818f6611d25ba3140bede410a52d659">osKernelInitialize</a>).</p>
326 <p>The total amount of memory needed is at least <code>block_count * block_size</code>. Memory from the pool can only be allocated/freed in fixed portions of <code>block_size</code>.</p>
327 <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from Interrupt Service Routines.</dd></dl>
328 <p><b>Code</b> <b>Example</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span>                          <span class="comment">// CMSIS RTOS header file</span></div>
329 <div class="line"> </div>
330 <div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
331 <div class="line"><span class="comment"> *      Memory Pool creation &amp; usage</span></div>
332 <div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
333 <div class="line"> </div>
334 <div class="line"><span class="preprocessor">#define MEMPOOL_OBJECTS 16                      </span><span class="comment">// number of Memory Pool Objects</span></div>
335 <div class="line"> </div>
336 <div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{                                <span class="comment">// object data type</span></div>
337 <div class="line">  uint8_t Buf[32];</div>
338 <div class="line">  uint8_t Idx;</div>
339 <div class="line">} MEM_BLOCK_t;</div>
340 <div class="line"> </div>
341 <div class="line"><a class="code hl_typedef" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mpid_MemPool;                  <span class="comment">// memory pool id</span></div>
342 <div class="line"> </div>
343 <div class="line"><a class="code hl_typedef" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> tid_Thread_MemPool;                <span class="comment">// thread id</span></div>
344 <div class="line"> </div>
345 <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument);           <span class="comment">// thread function</span></div>
346 <div class="line"> </div>
347 <div class="line"><span class="keywordtype">int</span> Init_MemPool (<span class="keywordtype">void</span>) {</div>
348 <div class="line"> </div>
349 <div class="line">  mpid_MemPool = <a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>(MEMPOOL_OBJECTS, <span class="keyword">sizeof</span>(MEM_BLOCK_t), NULL);</div>
350 <div class="line">  <span class="keywordflow">if</span> (mpid_MemPool == NULL) {</div>
351 <div class="line">    ; <span class="comment">// MemPool object not created, handle failure</span></div>
352 <div class="line">  }</div>
353 <div class="line"> </div>
354 <div class="line">  tid_Thread_MemPool = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a>(Thread_MemPool, NULL, NULL);</div>
355 <div class="line">  <span class="keywordflow">if</span> (tid_Thread_MemPool == NULL) {</div>
356 <div class="line">    <span class="keywordflow">return</span>(-1);</div>
357 <div class="line">  }</div>
358 <div class="line"> </div>
359 <div class="line">  <span class="keywordflow">return</span>(0);</div>
360 <div class="line">}</div>
361 <div class="line"> </div>
362 <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument) {</div>
363 <div class="line">  MEM_BLOCK_t *pMem;</div>
364 <div class="line">  <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> status;</div>
365 <div class="line"> </div>
366 <div class="line">  <span class="keywordflow">while</span> (1) {</div>
367 <div class="line">    ; <span class="comment">// Insert thread code here...</span></div>
368 <div class="line"> </div>
369 <div class="line">    pMem = (MEM_BLOCK_t *)<a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a>(mpid_MemPool, 0U);  <span class="comment">// get Mem Block</span></div>
370 <div class="line">    <span class="keywordflow">if</span> (pMem != NULL) {                                         <span class="comment">// Mem Block was available</span></div>
371 <div class="line">      pMem-&gt;Buf[0] = 0x55U;                                     <span class="comment">// do some work...</span></div>
372 <div class="line">      pMem-&gt;Idx    = 0U;</div>
373 <div class="line"> </div>
374 <div class="line">      status = <a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a>(mpid_MemPool, pMem);            <span class="comment">// free mem block</span></div>
375 <div class="line">      <span class="keywordflow">switch</span> (status)  {</div>
376 <div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>:</div>
377 <div class="line">          <span class="keywordflow">break</span>;</div>
378 <div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eac24adca6a5d072c9f01c32178ba0d109">osErrorParameter</a>:</div>
379 <div class="line">          <span class="keywordflow">break</span>;</div>
380 <div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eaf1fac0240218e51eb30a13da2f8aae81">osErrorNoMemory</a>:</div>
381 <div class="line">          <span class="keywordflow">break</span>;</div>
382 <div class="line">        <span class="keywordflow">default</span>:</div>
383 <div class="line">          <span class="keywordflow">break</span>;</div>
384 <div class="line">      }</div>
385 <div class="line">    }</div>
386 <div class="line"> </div>
387 <div class="line">    <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a>();                                            <span class="comment">// suspend thread</span></div>
388 <div class="line">  }</div>
389 <div class="line">}</div>
390 <div class="ttc" id="acmsis__os2_8h_html"><div class="ttname"><a href="cmsis__os2_8h.html">cmsis_os2.h</a></div></div>
391 <div class="ttc" id="acmsis__os2_8h_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f"><div class="ttname"><a href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a></div><div class="ttdeci">@ osOK</div><div class="ttdoc">Operation completed successfully.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:247</div></div>
392 <div class="ttc" id="acmsis__os2_8h_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813eac24adca6a5d072c9f01c32178ba0d109"><div class="ttname"><a href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eac24adca6a5d072c9f01c32178ba0d109">osErrorParameter</a></div><div class="ttdeci">@ osErrorParameter</div><div class="ttdoc">Parameter error.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:251</div></div>
393 <div class="ttc" id="acmsis__os2_8h_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813eaf1fac0240218e51eb30a13da2f8aae81"><div class="ttname"><a href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eaf1fac0240218e51eb30a13da2f8aae81">osErrorNoMemory</a></div><div class="ttdeci">@ osErrorNoMemory</div><div class="ttdoc">System is out of memory: it was impossible to allocate or reserve memory for the operation.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:252</div></div>
394 <div class="ttc" id="agroup__CMSIS__RTOS__Definitions_html_ga6c0dbe6069e4e7f47bb4cd32ae2b813e"><div class="ttname"><a href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a></div><div class="ttdeci">osStatus_t</div><div class="ttdoc">Status code values returned by CMSIS-RTOS functions.</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:246</div></div>
395 <div class="ttc" id="agroup__CMSIS__RTOS__PoolMgmt_html_ga2e44473caf338266f56800960294f960"><div class="ttname"><a href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></div><div class="ttdeci">void * osMemoryPoolId_t</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:275</div></div>
396 <div class="ttc" id="agroup__CMSIS__RTOS__PoolMgmt_html_ga497ced5d72dc5cd405c4c418516220dc"><div class="ttname"><a href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a></div><div class="ttdeci">osMemoryPoolId_t osMemoryPoolNew(uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr)</div><div class="ttdoc">Create and Initialize a Memory Pool object.</div></div>
397 <div class="ttc" id="agroup__CMSIS__RTOS__PoolMgmt_html_ga8ead54e99ccb8f112356c88f99d38fbe"><div class="ttname"><a href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a></div><div class="ttdeci">void * osMemoryPoolAlloc(osMemoryPoolId_t mp_id, uint32_t timeout)</div><div class="ttdoc">Allocate a memory block from a Memory Pool.</div></div>
398 <div class="ttc" id="agroup__CMSIS__RTOS__PoolMgmt_html_gabb4f4560daa6d1f8c8789082ee186d16"><div class="ttname"><a href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a></div><div class="ttdeci">osStatus_t osMemoryPoolFree(osMemoryPoolId_t mp_id, void *block)</div><div class="ttdoc">Return an allocated memory block back to a Memory Pool.</div></div>
399 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_ga48d68b8666d99d28fa646ee1d2182b8f"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a></div><div class="ttdeci">osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr)</div><div class="ttdoc">Create a thread and add it to Active Threads.</div></div>
400 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gaa6c32fe2a3e0a2e01f212d55b02e51c7"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a></div><div class="ttdeci">void * osThreadId_t</div><div class="ttdef"><b>Definition:</b> cmsis_os2.h:260</div></div>
401 <div class="ttc" id="agroup__CMSIS__RTOS__ThreadMgmt_html_gad01c7ec26535b1de6b018bb9466720e2"><div class="ttname"><a href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a></div><div class="ttdeci">osStatus_t osThreadYield(void)</div><div class="ttdoc">Pass control to next thread that is in state READY.</div></div>
402 </div><!-- fragment --> 
403 </div>
404 </div>
405 <a id="gab414a1e138205a55820acfa277c8f386" name="gab414a1e138205a55820acfa277c8f386"></a>
406 <h2 class="memtitle"><span class="permalink"><a href="#gab414a1e138205a55820acfa277c8f386">&#9670;&#160;</a></span>osMemoryPoolGetName()</h2>
407
408 <div class="memitem">
409 <div class="memproto">
410       <table class="memname">
411         <tr>
412           <td class="memname">const char * osMemoryPoolGetName </td>
413           <td>(</td>
414           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
415           <td class="paramname"><em>mp_id</em></td><td>)</td>
416           <td></td>
417         </tr>
418       </table>
419 </div><div class="memdoc">
420 <dl class="params"><dt>Parameters</dt><dd>
421   <table class="params">
422     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
423   </table>
424   </dd>
425 </dl>
426 <dl class="section return"><dt>Returns</dt><dd>name as null-terminated string.</dd></dl>
427 <p>The function <b>osMemoryPoolGetName</b> returns the pointer to the name string of the memory pool identified by parameter <em>mp_id</em> or <span class="XML-Token">NULL</span> in case of an error.</p>
428 <dl class="section note"><dt>Note</dt><dd>This function may be called from Interrupt Service Routines. </dd></dl>
429
430 </div>
431 </div>
432 <a id="ga8ead54e99ccb8f112356c88f99d38fbe" name="ga8ead54e99ccb8f112356c88f99d38fbe"></a>
433 <h2 class="memtitle"><span class="permalink"><a href="#ga8ead54e99ccb8f112356c88f99d38fbe">&#9670;&#160;</a></span>osMemoryPoolAlloc()</h2>
434
435 <div class="memitem">
436 <div class="memproto">
437       <table class="memname">
438         <tr>
439           <td class="memname">void * osMemoryPoolAlloc </td>
440           <td>(</td>
441           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
442           <td class="paramname"><em>mp_id</em>, </td>
443         </tr>
444         <tr>
445           <td class="paramkey"></td>
446           <td></td>
447           <td class="paramtype">uint32_t&#160;</td>
448           <td class="paramname"><em>timeout</em>&#160;</td>
449         </tr>
450         <tr>
451           <td></td>
452           <td>)</td>
453           <td></td><td></td>
454         </tr>
455       </table>
456 </div><div class="memdoc">
457 <dl class="params"><dt>Parameters</dt><dd>
458   <table class="params">
459     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
460     <tr><td class="paramdir">[in]</td><td class="paramname">timeout</td><td>CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. </td></tr>
461   </table>
462   </dd>
463 </dl>
464 <dl class="section return"><dt>Returns</dt><dd>address of the allocated memory block or NULL in case of no memory is available.</dd></dl>
465 <p>The blocking function <b>osMemoryPoolAlloc</b> allocates the memory pool parameter <em>mp_id</em> and returns a pointer to the address of the allocated memory or <span class="XML-Token">0</span> in case of an error.</p>
466 <p>The parameter <em>timeout</em> specifies how long the system waits to allocate the memory. While the system waits, the thread that is calling this function is put into the <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">BLOCKED</a> state. The thread will become <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> as soon as at least one block of memory gets available.</p>
467 <p>The parameter timeout can have the following values:</p><ul>
468 <li>when <em>timeout</em> is <span class="XML-Token">0</span>, the function returns instantly (i.e. try semantics).</li>
469 <li>when <em>timeout</em> is set to <b>osWaitForever</b> the function will wait for an infinite time until the memory is allocated (i.e. wait semantics).</li>
470 <li>all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).</li>
471 </ul>
472 <p>The result is the pointer to the memory block allocated, or NULL if no memory is available.</p>
473 <dl class="section note"><dt>Note</dt><dd>It is in the responsibility of the user to respect the block size, i.e. not access memory beyond the blocks limit.</dd>
474 <dd>
475 May be called from Interrupt Service Routines if the parameter <em>timeout</em> is set to <span class="XML-Token">0</span>.</dd></dl>
476 <p><b>Code</b> <b>Example</b> </p>
477 <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
478
479 </div>
480 </div>
481 <a id="gabb4f4560daa6d1f8c8789082ee186d16" name="gabb4f4560daa6d1f8c8789082ee186d16"></a>
482 <h2 class="memtitle"><span class="permalink"><a href="#gabb4f4560daa6d1f8c8789082ee186d16">&#9670;&#160;</a></span>osMemoryPoolFree()</h2>
483
484 <div class="memitem">
485 <div class="memproto">
486       <table class="memname">
487         <tr>
488           <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolFree </td>
489           <td>(</td>
490           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
491           <td class="paramname"><em>mp_id</em>, </td>
492         </tr>
493         <tr>
494           <td class="paramkey"></td>
495           <td></td>
496           <td class="paramtype">void *&#160;</td>
497           <td class="paramname"><em>block</em>&#160;</td>
498         </tr>
499         <tr>
500           <td></td>
501           <td>)</td>
502           <td></td><td></td>
503         </tr>
504       </table>
505 </div><div class="memdoc">
506 <dl class="params"><dt>Parameters</dt><dd>
507   <table class="params">
508     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
509     <tr><td class="paramdir">[in]</td><td class="paramname">block</td><td>address of the allocated memory block to be returned to the memory pool. </td></tr>
510   </table>
511   </dd>
512 </dl>
513 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
514 <p>The function <b>osMemoryPoolFree</b> frees the memory pool block specified by the parameter <em>block</em> in the memory pool object specified by the parameter <em>mp_id</em>. The memory block is put back to the list of available blocks.</p>
515 <p>If another thread is waiting for memory to become available the thread is put to <a class="el" href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">READY</a> state.</p>
516 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
517 <li><em>osOK:</em> the memory has been freed.</li>
518 <li><em>osErrorParameter:</em> parameter <em>mp_id</em> is <span class="XML-Token">NULL</span> or invalid, <em>block</em> points to invalid memory.</li>
519 <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
520 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified memory pool.</li>
521 </ul>
522 <dl class="section note"><dt>Note</dt><dd><b>osMemoryPoolFree</b> may perform certain checks on the <em>block</em> pointer given. But using <b>osMemoryPoolFree</b> with a pointer other than one received from <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a> has <b>UNPREDICTED</b> behaviour.</dd>
523 <dd>
524 This function may be called from Interrupt Service Routines.</dd></dl>
525 <p><b>Code</b> <b>Example</b> </p>
526 <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
527
528 </div>
529 </div>
530 <a id="gad696e94bfbe28f0b6613f9303fdf6a37" name="gad696e94bfbe28f0b6613f9303fdf6a37"></a>
531 <h2 class="memtitle"><span class="permalink"><a href="#gad696e94bfbe28f0b6613f9303fdf6a37">&#9670;&#160;</a></span>osMemoryPoolGetCapacity()</h2>
532
533 <div class="memitem">
534 <div class="memproto">
535       <table class="memname">
536         <tr>
537           <td class="memname">uint32_t osMemoryPoolGetCapacity </td>
538           <td>(</td>
539           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
540           <td class="paramname"><em>mp_id</em></td><td>)</td>
541           <td></td>
542         </tr>
543       </table>
544 </div><div class="memdoc">
545 <dl class="params"><dt>Parameters</dt><dd>
546   <table class="params">
547     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
548   </table>
549   </dd>
550 </dl>
551 <dl class="section return"><dt>Returns</dt><dd>maximum number of memory blocks.</dd></dl>
552 <p>The function <b>osMemoryPoolGetCapacity</b> returns the maximum number of memory blocks in the memory pool object specified by parameter <em>mp_id</em> or <span class="XML-Token">0</span> in case of an error.</p>
553 <dl class="section note"><dt>Note</dt><dd>This function may be called from Interrupt Service Routines. </dd></dl>
554
555 </div>
556 </div>
557 <a id="gab2bf059b7fa7679c3cccdaeec60b6c0e" name="gab2bf059b7fa7679c3cccdaeec60b6c0e"></a>
558 <h2 class="memtitle"><span class="permalink"><a href="#gab2bf059b7fa7679c3cccdaeec60b6c0e">&#9670;&#160;</a></span>osMemoryPoolGetBlockSize()</h2>
559
560 <div class="memitem">
561 <div class="memproto">
562       <table class="memname">
563         <tr>
564           <td class="memname">uint32_t osMemoryPoolGetBlockSize </td>
565           <td>(</td>
566           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
567           <td class="paramname"><em>mp_id</em></td><td>)</td>
568           <td></td>
569         </tr>
570       </table>
571 </div><div class="memdoc">
572 <dl class="params"><dt>Parameters</dt><dd>
573   <table class="params">
574     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
575   </table>
576   </dd>
577 </dl>
578 <dl class="section return"><dt>Returns</dt><dd>memory block size in bytes.</dd></dl>
579 <p>The function <b>osMemoryPoolGetBlockSize</b> returns the memory block size in bytes in the memory pool object specified by parameter <em>mp_id</em> or <span class="XML-Token">0</span> in case of an error.</p>
580 <dl class="section note"><dt>Note</dt><dd>This function may be called from Interrupt Service Routines. </dd></dl>
581
582 </div>
583 </div>
584 <a id="ga958a9449bff8c95ce213de98eef5739d" name="ga958a9449bff8c95ce213de98eef5739d"></a>
585 <h2 class="memtitle"><span class="permalink"><a href="#ga958a9449bff8c95ce213de98eef5739d">&#9670;&#160;</a></span>osMemoryPoolGetCount()</h2>
586
587 <div class="memitem">
588 <div class="memproto">
589       <table class="memname">
590         <tr>
591           <td class="memname">uint32_t osMemoryPoolGetCount </td>
592           <td>(</td>
593           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
594           <td class="paramname"><em>mp_id</em></td><td>)</td>
595           <td></td>
596         </tr>
597       </table>
598 </div><div class="memdoc">
599 <dl class="params"><dt>Parameters</dt><dd>
600   <table class="params">
601     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
602   </table>
603   </dd>
604 </dl>
605 <dl class="section return"><dt>Returns</dt><dd>number of memory blocks used.</dd></dl>
606 <p>The function <b>osMemoryPoolGetCount</b> returns the number of memory blocks used in the memory pool object specified by parameter <em>mp_id</em> or <span class="XML-Token">0</span> in case of an error.</p>
607 <dl class="section note"><dt>Note</dt><dd>This function may be called from Interrupt Service Routines. </dd></dl>
608
609 </div>
610 </div>
611 <a id="ga0394cffa9479a7994e3b03c79c1cb909" name="ga0394cffa9479a7994e3b03c79c1cb909"></a>
612 <h2 class="memtitle"><span class="permalink"><a href="#ga0394cffa9479a7994e3b03c79c1cb909">&#9670;&#160;</a></span>osMemoryPoolGetSpace()</h2>
613
614 <div class="memitem">
615 <div class="memproto">
616       <table class="memname">
617         <tr>
618           <td class="memname">uint32_t osMemoryPoolGetSpace </td>
619           <td>(</td>
620           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
621           <td class="paramname"><em>mp_id</em></td><td>)</td>
622           <td></td>
623         </tr>
624       </table>
625 </div><div class="memdoc">
626 <dl class="params"><dt>Parameters</dt><dd>
627   <table class="params">
628     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
629   </table>
630   </dd>
631 </dl>
632 <dl class="section return"><dt>Returns</dt><dd>number of memory blocks available.</dd></dl>
633 <p>The function <b>osMemoryPoolGetSpace</b> returns the number of memory blocks available in the memory pool object specified by parameter <em>mp_id</em> or <span class="XML-Token">0</span> in case of an error.</p>
634 <dl class="section note"><dt>Note</dt><dd>This function may be called from Interrupt Service Routines. </dd></dl>
635
636 </div>
637 </div>
638 <a id="ga8c39e7e5cd2b9eda907466808e59d62e" name="ga8c39e7e5cd2b9eda907466808e59d62e"></a>
639 <h2 class="memtitle"><span class="permalink"><a href="#ga8c39e7e5cd2b9eda907466808e59d62e">&#9670;&#160;</a></span>osMemoryPoolDelete()</h2>
640
641 <div class="memitem">
642 <div class="memproto">
643       <table class="memname">
644         <tr>
645           <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolDelete </td>
646           <td>(</td>
647           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
648           <td class="paramname"><em>mp_id</em></td><td>)</td>
649           <td></td>
650         </tr>
651       </table>
652 </div><div class="memdoc">
653 <dl class="params"><dt>Parameters</dt><dd>
654   <table class="params">
655     <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
656   </table>
657   </dd>
658 </dl>
659 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
660 <p>The function <b>osMemoryPoolDelete</b> deletes a memory pool object specified by parameter <em>mp_id</em>. It releases internal memory obtained for memory pool handling. After this call, the <em>mp_id</em> is no longer valid and cannot be used. The memory pool may be created again using the function <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>.</p>
661 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
662 <li><em>osOK:</em> the memory pool object has been deleted.</li>
663 <li><em>osErrorParameter:</em> parameter <em>mp_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
664 <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
665 <li><em>osErrorISR:</em> <b>osMemoryPoolDelete</b> cannot be called from interrupt service routines.</li>
666 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified memory pool.</li>
667 </ul>
668 <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from Interrupt Service Routines. </dd></dl>
669
670 </div>
671 </div>
672 </div><!-- contents -->
673 </div><!-- doc-content -->
674 <!-- start footer part -->
675 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
676   <ul>
677     <li class="footer">
678       <script type="text/javascript">
679         <!--
680         writeFooter.call(this);
681         //-->
682       </script> 
683     </li>
684   </ul>
685 </div>
686 </body>
687 </html>