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">
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 <script type="text/javascript" src="jquery.js"></script>
11 <script type="text/javascript" src="dynsections.js"></script>
12 <script type="text/javascript" src="tabs.js"></script>
13 <script type="text/javascript" src="footer.js"></script>
14 <script type="text/javascript" src="navtree.js"></script>
15 <link href="navtree.css" rel="stylesheet" type="text/css"/>
16 <script type="text/javascript" src="resize.js"></script>
17 <script type="text/javascript" src="navtreedata.js"></script>
18 <script type="text/javascript" src="navtree.js"></script>
19 <link href="search/search.css" rel="stylesheet" type="text/css"/>
20 <script type="text/javascript" src="search/searchdata.js"></script>
21 <script type="text/javascript" src="search/search.js"></script>
22 <script type="text/javascript">
23 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
24 $(document).ready(function() { init_search(); });
27 <script type="text/javascript" src="darkmode_toggle.js"></script>
28 <link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
29 <link href="extra_navtree.css" rel="stylesheet" type="text/css"/>
30 <link href="extra_search.css" rel="stylesheet" type="text/css"/>
31 <link href="extra_tabs.css" rel="stylesheet" type="text/css"/>
32 <link href="version.css" rel="stylesheet" type="text/css"/>
33 <script type="text/javascript" src="../../version.js"></script>
36 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
38 <table cellspacing="0" cellpadding="0">
40 <tr style="height: 55px;">
41 <td id="projectlogo" style="padding: 1.5em;"><img alt="Logo" src="cmsis_logo_white_small.png"/></td>
42 <td style="padding-left: 1em; padding-bottom: 1em;padding-top: 1em;">
43 <div id="projectname">CMSIS-RTOS2
44  <span id="projectnumber"><script type="text/javascript">
46 writeHeader.call(this);
47 writeVersionDropdown.call(this, "CMSIS-RTOS2");
52 <div id="projectbrief">Real-Time Operating System API</div>
54 <td> <div id="MSearchBox" class="MSearchBoxInactive">
56 <span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()"> </span>
57 <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
58 onfocus="searchBox.OnSearchFieldFocus(true)"
59 onblur="searchBox.OnSearchFieldFocus(false)"
60 onkeyup="searchBox.OnSearchFieldChange(event)"/>
61 </span><span class="right">
62 <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
66 <!--END !PROJECT_NAME-->
71 <!-- end header part -->
72 <div id="CMSISnav" class="tabs1">
74 <script type="text/javascript">
75 writeComponentTabs.call(this);
79 <script type="text/javascript">
80 writeSubComponentTabs.call(this);
82 <!-- Generated by Doxygen 1.9.6 -->
83 <script type="text/javascript">
84 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
85 var searchBox = new SearchBox("searchBox", "search/",'.html');
89 <div id="side-nav" class="ui-resizable side-nav-resizable">
91 <div id="nav-tree-contents">
92 <div id="nav-sync" class="sync"></div>
95 <div id="splitbar" style="-moz-user-select:none;"
96 class="ui-resizable-handle">
99 <script type="text/javascript">
100 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
101 $(document).ready(function(){initNavTree('group__CMSIS__RTOS__PoolMgmt.html',''); initResizable(); });
104 <div id="doc-content">
105 <!-- window showing the filter options -->
106 <div id="MSearchSelectWindow"
107 onmouseover="return searchBox.OnSearchSelectShow()"
108 onmouseout="return searchBox.OnSearchSelectHide()"
109 onkeydown="return searchBox.OnSearchSelectKey(event)">
112 <!-- iframe showing the search results (closed by default) -->
113 <div id="MSearchResultsWindow">
114 <div id="MSearchResults">
117 <div id="SRResults"></div>
118 <div class="SRStatus" id="Loading">Loading...</div>
119 <div class="SRStatus" id="Searching">Searching...</div>
120 <div class="SRStatus" id="NoMatches">No Matches</div>
127 <div class="summary">
128 <a href="#nested-classes">Data Structures</a> |
129 <a href="#typedef-members">Typedefs</a> |
130 <a href="#func-members">Functions</a> </div>
131 <div class="headertitle"><div class="title">Memory Pool<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS2 API</a></div></div></div>
133 <div class="contents">
135 <p>Manage thread-safe fixed-size blocks of dynamic memory.
136 <a href="#details">More...</a></p>
137 <table class="memberdecls">
138 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
139 Data Structures</h2></td></tr>
140 <tr class="memitem:structosMemoryPoolAttr__t"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a></td></tr>
141 <tr class="memdesc:structosMemoryPoolAttr__t"><td class="mdescLeft"> </td><td class="mdescRight">Attributes structure for memory pool. <a href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">More...</a><br /></td></tr>
142 <tr class="separator:structosMemoryPoolAttr__t"><td class="memSeparator" colspan="2"> </td></tr>
143 </table><table class="memberdecls">
144 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
145 Typedefs</h2></td></tr>
146 <tr class="memitem:ga2e44473caf338266f56800960294f960"><td class="memItemLeft" align="right" valign="top">typedef void * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></td></tr>
147 <tr class="separator:ga2e44473caf338266f56800960294f960"><td class="memSeparator" colspan="2"> </td></tr>
148 </table><table class="memberdecls">
149 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
150 Functions</h2></td></tr>
151 <tr class="memitem:ga497ced5d72dc5cd405c4c418516220dc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </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>
152 <tr class="memdesc:ga497ced5d72dc5cd405c4c418516220dc"><td class="mdescLeft"> </td><td class="mdescRight">Create and Initialize a Memory Pool object. <br /></td></tr>
153 <tr class="separator:ga497ced5d72dc5cd405c4c418516220dc"><td class="memSeparator" colspan="2"> </td></tr>
154 <tr class="memitem:gab414a1e138205a55820acfa277c8f386"><td class="memItemLeft" align="right" valign="top">const char * </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>
155 <tr class="memdesc:gab414a1e138205a55820acfa277c8f386"><td class="mdescLeft"> </td><td class="mdescRight">Get name of a Memory Pool object. <br /></td></tr>
156 <tr class="separator:gab414a1e138205a55820acfa277c8f386"><td class="memSeparator" colspan="2"> </td></tr>
157 <tr class="memitem:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="memItemLeft" align="right" valign="top">void * </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>
158 <tr class="memdesc:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="mdescLeft"> </td><td class="mdescRight">Allocate a memory block from a Memory Pool. <br /></td></tr>
159 <tr class="separator:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="memSeparator" colspan="2"> </td></tr>
160 <tr class="memitem:gabb4f4560daa6d1f8c8789082ee186d16"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </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>
161 <tr class="memdesc:gabb4f4560daa6d1f8c8789082ee186d16"><td class="mdescLeft"> </td><td class="mdescRight">Return an allocated memory block back to a Memory Pool. <br /></td></tr>
162 <tr class="separator:gabb4f4560daa6d1f8c8789082ee186d16"><td class="memSeparator" colspan="2"> </td></tr>
163 <tr class="memitem:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="memItemLeft" align="right" valign="top">uint32_t </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>
164 <tr class="memdesc:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="mdescLeft"> </td><td class="mdescRight">Get maximum number of memory blocks in a Memory Pool. <br /></td></tr>
165 <tr class="separator:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="memSeparator" colspan="2"> </td></tr>
166 <tr class="memitem:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="memItemLeft" align="right" valign="top">uint32_t </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>
167 <tr class="memdesc:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="mdescLeft"> </td><td class="mdescRight">Get memory block size in a Memory Pool. <br /></td></tr>
168 <tr class="separator:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="memSeparator" colspan="2"> </td></tr>
169 <tr class="memitem:ga958a9449bff8c95ce213de98eef5739d"><td class="memItemLeft" align="right" valign="top">uint32_t </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>
170 <tr class="memdesc:ga958a9449bff8c95ce213de98eef5739d"><td class="mdescLeft"> </td><td class="mdescRight">Get number of memory blocks used in a Memory Pool. <br /></td></tr>
171 <tr class="separator:ga958a9449bff8c95ce213de98eef5739d"><td class="memSeparator" colspan="2"> </td></tr>
172 <tr class="memitem:ga0394cffa9479a7994e3b03c79c1cb909"><td class="memItemLeft" align="right" valign="top">uint32_t </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>
173 <tr class="memdesc:ga0394cffa9479a7994e3b03c79c1cb909"><td class="mdescLeft"> </td><td class="mdescRight">Get number of memory blocks available in a Memory Pool. <br /></td></tr>
174 <tr class="separator:ga0394cffa9479a7994e3b03c79c1cb909"><td class="memSeparator" colspan="2"> </td></tr>
175 <tr class="memitem:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> </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>
176 <tr class="memdesc:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="mdescLeft"> </td><td class="mdescRight">Delete a Memory Pool object. <br /></td></tr>
177 <tr class="separator:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="memSeparator" colspan="2"> </td></tr>
179 <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
180 <p>Manage thread-safe fixed-size blocks of dynamic memory. </p>
181 <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>
182 <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>
184 <img src="mempool.png" alt=""/>
185 <div class="caption">
186 CMSIS-RTOS Memory Pools</div></div>
187 <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>
188 <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>
189 <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 <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
190 <hr/><h2 class="groupheader">Data Structure Documentation</h2>
191 <a name="structosMemoryPoolAttr__t" id="structosMemoryPoolAttr__t"></a>
192 <h2 class="memtitle"><span class="permalink"><a href="#structosMemoryPoolAttr__t">◆ </a></span>osMemoryPoolAttr_t</h2>
194 <div class="memitem">
195 <div class="memproto">
196 <table class="memname">
198 <td class="memname">struct osMemoryPoolAttr_t</td>
201 </div><div class="memdoc">
202 <div class="textblock"><p>Attributes structure for memory pool. </p>
203 <p>Attributes to configure a memory pool.</p>
204 <p>Refer to <a class="el" href="usingOS2.html#CMSIS_RTOS_MemoryMgmt">Memory Management</a> for details about usage of</p><ul>
205 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a1e100dc33d403841ed3c344e3397868e" title="memory for control block">osMemoryPoolAttr_t::cb_mem</a></li>
206 <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>
207 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a5799465cca9c71c5587ceb0986f5b06a" title="memory for data storage">osMemoryPoolAttr_t::mp_mem</a></li>
208 <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>
210 </div><table class="fieldtable">
211 <tr><th colspan="3">Data Fields</th></tr>
212 <tr><td class="fieldtype">
213 <a id="ab74e6bf80237ddc4109968cedc58c151" name="ab74e6bf80237ddc4109968cedc58c151"></a>const char *</td>
214 <td class="fieldname">
216 <td class="fielddoc">
217 name of the memory pool <p>Pointer to a string with a human readable name of the memory pool object.<br />
218 Default: <span class="XML-Token">NULL</span>. </p>
220 <tr><td class="fieldtype">
221 <a id="a6e93b49cb79c12f768d72580c7731f30" name="a6e93b49cb79c12f768d72580c7731f30"></a>uint32_t</td>
222 <td class="fieldname">
224 <td class="fielddoc">
225 attribute bits <p>Reserved for future use (set to '0').<br />
226 Default: <span class="XML-Token">0</span>. </p>
228 <tr><td class="fieldtype">
229 <a id="a1e100dc33d403841ed3c344e3397868e" name="a1e100dc33d403841ed3c344e3397868e"></a>void *</td>
230 <td class="fieldname">
232 <td class="fielddoc">
233 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 />
234 Default: <span class="XML-Token">NULL</span> (uses kernel memory management). </p>
236 <tr><td class="fieldtype">
237 <a id="aa55a4335d12dc2785dc00fdc292d1159" name="aa55a4335d12dc2785dc00fdc292d1159"></a>uint32_t</td>
238 <td class="fieldname">
240 <td class="fielddoc">
241 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>
243 <tr><td class="fieldtype">
244 <a id="a5799465cca9c71c5587ceb0986f5b06a" name="a5799465cca9c71c5587ceb0986f5b06a"></a>void *</td>
245 <td class="fieldname">
247 <td class="fielddoc">
248 memory for data storage <p>Pointer to a memory location for the data of the memory pool object.<br />
249 Default: <span class="XML-Token">NULL</span>. </p>
251 <tr><td class="fieldtype">
252 <a id="a66c26015c0ac8e88a4ad907c120aee4f" name="a66c26015c0ac8e88a4ad907c120aee4f"></a>uint32_t</td>
253 <td class="fieldname">
255 <td class="fielddoc">
256 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>
262 <h2 class="groupheader">Typedef Documentation</h2>
263 <a id="ga2e44473caf338266f56800960294f960" name="ga2e44473caf338266f56800960294f960"></a>
264 <h2 class="memtitle"><span class="permalink"><a href="#ga2e44473caf338266f56800960294f960">◆ </a></span>osMemoryPoolId_t</h2>
266 <div class="memitem">
267 <div class="memproto">
268 <table class="memname">
270 <td class="memname"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></td>
273 </div><div class="memdoc">
274 <p>Memory Pool ID identifies the memory pool.</p>
275 <p>Returned by:</p><ul>
276 <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a> </li>
281 <h2 class="groupheader">Function Documentation</h2>
282 <a id="ga497ced5d72dc5cd405c4c418516220dc" name="ga497ced5d72dc5cd405c4c418516220dc"></a>
283 <h2 class="memtitle"><span class="permalink"><a href="#ga497ced5d72dc5cd405c4c418516220dc">◆ </a></span>osMemoryPoolNew()</h2>
285 <div class="memitem">
286 <div class="memproto">
287 <table class="memname">
289 <td class="memname"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> osMemoryPoolNew </td>
291 <td class="paramtype">uint32_t </td>
292 <td class="paramname"><em>block_count</em>, </td>
295 <td class="paramkey"></td>
297 <td class="paramtype">uint32_t </td>
298 <td class="paramname"><em>block_size</em>, </td>
301 <td class="paramkey"></td>
303 <td class="paramtype">const <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a> * </td>
304 <td class="paramname"><em>attr</em> </td>
312 </div><div class="memdoc">
314 <p>Create and Initialize a Memory Pool object. </p>
315 <dl class="params"><dt>Parameters</dt><dd>
316 <table class="params">
317 <tr><td class="paramdir">[in]</td><td class="paramname">block_count</td><td>maximum number of memory blocks in memory pool. </td></tr>
318 <tr><td class="paramdir">[in]</td><td class="paramname">block_size</td><td>memory block size in bytes. </td></tr>
319 <tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>memory pool attributes; NULL: default values. </td></tr>
323 <dl class="section return"><dt>Returns</dt><dd>memory pool ID for reference by other functions or NULL in case of error.</dd></dl>
324 <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>
325 <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>
326 <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
327 <p><b>Code</b> <b>Example</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include "cmsis_os2.h"</span> <span class="comment">// CMSIS RTOS header file</span></div>
328 <div class="line"> </div>
329 <div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
330 <div class="line"><span class="comment"> * Memory Pool creation & usage</span></div>
331 <div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
332 <div class="line"> </div>
333 <div class="line"><span class="preprocessor">#define MEMPOOL_OBJECTS 16 </span><span class="comment">// number of Memory Pool Objects</span></div>
334 <div class="line"> </div>
335 <div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{ <span class="comment">// object data type</span></div>
336 <div class="line"> uint8_t Buf[32];</div>
337 <div class="line"> uint8_t Idx;</div>
338 <div class="line">} MEM_BLOCK_t;</div>
339 <div class="line"> </div>
340 <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>
341 <div class="line"> </div>
342 <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>
343 <div class="line"> </div>
344 <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument); <span class="comment">// thread function</span></div>
345 <div class="line"> </div>
346 <div class="line"><span class="keywordtype">int</span> Init_MemPool (<span class="keywordtype">void</span>) {</div>
347 <div class="line"> </div>
348 <div class="line"> mpid_MemPool = <a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc" title="Create and Initialize a Memory Pool object.">osMemoryPoolNew</a>(MEMPOOL_OBJECTS, <span class="keyword">sizeof</span>(MEM_BLOCK_t), NULL);</div>
349 <div class="line"> <span class="keywordflow">if</span> (mpid_MemPool == NULL) {</div>
350 <div class="line"> ; <span class="comment">// MemPool object not created, handle failure</span></div>
351 <div class="line"> }</div>
352 <div class="line"> </div>
353 <div class="line"> tid_Thread_MemPool = <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f" title="Create a thread and add it to Active Threads.">osThreadNew</a>(Thread_MemPool, NULL, NULL);</div>
354 <div class="line"> <span class="keywordflow">if</span> (tid_Thread_MemPool == NULL) {</div>
355 <div class="line"> <span class="keywordflow">return</span>(-1);</div>
356 <div class="line"> }</div>
357 <div class="line"> </div>
358 <div class="line"> <span class="keywordflow">return</span>(0);</div>
359 <div class="line">}</div>
360 <div class="line"> </div>
361 <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument) {</div>
362 <div class="line"> MEM_BLOCK_t *pMem;</div>
363 <div class="line"> <a class="code hl_enumeration" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e" title="Status code values returned by CMSIS-RTOS functions.">osStatus_t</a> status;</div>
364 <div class="line"> </div>
365 <div class="line"> <span class="keywordflow">while</span> (1) {</div>
366 <div class="line"> ; <span class="comment">// Insert thread code here...</span></div>
367 <div class="line"> </div>
368 <div class="line"> pMem = (MEM_BLOCK_t *)<a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe" title="Allocate a memory block from a Memory Pool.">osMemoryPoolAlloc</a>(mpid_MemPool, 0U); <span class="comment">// get Mem Block</span></div>
369 <div class="line"> <span class="keywordflow">if</span> (pMem != NULL) { <span class="comment">// Mem Block was available</span></div>
370 <div class="line"> pMem->Buf[0] = 0x55U; <span class="comment">// do some work...</span></div>
371 <div class="line"> pMem->Idx = 0U;</div>
372 <div class="line"> </div>
373 <div class="line"> status = <a class="code hl_function" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16" title="Return an allocated memory block back to a Memory Pool.">osMemoryPoolFree</a>(mpid_MemPool, pMem); <span class="comment">// free mem block</span></div>
374 <div class="line"> <span class="keywordflow">switch</span> (status) {</div>
375 <div class="line"> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__CMSIS__RTOS__Definitions.html#gga6c0dbe6069e4e7f47bb4cd32ae2b813eab17c65ad8b5bae759882b41c5bf35cda" title="Operation completed successfully.">osOK</a>:</div>
376 <div class="line"> <span class="keywordflow">break</span>;</div>
377 <div class="line"> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__CMSIS__RTOS__Definitions.html#gga6c0dbe6069e4e7f47bb4cd32ae2b813ea146cdcbc5c2b6f43e196294dbc59e12c" title="Parameter error.">osErrorParameter</a>:</div>
378 <div class="line"> <span class="keywordflow">break</span>;</div>
379 <div class="line"> <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__CMSIS__RTOS__Definitions.html#gga6c0dbe6069e4e7f47bb4cd32ae2b813ea1bccee013c5725778b750a54c4f9e57d" title="System is out of memory: it was impossible to allocate or reserve memory for the operation.">osErrorNoMemory</a>:</div>
380 <div class="line"> <span class="keywordflow">break</span>;</div>
381 <div class="line"> <span class="keywordflow">default</span>:</div>
382 <div class="line"> <span class="keywordflow">break</span>;</div>
383 <div class="line"> }</div>
384 <div class="line"> }</div>
385 <div class="line"> </div>
386 <div class="line"> <a class="code hl_function" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2" title="Pass control to next thread that is in state READY.">osThreadYield</a>(); <span class="comment">// suspend thread</span></div>
387 <div class="line"> }</div>
388 <div class="line">}</div>
389 </div><!-- fragment -->
392 <a id="gab414a1e138205a55820acfa277c8f386" name="gab414a1e138205a55820acfa277c8f386"></a>
393 <h2 class="memtitle"><span class="permalink"><a href="#gab414a1e138205a55820acfa277c8f386">◆ </a></span>osMemoryPoolGetName()</h2>
395 <div class="memitem">
396 <div class="memproto">
397 <table class="memname">
399 <td class="memname">const char * osMemoryPoolGetName </td>
401 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </td>
402 <td class="paramname"><em>mp_id</em></td><td>)</td>
406 </div><div class="memdoc">
408 <p>Get name of a Memory Pool object. </p>
409 <dl class="params"><dt>Parameters</dt><dd>
410 <table class="params">
411 <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>
415 <dl class="section return"><dt>Returns</dt><dd>name as null-terminated string.</dd></dl>
416 <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>
417 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
421 <a id="ga8ead54e99ccb8f112356c88f99d38fbe" name="ga8ead54e99ccb8f112356c88f99d38fbe"></a>
422 <h2 class="memtitle"><span class="permalink"><a href="#ga8ead54e99ccb8f112356c88f99d38fbe">◆ </a></span>osMemoryPoolAlloc()</h2>
424 <div class="memitem">
425 <div class="memproto">
426 <table class="memname">
428 <td class="memname">void * osMemoryPoolAlloc </td>
430 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </td>
431 <td class="paramname"><em>mp_id</em>, </td>
434 <td class="paramkey"></td>
436 <td class="paramtype">uint32_t </td>
437 <td class="paramname"><em>timeout</em> </td>
445 </div><div class="memdoc">
447 <p>Allocate a memory block from a Memory Pool. </p>
448 <dl class="params"><dt>Parameters</dt><dd>
449 <table class="params">
450 <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>
451 <tr><td class="paramdir">[in]</td><td class="paramname">timeout</td><td><a class="el" href="usingOS2.html#CMSIS_RTOS_TimeOutValue">Timeout Values</a> or 0 in case of no time-out. </td></tr>
455 <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>
456 <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>
457 <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>
458 <p>The parameter <a class="el" href="usingOS2.html#CMSIS_RTOS_TimeOutValue">timeout</a> can have the following values:</p><ul>
459 <li>when <em>timeout</em> is <span class="XML-Token">0</span>, the function returns instantly (i.e. try semantics).</li>
460 <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>
461 <li>all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).</li>
463 <p>The result is the pointer to the memory block allocated, or NULL if no memory is available.</p>
464 <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>
466 May be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a> if the parameter <em>timeout</em> is set to <span class="XML-Token">0</span>.</dd></dl>
467 <p><b>Code</b> <b>Example</b> </p>
468 <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
472 <a id="gabb4f4560daa6d1f8c8789082ee186d16" name="gabb4f4560daa6d1f8c8789082ee186d16"></a>
473 <h2 class="memtitle"><span class="permalink"><a href="#gabb4f4560daa6d1f8c8789082ee186d16">◆ </a></span>osMemoryPoolFree()</h2>
475 <div class="memitem">
476 <div class="memproto">
477 <table class="memname">
479 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolFree </td>
481 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </td>
482 <td class="paramname"><em>mp_id</em>, </td>
485 <td class="paramkey"></td>
487 <td class="paramtype">void * </td>
488 <td class="paramname"><em>block</em> </td>
496 </div><div class="memdoc">
498 <p>Return an allocated memory block back to a Memory Pool. </p>
499 <dl class="params"><dt>Parameters</dt><dd>
500 <table class="params">
501 <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>
502 <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>
506 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
507 <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>
508 <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>
509 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
510 <li><em>osOK:</em> the memory has been freed.</li>
511 <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>
512 <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
513 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified memory pool.</li>
515 <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>
517 This function may be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
518 <p><b>Code</b> <b>Example</b> </p>
519 <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
523 <a id="gad696e94bfbe28f0b6613f9303fdf6a37" name="gad696e94bfbe28f0b6613f9303fdf6a37"></a>
524 <h2 class="memtitle"><span class="permalink"><a href="#gad696e94bfbe28f0b6613f9303fdf6a37">◆ </a></span>osMemoryPoolGetCapacity()</h2>
526 <div class="memitem">
527 <div class="memproto">
528 <table class="memname">
530 <td class="memname">uint32_t osMemoryPoolGetCapacity </td>
532 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </td>
533 <td class="paramname"><em>mp_id</em></td><td>)</td>
537 </div><div class="memdoc">
539 <p>Get maximum number of memory blocks in a Memory Pool. </p>
540 <dl class="params"><dt>Parameters</dt><dd>
541 <table class="params">
542 <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>
546 <dl class="section return"><dt>Returns</dt><dd>maximum number of memory blocks.</dd></dl>
547 <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>
548 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
552 <a id="gab2bf059b7fa7679c3cccdaeec60b6c0e" name="gab2bf059b7fa7679c3cccdaeec60b6c0e"></a>
553 <h2 class="memtitle"><span class="permalink"><a href="#gab2bf059b7fa7679c3cccdaeec60b6c0e">◆ </a></span>osMemoryPoolGetBlockSize()</h2>
555 <div class="memitem">
556 <div class="memproto">
557 <table class="memname">
559 <td class="memname">uint32_t osMemoryPoolGetBlockSize </td>
561 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </td>
562 <td class="paramname"><em>mp_id</em></td><td>)</td>
566 </div><div class="memdoc">
568 <p>Get memory block size in a Memory Pool. </p>
569 <dl class="params"><dt>Parameters</dt><dd>
570 <table class="params">
571 <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 <dl class="section return"><dt>Returns</dt><dd>memory block size in bytes.</dd></dl>
576 <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>
577 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
581 <a id="ga958a9449bff8c95ce213de98eef5739d" name="ga958a9449bff8c95ce213de98eef5739d"></a>
582 <h2 class="memtitle"><span class="permalink"><a href="#ga958a9449bff8c95ce213de98eef5739d">◆ </a></span>osMemoryPoolGetCount()</h2>
584 <div class="memitem">
585 <div class="memproto">
586 <table class="memname">
588 <td class="memname">uint32_t osMemoryPoolGetCount </td>
590 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </td>
591 <td class="paramname"><em>mp_id</em></td><td>)</td>
595 </div><div class="memdoc">
597 <p>Get number of memory blocks used in a Memory Pool. </p>
598 <dl class="params"><dt>Parameters</dt><dd>
599 <table class="params">
600 <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>
604 <dl class="section return"><dt>Returns</dt><dd>number of memory blocks used.</dd></dl>
605 <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>
606 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
610 <a id="ga0394cffa9479a7994e3b03c79c1cb909" name="ga0394cffa9479a7994e3b03c79c1cb909"></a>
611 <h2 class="memtitle"><span class="permalink"><a href="#ga0394cffa9479a7994e3b03c79c1cb909">◆ </a></span>osMemoryPoolGetSpace()</h2>
613 <div class="memitem">
614 <div class="memproto">
615 <table class="memname">
617 <td class="memname">uint32_t osMemoryPoolGetSpace </td>
619 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </td>
620 <td class="paramname"><em>mp_id</em></td><td>)</td>
624 </div><div class="memdoc">
626 <p>Get number of memory blocks available in a Memory Pool. </p>
627 <dl class="params"><dt>Parameters</dt><dd>
628 <table class="params">
629 <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>
633 <dl class="section return"><dt>Returns</dt><dd>number of memory blocks available.</dd></dl>
634 <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>
635 <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
639 <a id="ga8c39e7e5cd2b9eda907466808e59d62e" name="ga8c39e7e5cd2b9eda907466808e59d62e"></a>
640 <h2 class="memtitle"><span class="permalink"><a href="#ga8c39e7e5cd2b9eda907466808e59d62e">◆ </a></span>osMemoryPoolDelete()</h2>
642 <div class="memitem">
643 <div class="memproto">
644 <table class="memname">
646 <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolDelete </td>
648 <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> </td>
649 <td class="paramname"><em>mp_id</em></td><td>)</td>
653 </div><div class="memdoc">
655 <p>Delete a Memory Pool object. </p>
656 <dl class="params"><dt>Parameters</dt><dd>
657 <table class="params">
658 <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>
662 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
663 <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>
664 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
665 <li><em>osOK:</em> the memory pool object has been deleted.</li>
666 <li><em>osErrorParameter:</em> parameter <em>mp_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
667 <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
668 <li><em>osErrorISR:</em> <b>osMemoryPoolDelete</b> cannot be called from interrupt service routines.</li>
669 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified memory pool.</li>
671 <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
675 </div><!-- contents -->
676 </div><!-- doc-content -->
677 <!-- start footer part -->
678 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
681 <script type="text/javascript">
683 writeFooter.call(this);