]> 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);
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-RTOS2 API</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>Manage thread-safe fixed-size blocks of dynamic memory. </p>
184 <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>
185 <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>
186 <div class="image">
187 <img src="mempool.png" alt=""/>
188 <div class="caption">
189 CMSIS-RTOS Memory Pools</div></div>
190 <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>
191 <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>
192 <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>
193 <hr/><h2 class="groupheader">Data Structure Documentation</h2>
194 <a name="structosMemoryPoolAttr__t" id="structosMemoryPoolAttr__t"></a>
195 <h2 class="memtitle"><span class="permalink"><a href="#structosMemoryPoolAttr__t">&#9670;&#160;</a></span>osMemoryPoolAttr_t</h2>
196
197 <div class="memitem">
198 <div class="memproto">
199       <table class="memname">
200         <tr>
201           <td class="memname">struct osMemoryPoolAttr_t</td>
202         </tr>
203       </table>
204 </div><div class="memdoc">
205 <div class="textblock"><p>Attributes structure for memory pool. </p>
206 <p>Attributes to configure a memory pool.</p>
207 <p>Refer to <a class="el" href="usingOS2.html#CMSIS_RTOS_MemoryMgmt">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
317 <p>Create and Initialize a Memory Pool object. </p>
318 <dl class="params"><dt>Parameters</dt><dd>
319   <table class="params">
320     <tr><td class="paramdir">[in]</td><td class="paramname">block_count</td><td>maximum number of memory blocks in memory pool. </td></tr>
321     <tr><td class="paramdir">[in]</td><td class="paramname">block_size</td><td>memory block size in bytes. </td></tr>
322     <tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>memory pool attributes; NULL: default values. </td></tr>
323   </table>
324   </dd>
325 </dl>
326 <dl class="section return"><dt>Returns</dt><dd>memory pool ID for reference by other functions or NULL in case of error.</dd></dl>
327 <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>
328 <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>
329 <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>
330 <p><b>Code</b> <b>Example</b> </p><div class="fragment"><div class="line"><span class="preprocessor">#include &quot;cmsis_os2.h&quot;</span>                          <span class="comment">// CMSIS RTOS header file</span></div>
331 <div class="line"> </div>
332 <div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
333 <div class="line"><span class="comment"> *      Memory Pool creation &amp; usage</span></div>
334 <div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
335 <div class="line"> </div>
336 <div class="line"><span class="preprocessor">#define MEMPOOL_OBJECTS 16                      </span><span class="comment">// number of Memory Pool Objects</span></div>
337 <div class="line"> </div>
338 <div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{                                <span class="comment">// object data type</span></div>
339 <div class="line">  uint8_t Buf[32];</div>
340 <div class="line">  uint8_t Idx;</div>
341 <div class="line">} MEM_BLOCK_t;</div>
342 <div class="line"> </div>
343 <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>
344 <div class="line"> </div>
345 <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>
346 <div class="line"> </div>
347 <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument);           <span class="comment">// thread function</span></div>
348 <div class="line"> </div>
349 <div class="line"><span class="keywordtype">int</span> Init_MemPool (<span class="keywordtype">void</span>) {</div>
350 <div class="line"> </div>
351 <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>
352 <div class="line">  <span class="keywordflow">if</span> (mpid_MemPool == NULL) {</div>
353 <div class="line">    ; <span class="comment">// MemPool object not created, handle failure</span></div>
354 <div class="line">  }</div>
355 <div class="line"> </div>
356 <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>
357 <div class="line">  <span class="keywordflow">if</span> (tid_Thread_MemPool == NULL) {</div>
358 <div class="line">    <span class="keywordflow">return</span>(-1);</div>
359 <div class="line">  }</div>
360 <div class="line"> </div>
361 <div class="line">  <span class="keywordflow">return</span>(0);</div>
362 <div class="line">}</div>
363 <div class="line"> </div>
364 <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument) {</div>
365 <div class="line">  MEM_BLOCK_t *pMem;</div>
366 <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>
367 <div class="line"> </div>
368 <div class="line">  <span class="keywordflow">while</span> (1) {</div>
369 <div class="line">    ; <span class="comment">// Insert thread code here...</span></div>
370 <div class="line"> </div>
371 <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>
372 <div class="line">    <span class="keywordflow">if</span> (pMem != NULL) {                                         <span class="comment">// Mem Block was available</span></div>
373 <div class="line">      pMem-&gt;Buf[0] = 0x55U;                                     <span class="comment">// do some work...</span></div>
374 <div class="line">      pMem-&gt;Idx    = 0U;</div>
375 <div class="line"> </div>
376 <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>
377 <div class="line">      <span class="keywordflow">switch</span> (status)  {</div>
378 <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>
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="group__CMSIS__RTOS__Definitions.html#gga6c0dbe6069e4e7f47bb4cd32ae2b813ea146cdcbc5c2b6f43e196294dbc59e12c" title="Parameter error.">osErrorParameter</a>:</div>
381 <div class="line">          <span class="keywordflow">break</span>;</div>
382 <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>
383 <div class="line">          <span class="keywordflow">break</span>;</div>
384 <div class="line">        <span class="keywordflow">default</span>:</div>
385 <div class="line">          <span class="keywordflow">break</span>;</div>
386 <div class="line">      }</div>
387 <div class="line">    }</div>
388 <div class="line"> </div>
389 <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>
390 <div class="line">  }</div>
391 <div class="line">}</div>
392 </div><!-- fragment --> 
393 </div>
394 </div>
395 <a id="gab414a1e138205a55820acfa277c8f386" name="gab414a1e138205a55820acfa277c8f386"></a>
396 <h2 class="memtitle"><span class="permalink"><a href="#gab414a1e138205a55820acfa277c8f386">&#9670;&#160;</a></span>osMemoryPoolGetName()</h2>
397
398 <div class="memitem">
399 <div class="memproto">
400       <table class="memname">
401         <tr>
402           <td class="memname">const char * osMemoryPoolGetName </td>
403           <td>(</td>
404           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
405           <td class="paramname"><em>mp_id</em></td><td>)</td>
406           <td></td>
407         </tr>
408       </table>
409 </div><div class="memdoc">
410
411 <p>Get name of a Memory Pool object. </p>
412 <dl class="params"><dt>Parameters</dt><dd>
413   <table class="params">
414     <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   </table>
416   </dd>
417 </dl>
418 <dl class="section return"><dt>Returns</dt><dd>name as null-terminated string.</dd></dl>
419 <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>
420 <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
422 </div>
423 </div>
424 <a id="ga8ead54e99ccb8f112356c88f99d38fbe" name="ga8ead54e99ccb8f112356c88f99d38fbe"></a>
425 <h2 class="memtitle"><span class="permalink"><a href="#ga8ead54e99ccb8f112356c88f99d38fbe">&#9670;&#160;</a></span>osMemoryPoolAlloc()</h2>
426
427 <div class="memitem">
428 <div class="memproto">
429       <table class="memname">
430         <tr>
431           <td class="memname">void * osMemoryPoolAlloc </td>
432           <td>(</td>
433           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
434           <td class="paramname"><em>mp_id</em>, </td>
435         </tr>
436         <tr>
437           <td class="paramkey"></td>
438           <td></td>
439           <td class="paramtype">uint32_t&#160;</td>
440           <td class="paramname"><em>timeout</em>&#160;</td>
441         </tr>
442         <tr>
443           <td></td>
444           <td>)</td>
445           <td></td><td></td>
446         </tr>
447       </table>
448 </div><div class="memdoc">
449
450 <p>Allocate a memory block from a Memory Pool. </p>
451 <dl class="params"><dt>Parameters</dt><dd>
452   <table class="params">
453     <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>
454     <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   </table>
456   </dd>
457 </dl>
458 <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>
459 <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>
460 <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>
461 <p>The parameter <a class="el" href="usingOS2.html#CMSIS_RTOS_TimeOutValue">timeout</a> can have the following values:</p><ul>
462 <li>when <em>timeout</em> is <span class="XML-Token">0</span>, the function returns instantly (i.e. try semantics).</li>
463 <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>
464 <li>all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).</li>
465 </ul>
466 <p>The result is the pointer to the memory block allocated, or NULL if no memory is available.</p>
467 <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>
468 <dd>
469 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>
470 <p><b>Code</b> <b>Example</b> </p>
471 <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
472
473 </div>
474 </div>
475 <a id="gabb4f4560daa6d1f8c8789082ee186d16" name="gabb4f4560daa6d1f8c8789082ee186d16"></a>
476 <h2 class="memtitle"><span class="permalink"><a href="#gabb4f4560daa6d1f8c8789082ee186d16">&#9670;&#160;</a></span>osMemoryPoolFree()</h2>
477
478 <div class="memitem">
479 <div class="memproto">
480       <table class="memname">
481         <tr>
482           <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolFree </td>
483           <td>(</td>
484           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
485           <td class="paramname"><em>mp_id</em>, </td>
486         </tr>
487         <tr>
488           <td class="paramkey"></td>
489           <td></td>
490           <td class="paramtype">void *&#160;</td>
491           <td class="paramname"><em>block</em>&#160;</td>
492         </tr>
493         <tr>
494           <td></td>
495           <td>)</td>
496           <td></td><td></td>
497         </tr>
498       </table>
499 </div><div class="memdoc">
500
501 <p>Return an allocated memory block back to a Memory Pool. </p>
502 <dl class="params"><dt>Parameters</dt><dd>
503   <table class="params">
504     <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>
505     <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   </table>
507   </dd>
508 </dl>
509 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
510 <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>
511 <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>
512 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
513 <li><em>osOK:</em> the memory has been freed.</li>
514 <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>
515 <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
516 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified memory pool.</li>
517 </ul>
518 <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>
519 <dd>
520 This function may be called from <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
521 <p><b>Code</b> <b>Example</b> </p>
522 <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
523
524 </div>
525 </div>
526 <a id="gad696e94bfbe28f0b6613f9303fdf6a37" name="gad696e94bfbe28f0b6613f9303fdf6a37"></a>
527 <h2 class="memtitle"><span class="permalink"><a href="#gad696e94bfbe28f0b6613f9303fdf6a37">&#9670;&#160;</a></span>osMemoryPoolGetCapacity()</h2>
528
529 <div class="memitem">
530 <div class="memproto">
531       <table class="memname">
532         <tr>
533           <td class="memname">uint32_t osMemoryPoolGetCapacity </td>
534           <td>(</td>
535           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
536           <td class="paramname"><em>mp_id</em></td><td>)</td>
537           <td></td>
538         </tr>
539       </table>
540 </div><div class="memdoc">
541
542 <p>Get maximum number of memory blocks in a Memory Pool. </p>
543 <dl class="params"><dt>Parameters</dt><dd>
544   <table class="params">
545     <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   </table>
547   </dd>
548 </dl>
549 <dl class="section return"><dt>Returns</dt><dd>maximum number of memory blocks.</dd></dl>
550 <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>
551 <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
553 </div>
554 </div>
555 <a id="gab2bf059b7fa7679c3cccdaeec60b6c0e" name="gab2bf059b7fa7679c3cccdaeec60b6c0e"></a>
556 <h2 class="memtitle"><span class="permalink"><a href="#gab2bf059b7fa7679c3cccdaeec60b6c0e">&#9670;&#160;</a></span>osMemoryPoolGetBlockSize()</h2>
557
558 <div class="memitem">
559 <div class="memproto">
560       <table class="memname">
561         <tr>
562           <td class="memname">uint32_t osMemoryPoolGetBlockSize </td>
563           <td>(</td>
564           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
565           <td class="paramname"><em>mp_id</em></td><td>)</td>
566           <td></td>
567         </tr>
568       </table>
569 </div><div class="memdoc">
570
571 <p>Get memory block size in a Memory Pool. </p>
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 <a class="el" href="usingOS2.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </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
600 <p>Get number of memory blocks used in a Memory Pool. </p>
601 <dl class="params"><dt>Parameters</dt><dd>
602   <table class="params">
603     <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   </table>
605   </dd>
606 </dl>
607 <dl class="section return"><dt>Returns</dt><dd>number of memory blocks used.</dd></dl>
608 <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>
609 <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
611 </div>
612 </div>
613 <a id="ga0394cffa9479a7994e3b03c79c1cb909" name="ga0394cffa9479a7994e3b03c79c1cb909"></a>
614 <h2 class="memtitle"><span class="permalink"><a href="#ga0394cffa9479a7994e3b03c79c1cb909">&#9670;&#160;</a></span>osMemoryPoolGetSpace()</h2>
615
616 <div class="memitem">
617 <div class="memproto">
618       <table class="memname">
619         <tr>
620           <td class="memname">uint32_t osMemoryPoolGetSpace </td>
621           <td>(</td>
622           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
623           <td class="paramname"><em>mp_id</em></td><td>)</td>
624           <td></td>
625         </tr>
626       </table>
627 </div><div class="memdoc">
628
629 <p>Get number of memory blocks available in a Memory Pool. </p>
630 <dl class="params"><dt>Parameters</dt><dd>
631   <table class="params">
632     <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   </table>
634   </dd>
635 </dl>
636 <dl class="section return"><dt>Returns</dt><dd>number of memory blocks available.</dd></dl>
637 <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>
638 <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
640 </div>
641 </div>
642 <a id="ga8c39e7e5cd2b9eda907466808e59d62e" name="ga8c39e7e5cd2b9eda907466808e59d62e"></a>
643 <h2 class="memtitle"><span class="permalink"><a href="#ga8c39e7e5cd2b9eda907466808e59d62e">&#9670;&#160;</a></span>osMemoryPoolDelete()</h2>
644
645 <div class="memitem">
646 <div class="memproto">
647       <table class="memname">
648         <tr>
649           <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolDelete </td>
650           <td>(</td>
651           <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
652           <td class="paramname"><em>mp_id</em></td><td>)</td>
653           <td></td>
654         </tr>
655       </table>
656 </div><div class="memdoc">
657
658 <p>Delete a Memory Pool object. </p>
659 <dl class="params"><dt>Parameters</dt><dd>
660   <table class="params">
661     <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   </table>
663   </dd>
664 </dl>
665 <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
666 <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>
667 <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p><ul>
668 <li><em>osOK:</em> the memory pool object has been deleted.</li>
669 <li><em>osErrorParameter:</em> parameter <em>mp_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
670 <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
671 <li><em>osErrorISR:</em> <b>osMemoryPoolDelete</b> cannot be called from interrupt service routines.</li>
672 <li><em>osErrorSafetyClass:</em> the calling thread safety class is lower than the safety class of the specified memory pool.</li>
673 </ul>
674 <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
676 </div>
677 </div>
678 </div><!-- contents -->
679 </div><!-- doc-content -->
680 <!-- start footer part -->
681 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
682   <ul>
683     <li class="footer">
684       <script type="text/javascript">
685         <!--
686         writeFooter.call(this);
687         //-->
688       </script> 
689     </li>
690   </ul>
691 </div>
692 </body>
693 </html>