group__CMSIS__RTOS__PoolMgmt.html 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <title>Memory Pool</title>
  7. <title>CMSIS-RTOS2: Memory Pool</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <link href="cmsis.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="printComponentTabs.js"></script>
  13. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  14. <script type="text/javascript" src="resize.js"></script>
  15. <script type="text/javascript" src="navtree.js"></script>
  16. <script type="text/javascript">
  17. $(document).ready(initResizable);
  18. $(window).load(resizeHeight);
  19. </script>
  20. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  21. <script type="text/javascript" src="search/search.js"></script>
  22. <script type="text/javascript">
  23. $(document).ready(function() { searchBox.OnSelectItem(0); });
  24. </script>
  25. </head>
  26. <body>
  27. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  28. <div id="titlearea">
  29. <table cellspacing="0" cellpadding="0">
  30. <tbody>
  31. <tr style="height: 46px;">
  32. <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  33. <td style="padding-left: 0.5em;">
  34. <div id="projectname">CMSIS-RTOS2
  35. &#160;<span id="projectnumber">Version 2.1.3</span>
  36. </div>
  37. <div id="projectbrief">Real-Time Operating System: API and RTX Reference Implementation</div>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. <!-- end header part -->
  44. <div id="CMSISnav" class="tabs1">
  45. <ul class="tablist">
  46. <script type="text/javascript">
  47. <!--
  48. writeComponentTabs.call(this);
  49. //-->
  50. </script>
  51. </ul>
  52. </div>
  53. <!-- Generated by Doxygen 1.8.6 -->
  54. <script type="text/javascript">
  55. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  56. </script>
  57. <div id="navrow1" class="tabs">
  58. <ul class="tablist">
  59. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  60. <li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
  61. <li><a href="modules.html"><span>Reference</span></a></li>
  62. <li>
  63. <div id="MSearchBox" class="MSearchBoxInactive">
  64. <span class="left">
  65. <img id="MSearchSelect" src="search/mag_sel.png"
  66. onmouseover="return searchBox.OnSearchSelectShow()"
  67. onmouseout="return searchBox.OnSearchSelectHide()"
  68. alt=""/>
  69. <input type="text" id="MSearchField" value="Search" accesskey="S"
  70. onfocus="searchBox.OnSearchFieldFocus(true)"
  71. onblur="searchBox.OnSearchFieldFocus(false)"
  72. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  73. </span><span class="right">
  74. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  75. </span>
  76. </div>
  77. </li>
  78. </ul>
  79. </div>
  80. </div><!-- top -->
  81. <div id="side-nav" class="ui-resizable side-nav-resizable">
  82. <div id="nav-tree">
  83. <div id="nav-tree-contents">
  84. <div id="nav-sync" class="sync"></div>
  85. </div>
  86. </div>
  87. <div id="splitbar" style="-moz-user-select:none;"
  88. class="ui-resizable-handle">
  89. </div>
  90. </div>
  91. <script type="text/javascript">
  92. $(document).ready(function(){initNavTree('group__CMSIS__RTOS__PoolMgmt.html','');});
  93. </script>
  94. <div id="doc-content">
  95. <!-- window showing the filter options -->
  96. <div id="MSearchSelectWindow"
  97. onmouseover="return searchBox.OnSearchSelectShow()"
  98. onmouseout="return searchBox.OnSearchSelectHide()"
  99. onkeydown="return searchBox.OnSearchSelectKey(event)">
  100. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>
  101. <!-- iframe showing the search results (closed by default) -->
  102. <div id="MSearchResultsWindow">
  103. <iframe src="javascript:void(0)" frameborder="0"
  104. name="MSearchResults" id="MSearchResults">
  105. </iframe>
  106. </div>
  107. <div class="header">
  108. <div class="summary">
  109. <a href="#nested-classes">Data Structures</a> &#124;
  110. <a href="#typedef-members">Typedefs</a> &#124;
  111. <a href="#func-members">Functions</a> </div>
  112. <div class="headertitle">
  113. <div class="title">Memory Pool<div class="ingroups"><a class="el" href="group__CMSIS__RTOS.html">CMSIS-RTOS API v2</a></div></div> </div>
  114. </div><!--header-->
  115. <div class="contents">
  116. <p>Manage thread-safe fixed-size blocks of dynamic memory.
  117. <a href="#details">More...</a></p>
  118. <table class="memberdecls">
  119. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
  120. Data Structures</h2></td></tr>
  121. <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>
  122. <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>
  123. <tr class="separator:structosMemoryPoolAttr__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
  124. </table><table class="memberdecls">
  125. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
  126. Typedefs</h2></td></tr>
  127. <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>
  128. <tr class="separator:ga2e44473caf338266f56800960294f960"><td class="memSeparator" colspan="2">&#160;</td></tr>
  129. </table><table class="memberdecls">
  130. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  131. Functions</h2></td></tr>
  132. <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>
  133. <tr class="memdesc:ga497ced5d72dc5cd405c4c418516220dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create and Initialize a Memory Pool object. <a href="#ga497ced5d72dc5cd405c4c418516220dc">More...</a><br/></td></tr>
  134. <tr class="separator:ga497ced5d72dc5cd405c4c418516220dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
  135. <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>
  136. <tr class="memdesc:gab414a1e138205a55820acfa277c8f386"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get name of a Memory Pool object. <a href="#gab414a1e138205a55820acfa277c8f386">More...</a><br/></td></tr>
  137. <tr class="separator:gab414a1e138205a55820acfa277c8f386"><td class="memSeparator" colspan="2">&#160;</td></tr>
  138. <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>
  139. <tr class="memdesc:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate a memory block from a Memory Pool. <a href="#ga8ead54e99ccb8f112356c88f99d38fbe">More...</a><br/></td></tr>
  140. <tr class="separator:ga8ead54e99ccb8f112356c88f99d38fbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
  141. <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>
  142. <tr class="memdesc:gabb4f4560daa6d1f8c8789082ee186d16"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return an allocated memory block back to a Memory Pool. <a href="#gabb4f4560daa6d1f8c8789082ee186d16">More...</a><br/></td></tr>
  143. <tr class="separator:gabb4f4560daa6d1f8c8789082ee186d16"><td class="memSeparator" colspan="2">&#160;</td></tr>
  144. <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>
  145. <tr class="memdesc:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get maximum number of memory blocks in a Memory Pool. <a href="#gad696e94bfbe28f0b6613f9303fdf6a37">More...</a><br/></td></tr>
  146. <tr class="separator:gad696e94bfbe28f0b6613f9303fdf6a37"><td class="memSeparator" colspan="2">&#160;</td></tr>
  147. <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>
  148. <tr class="memdesc:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get memory block size in a Memory Pool. <a href="#gab2bf059b7fa7679c3cccdaeec60b6c0e">More...</a><br/></td></tr>
  149. <tr class="separator:gab2bf059b7fa7679c3cccdaeec60b6c0e"><td class="memSeparator" colspan="2">&#160;</td></tr>
  150. <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>
  151. <tr class="memdesc:ga958a9449bff8c95ce213de98eef5739d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of memory blocks used in a Memory Pool. <a href="#ga958a9449bff8c95ce213de98eef5739d">More...</a><br/></td></tr>
  152. <tr class="separator:ga958a9449bff8c95ce213de98eef5739d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  153. <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>
  154. <tr class="memdesc:ga0394cffa9479a7994e3b03c79c1cb909"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get number of memory blocks available in a Memory Pool. <a href="#ga0394cffa9479a7994e3b03c79c1cb909">More...</a><br/></td></tr>
  155. <tr class="separator:ga0394cffa9479a7994e3b03c79c1cb909"><td class="memSeparator" colspan="2">&#160;</td></tr>
  156. <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>
  157. <tr class="memdesc:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete a Memory Pool object. <a href="#ga8c39e7e5cd2b9eda907466808e59d62e">More...</a><br/></td></tr>
  158. <tr class="separator:ga8c39e7e5cd2b9eda907466808e59d62e"><td class="memSeparator" colspan="2">&#160;</td></tr>
  159. </table>
  160. <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
  161. <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>
  162. <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>
  163. <div class="image">
  164. <img src="mempool.png" alt="mempool.png"/>
  165. <div class="caption">
  166. CMSIS-RTOS Memory Pools</div></div>
  167. <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>
  168. <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>
  169. <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="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd>
  170. <dd>
  171. Refer to <a class="el" href="config_rtx5.html#memPoolConfig">Memory Pool Configuration</a> for RTX5 configuration options. </dd></dl>
  172. <hr/><h2 class="groupheader">Data Structure Documentation</h2>
  173. <a name="structosMemoryPoolAttr__t" id="structosMemoryPoolAttr__t"></a>
  174. <div class="memitem">
  175. <div class="memproto">
  176. <table class="memname">
  177. <tr>
  178. <td class="memname">struct osMemoryPoolAttr_t</td>
  179. </tr>
  180. </table>
  181. </div><div class="memdoc">
  182. <div class="textblock"><p>Attributes to configure a memory pool.</p>
  183. <p>Refer to <a class="el" href="group__CMSIS__RTOS__MemoryMgmt.html">Memory Management</a> for details about usage of</p>
  184. <ul>
  185. <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a1e100dc33d403841ed3c344e3397868e" title="memory for control block ">osMemoryPoolAttr_t::cb_mem</a></li>
  186. <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>
  187. <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#a5799465cca9c71c5587ceb0986f5b06a" title="memory for data storage ">osMemoryPoolAttr_t::mp_mem</a></li>
  188. <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>
  189. </ul>
  190. </div><table class="fieldtable">
  191. <tr><th colspan="3">Data Fields</th></tr>
  192. <tr><td class="fieldtype">
  193. <a class="anchor" id="ab74e6bf80237ddc4109968cedc58c151"></a>const char *</td>
  194. <td class="fieldname">
  195. name</td>
  196. <td class="fielddoc">
  197. name of the memory pool <p>Pointer to a string with a human readable name of the memory pool object.<br/>
  198. Default: <span class="XML-Token">NULL</span>. </p>
  199. </td></tr>
  200. <tr><td class="fieldtype">
  201. <a class="anchor" id="a6e93b49cb79c12f768d72580c7731f30"></a>uint32_t</td>
  202. <td class="fieldname">
  203. attr_bits</td>
  204. <td class="fielddoc">
  205. attribute bits <p>Reserved for future use (set to '0').<br/>
  206. Default: <span class="XML-Token">0</span>. </p>
  207. </td></tr>
  208. <tr><td class="fieldtype">
  209. <a class="anchor" id="a1e100dc33d403841ed3c344e3397868e"></a>void *</td>
  210. <td class="fieldname">
  211. cb_mem</td>
  212. <td class="fielddoc">
  213. 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/>
  214. Default: <span class="XML-Token">NULL</span> (uses kernel memory management). </p>
  215. </td></tr>
  216. <tr><td class="fieldtype">
  217. <a class="anchor" id="aa55a4335d12dc2785dc00fdc292d1159"></a>uint32_t</td>
  218. <td class="fieldname">
  219. cb_size</td>
  220. <td class="fielddoc">
  221. 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>
  222. </td></tr>
  223. <tr><td class="fieldtype">
  224. <a class="anchor" id="a5799465cca9c71c5587ceb0986f5b06a"></a>void *</td>
  225. <td class="fieldname">
  226. mp_mem</td>
  227. <td class="fielddoc">
  228. memory for data storage <p>Pointer to a memory location for the data of the memory pool object.<br/>
  229. Default: <span class="XML-Token">NULL</span>. </p>
  230. </td></tr>
  231. <tr><td class="fieldtype">
  232. <a class="anchor" id="a66c26015c0ac8e88a4ad907c120aee4f"></a>uint32_t</td>
  233. <td class="fieldname">
  234. mp_size</td>
  235. <td class="fielddoc">
  236. 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>
  237. </td></tr>
  238. </table>
  239. </div>
  240. </div>
  241. <h2 class="groupheader">Typedef Documentation</h2>
  242. <a class="anchor" id="ga2e44473caf338266f56800960294f960"></a>
  243. <div class="memitem">
  244. <div class="memproto">
  245. <table class="memname">
  246. <tr>
  247. <td class="memname"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a></td>
  248. </tr>
  249. </table>
  250. </div><div class="memdoc">
  251. <p>Memory Pool ID identifies the memory pool.</p>
  252. <p>Returned by:</p>
  253. <ul>
  254. <li><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a> </li>
  255. </ul>
  256. </div>
  257. </div>
  258. <h2 class="groupheader">Function Documentation</h2>
  259. <a class="anchor" id="ga497ced5d72dc5cd405c4c418516220dc"></a>
  260. <div class="memitem">
  261. <div class="memproto">
  262. <table class="memname">
  263. <tr>
  264. <td class="memname"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> osMemoryPoolNew </td>
  265. <td>(</td>
  266. <td class="paramtype">uint32_t&#160;</td>
  267. <td class="paramname"><em>block_count</em>, </td>
  268. </tr>
  269. <tr>
  270. <td class="paramkey"></td>
  271. <td></td>
  272. <td class="paramtype">uint32_t&#160;</td>
  273. <td class="paramname"><em>block_size</em>, </td>
  274. </tr>
  275. <tr>
  276. <td class="paramkey"></td>
  277. <td></td>
  278. <td class="paramtype">const <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#structosMemoryPoolAttr__t">osMemoryPoolAttr_t</a> *&#160;</td>
  279. <td class="paramname"><em>attr</em>&#160;</td>
  280. </tr>
  281. <tr>
  282. <td></td>
  283. <td>)</td>
  284. <td></td><td></td>
  285. </tr>
  286. </table>
  287. </div><div class="memdoc">
  288. <dl class="params"><dt>Parameters</dt><dd>
  289. <table class="params">
  290. <tr><td class="paramdir">[in]</td><td class="paramname">block_count</td><td>maximum number of memory blocks in memory pool. </td></tr>
  291. <tr><td class="paramdir">[in]</td><td class="paramname">block_size</td><td>memory block size in bytes. </td></tr>
  292. <tr><td class="paramdir">[in]</td><td class="paramname">attr</td><td>memory pool attributes; NULL: default values. </td></tr>
  293. </table>
  294. </dd>
  295. </dl>
  296. <dl class="section return"><dt>Returns</dt><dd>memory pool ID for reference by other functions or NULL in case of error.</dd></dl>
  297. <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>
  298. <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>
  299. <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
  300. <p><b>Code</b> <b>Example</b> </p>
  301. <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="cmsis__os2_8h.html">cmsis_os2.h</a>&quot;</span> <span class="comment">// CMSIS RTOS header file</span></div>
  302. <div class="line"> </div>
  303. <div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
  304. <div class="line"><span class="comment"> * Memory Pool creation &amp; usage</span></div>
  305. <div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
  306. <div class="line"> </div>
  307. <div class="line"><span class="preprocessor">#define MEMPOOL_OBJECTS 16 // number of Memory Pool Objects</span></div>
  308. <div class="line"><span class="preprocessor"></span> </div>
  309. <div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{ <span class="comment">// object data type</span></div>
  310. <div class="line"> uint8_t Buf[32];</div>
  311. <div class="line"> uint8_t Idx;</div>
  312. <div class="line">} MEM_BLOCK_t;</div>
  313. <div class="line"> </div>
  314. <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument); <span class="comment">// thread function</span></div>
  315. <div class="line"><a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gaa6c32fe2a3e0a2e01f212d55b02e51c7">osThreadId_t</a> tid_Thread_MemPool; <span class="comment">// thread id</span></div>
  316. <div class="line"> </div>
  317. <div class="line"><a class="code" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a> mpid_MemPool; <span class="comment">// memory pool id</span></div>
  318. <div class="line"> </div>
  319. <div class="line"><span class="keywordtype">int</span> Init_MemPool (<span class="keywordtype">void</span>)</div>
  320. <div class="line">{</div>
  321. <div class="line"> </div>
  322. <div class="line"> mpid_MemPool = <a class="code" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>(MEMPOOL_OBJECTS,<span class="keyword">sizeof</span>(MEM_BLOCK_t), NULL);</div>
  323. <div class="line"> <span class="keywordflow">if</span> (mpid_MemPool == NULL) {</div>
  324. <div class="line"> ; <span class="comment">// MemPool object not created, handle failure</span></div>
  325. <div class="line"> }</div>
  326. <div class="line"> </div>
  327. <div class="line"> tid_Thread_MemPool = <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#ga48d68b8666d99d28fa646ee1d2182b8f">osThreadNew</a> (Thread_MemPool,NULL , NULL);</div>
  328. <div class="line"> <span class="keywordflow">if</span> (tid_Thread_MemPool == NULL) {</div>
  329. <div class="line"> <span class="keywordflow">return</span>(-1);</div>
  330. <div class="line"> }</div>
  331. <div class="line"> </div>
  332. <div class="line"> <span class="keywordflow">return</span>(0);</div>
  333. <div class="line">}</div>
  334. <div class="line"> </div>
  335. <div class="line"><span class="keywordtype">void</span> Thread_MemPool (<span class="keywordtype">void</span> *argument)</div>
  336. <div class="line">{</div>
  337. <div class="line"> osStatus_t status;</div>
  338. <div class="line"> MEM_BLOCK_t *pMem = 0;</div>
  339. <div class="line"> </div>
  340. <div class="line"> <span class="keywordflow">while</span> (1) {</div>
  341. <div class="line"> ; <span class="comment">// Insert thread code here...</span></div>
  342. <div class="line"> </div>
  343. <div class="line"> pMem = (MEM_BLOCK_t *)<a class="code" href="group__CMSIS__RTOS__PoolMgmt.html#ga8ead54e99ccb8f112356c88f99d38fbe">osMemoryPoolAlloc</a> (mpid_MemPool, NULL); <span class="comment">// get Mem Block</span></div>
  344. <div class="line"> <span class="keywordflow">if</span> (pMem) { <span class="comment">// Mem Block was available</span></div>
  345. <div class="line"> pMem-&gt;Buf[0] = 0x55; <span class="comment">// do some work...</span></div>
  346. <div class="line"> pMem-&gt;Idx = 0;</div>
  347. <div class="line"> </div>
  348. <div class="line"> status = <a class="code" href="group__CMSIS__RTOS__PoolMgmt.html#gabb4f4560daa6d1f8c8789082ee186d16">osMemoryPoolFree</a> (mpid_MemPool, pMem); <span class="comment">// free mem block</span></div>
  349. <div class="line"> <span class="keywordflow">switch</span> (status) {</div>
  350. <div class="line"> <span class="keywordflow">case</span> <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813ea9e1c9e2550bb4de8969a935acffc968f">osOK</a>:</div>
  351. <div class="line"> <span class="keywordflow">break</span>;</div>
  352. <div class="line"> <span class="keywordflow">case</span> <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eac24adca6a5d072c9f01c32178ba0d109">osErrorParameter</a>:</div>
  353. <div class="line"> <span class="keywordflow">break</span>;</div>
  354. <div class="line"> <span class="keywordflow">case</span> <a class="code" href="cmsis__os2_8h.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813eaf1fac0240218e51eb30a13da2f8aae81">osErrorNoMemory</a>:</div>
  355. <div class="line"> <span class="keywordflow">break</span>;</div>
  356. <div class="line"> <span class="keywordflow">default</span>:</div>
  357. <div class="line"> <span class="keywordflow">break</span>;</div>
  358. <div class="line"> }</div>
  359. <div class="line"> }</div>
  360. <div class="line"> </div>
  361. <div class="line"> <a class="code" href="group__CMSIS__RTOS__ThreadMgmt.html#gad01c7ec26535b1de6b018bb9466720e2">osThreadYield</a> (); <span class="comment">// suspend thread</span></div>
  362. <div class="line"> }</div>
  363. <div class="line">}</div>
  364. </div><!-- fragment -->
  365. </div>
  366. </div>
  367. <a class="anchor" id="gab414a1e138205a55820acfa277c8f386"></a>
  368. <div class="memitem">
  369. <div class="memproto">
  370. <table class="memname">
  371. <tr>
  372. <td class="memname">const char * osMemoryPoolGetName </td>
  373. <td>(</td>
  374. <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
  375. <td class="paramname"><em>mp_id</em></td><td>)</td>
  376. <td></td>
  377. </tr>
  378. </table>
  379. </div><div class="memdoc">
  380. <dl class="params"><dt>Parameters</dt><dd>
  381. <table class="params">
  382. <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>
  383. </table>
  384. </dd>
  385. </dl>
  386. <dl class="section return"><dt>Returns</dt><dd>name as null-terminated string.</dd></dl>
  387. <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>
  388. <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
  389. </div>
  390. </div>
  391. <a class="anchor" id="ga8ead54e99ccb8f112356c88f99d38fbe"></a>
  392. <div class="memitem">
  393. <div class="memproto">
  394. <table class="memname">
  395. <tr>
  396. <td class="memname">void * osMemoryPoolAlloc </td>
  397. <td>(</td>
  398. <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
  399. <td class="paramname"><em>mp_id</em>, </td>
  400. </tr>
  401. <tr>
  402. <td class="paramkey"></td>
  403. <td></td>
  404. <td class="paramtype">uint32_t&#160;</td>
  405. <td class="paramname"><em>timeout</em>&#160;</td>
  406. </tr>
  407. <tr>
  408. <td></td>
  409. <td>)</td>
  410. <td></td><td></td>
  411. </tr>
  412. </table>
  413. </div><div class="memdoc">
  414. <dl class="params"><dt>Parameters</dt><dd>
  415. <table class="params">
  416. <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>
  417. <tr><td class="paramdir">[in]</td><td class="paramname">timeout</td><td><a class="el" href="theory_of_operation.html#CMSIS_RTOS_TimeOutValue">Timeout Value</a> or 0 in case of no time-out. </td></tr>
  418. </table>
  419. </dd>
  420. </dl>
  421. <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>
  422. <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>
  423. <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>
  424. <p>The parameter <a class="el" href="theory_of_operation.html#CMSIS_RTOS_TimeOutValue">timeout</a> can have the following values:</p>
  425. <ul>
  426. <li>when <em>timeout</em> is <span class="XML-Token">0</span>, the function returns instantly (i.e. try semantics).</li>
  427. <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>
  428. <li>all other values specify a time in kernel ticks for a timeout (i.e. timed-wait semantics).</li>
  429. </ul>
  430. <p>The result is the pointer to the memory block allocated, or NULL if no memory is available.</p>
  431. <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>
  432. <dd>
  433. May be called from <a class="el" href="theory_of_operation.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>
  434. <p><b>Code</b> <b>Example</b> </p>
  435. <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
  436. </div>
  437. </div>
  438. <a class="anchor" id="gabb4f4560daa6d1f8c8789082ee186d16"></a>
  439. <div class="memitem">
  440. <div class="memproto">
  441. <table class="memname">
  442. <tr>
  443. <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolFree </td>
  444. <td>(</td>
  445. <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
  446. <td class="paramname"><em>mp_id</em>, </td>
  447. </tr>
  448. <tr>
  449. <td class="paramkey"></td>
  450. <td></td>
  451. <td class="paramtype">void *&#160;</td>
  452. <td class="paramname"><em>block</em>&#160;</td>
  453. </tr>
  454. <tr>
  455. <td></td>
  456. <td>)</td>
  457. <td></td><td></td>
  458. </tr>
  459. </table>
  460. </div><div class="memdoc">
  461. <dl class="params"><dt>Parameters</dt><dd>
  462. <table class="params">
  463. <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>
  464. <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>
  465. </table>
  466. </dd>
  467. </dl>
  468. <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
  469. <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>
  470. <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>
  471. <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
  472. <ul>
  473. <li><em>osOK:</em> the memory has been freed.</li>
  474. <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>
  475. <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
  476. </ul>
  477. <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>
  478. <dd>
  479. This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
  480. <p><b>Code</b> <b>Example</b> </p>
  481. <p>Refer to <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </p>
  482. </div>
  483. </div>
  484. <a class="anchor" id="gad696e94bfbe28f0b6613f9303fdf6a37"></a>
  485. <div class="memitem">
  486. <div class="memproto">
  487. <table class="memname">
  488. <tr>
  489. <td class="memname">uint32_t osMemoryPoolGetCapacity </td>
  490. <td>(</td>
  491. <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
  492. <td class="paramname"><em>mp_id</em></td><td>)</td>
  493. <td></td>
  494. </tr>
  495. </table>
  496. </div><div class="memdoc">
  497. <dl class="params"><dt>Parameters</dt><dd>
  498. <table class="params">
  499. <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>
  500. </table>
  501. </dd>
  502. </dl>
  503. <dl class="section return"><dt>Returns</dt><dd>maximum number of memory blocks.</dd></dl>
  504. <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>
  505. <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
  506. </div>
  507. </div>
  508. <a class="anchor" id="gab2bf059b7fa7679c3cccdaeec60b6c0e"></a>
  509. <div class="memitem">
  510. <div class="memproto">
  511. <table class="memname">
  512. <tr>
  513. <td class="memname">uint32_t osMemoryPoolGetBlockSize </td>
  514. <td>(</td>
  515. <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
  516. <td class="paramname"><em>mp_id</em></td><td>)</td>
  517. <td></td>
  518. </tr>
  519. </table>
  520. </div><div class="memdoc">
  521. <dl class="params"><dt>Parameters</dt><dd>
  522. <table class="params">
  523. <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>
  524. </table>
  525. </dd>
  526. </dl>
  527. <dl class="section return"><dt>Returns</dt><dd>memory block size in bytes.</dd></dl>
  528. <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>
  529. <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
  530. </div>
  531. </div>
  532. <a class="anchor" id="ga958a9449bff8c95ce213de98eef5739d"></a>
  533. <div class="memitem">
  534. <div class="memproto">
  535. <table class="memname">
  536. <tr>
  537. <td class="memname">uint32_t osMemoryPoolGetCount </td>
  538. <td>(</td>
  539. <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
  540. <td class="paramname"><em>mp_id</em></td><td>)</td>
  541. <td></td>
  542. </tr>
  543. </table>
  544. </div><div class="memdoc">
  545. <dl class="params"><dt>Parameters</dt><dd>
  546. <table class="params">
  547. <tr><td class="paramdir">[in]</td><td class="paramname">mp_id</td><td>memory pool ID obtained by <a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga497ced5d72dc5cd405c4c418516220dc">osMemoryPoolNew</a>. </td></tr>
  548. </table>
  549. </dd>
  550. </dl>
  551. <dl class="section return"><dt>Returns</dt><dd>number of memory blocks used.</dd></dl>
  552. <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>
  553. <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
  554. </div>
  555. </div>
  556. <a class="anchor" id="ga0394cffa9479a7994e3b03c79c1cb909"></a>
  557. <div class="memitem">
  558. <div class="memproto">
  559. <table class="memname">
  560. <tr>
  561. <td class="memname">uint32_t osMemoryPoolGetSpace </td>
  562. <td>(</td>
  563. <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
  564. <td class="paramname"><em>mp_id</em></td><td>)</td>
  565. <td></td>
  566. </tr>
  567. </table>
  568. </div><div class="memdoc">
  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>
  572. </table>
  573. </dd>
  574. </dl>
  575. <dl class="section return"><dt>Returns</dt><dd>number of memory blocks available.</dd></dl>
  576. <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>
  577. <dl class="section note"><dt>Note</dt><dd>This function may be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
  578. </div>
  579. </div>
  580. <a class="anchor" id="ga8c39e7e5cd2b9eda907466808e59d62e"></a>
  581. <div class="memitem">
  582. <div class="memproto">
  583. <table class="memname">
  584. <tr>
  585. <td class="memname"><a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> osMemoryPoolDelete </td>
  586. <td>(</td>
  587. <td class="paramtype"><a class="el" href="group__CMSIS__RTOS__PoolMgmt.html#ga2e44473caf338266f56800960294f960">osMemoryPoolId_t</a>&#160;</td>
  588. <td class="paramname"><em>mp_id</em></td><td>)</td>
  589. <td></td>
  590. </tr>
  591. </table>
  592. </div><div class="memdoc">
  593. <dl class="params"><dt>Parameters</dt><dd>
  594. <table class="params">
  595. <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>
  596. </table>
  597. </dd>
  598. </dl>
  599. <dl class="section return"><dt>Returns</dt><dd>status code that indicates the execution status of the function.</dd></dl>
  600. <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>
  601. <p>Possible <a class="el" href="group__CMSIS__RTOS__Definitions.html#ga6c0dbe6069e4e7f47bb4cd32ae2b813e">osStatus_t</a> return values:</p>
  602. <ul>
  603. <li><em>osOK:</em> the memory pool object has been deleted.</li>
  604. <li><em>osErrorParameter:</em> parameter <em>mp_id</em> is <span class="XML-Token">NULL</span> or invalid.</li>
  605. <li><em>osErrorResource:</em> the memory pool is in an invalid state.</li>
  606. <li><em>osErrorISR:</em> <b>osMemoryPoolDelete</b> cannot be called from interrupt service routines.</li>
  607. </ul>
  608. <dl class="section note"><dt>Note</dt><dd>This function <b>cannot</b> be called from <a class="el" href="theory_of_operation.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>. </dd></dl>
  609. </div>
  610. </div>
  611. </div><!-- contents -->
  612. </div><!-- doc-content -->
  613. <!-- start footer part -->
  614. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  615. <ul>
  616. <li class="footer">Generated on Mon Mar 18 2019 16:06:33 for CMSIS-RTOS2 by Arm Ltd. All rights reserved.
  617. <!--
  618. <a href="http://www.doxygen.org/index.html">
  619. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
  620. -->
  621. </li>
  622. </ul>
  623. </div>
  624. </body>
  625. </html>