]> begriffs open source - cmsis/blob - main/Driver/html/group__StorageDriverFunctions.html
Update documentation for branch main
[cmsis] / main / Driver / html / group__StorageDriverFunctions.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-Driver: Use of Storage APIs</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-Driver
47    &#160;<span id="projectnumber"><script type="text/javascript">
48      <!--
49      writeHeader.call(this);
50      writeVersionDropdown.call(this, "CMSIS-Driver");
51      //-->
52     </script>
53    </span>
54    </div>
55    <div id="projectbrief">Peripheral Interface for Middleware and Application Code</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 <!-- Generated by Doxygen 1.9.6 -->
83 <script type="text/javascript">
84 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
85 var searchBox = new SearchBox("searchBox", "search/",'.html');
86 /* @license-end */
87 </script>
88 </div><!-- top -->
89 <div id="side-nav" class="ui-resizable side-nav-resizable">
90   <div id="nav-tree">
91     <div id="nav-tree-contents">
92       <div id="nav-sync" class="sync"></div>
93     </div>
94   </div>
95   <div id="splitbar" style="-moz-user-select:none;" 
96        class="ui-resizable-handle">
97   </div>
98 </div>
99 <script type="text/javascript">
100 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
101 $(document).ready(function(){initNavTree('group__StorageDriverFunctions.html',''); initResizable(); });
102 /* @license-end */
103 </script>
104 <div id="doc-content">
105 <!-- window showing the filter options -->
106 <div id="MSearchSelectWindow"
107      onmouseover="return searchBox.OnSearchSelectShow()"
108      onmouseout="return searchBox.OnSearchSelectHide()"
109      onkeydown="return searchBox.OnSearchSelectKey(event)">
110 </div>
111
112 <!-- iframe showing the search results (closed by default) -->
113 <div id="MSearchResultsWindow">
114 <div id="MSearchResults">
115 <div class="SRPage">
116 <div id="SRIndex">
117 <div id="SRResults"></div>
118 <div class="SRStatus" id="Loading">Loading...</div>
119 <div class="SRStatus" id="Searching">Searching...</div>
120 <div class="SRStatus" id="NoMatches">No Matches</div>
121 </div>
122 </div>
123 </div>
124 </div>
125
126 <div class="header">
127   <div class="headertitle"><div class="title">Use of Storage APIs<div class="ingroups"><a class="el" href="group__storage__interface__gr.html">Storage Interface</a></div></div></div>
128 </div><!--header-->
129 <div class="contents">
130 <p>Function pointers within <a class="el" href="group__storage__interface__gr.html#structARM__DRIVER__STORAGE">ARM_DRIVER_STORAGE</a> form the set of operations constituting the Storage driver. Their implementation is platform-specific, and needs to be supplied by the porting effort.</p>
131 <p>Some of these APIs will always operate synchronously:</p><ul>
132 <li><a class="el" href="group__storage__interface__gr.html#gaf28193431b1a2ee64b22bfb36aed27e3">ARM_Storage_GetVersion</a></li>
133 <li><a class="el" href="group__storage__interface__gr.html#ga8378b3901dfe76d8f31728a50e10dae2">ARM_Storage_GetCapabilities</a></li>
134 <li><a class="el" href="group__storage__interface__gr.html#ga29e7bfe78f41abb16973bdb4e0188a20">ARM_Storage_GetStatus</a></li>
135 <li><a class="el" href="group__storage__interface__gr.html#gad557e8e6e33cd4528d398ecf4dddc747">ARM_Storage_GetInfo</a></li>
136 <li><a class="el" href="group__storage__interface__gr.html#ga5a1934750a51c74b8b0fea52588a3b9a">ARM_Storage_ResolveAddress</a></li>
137 <li><a class="el" href="group__storage__interface__gr.html#gad318f8cb38626cbeea1fcf36a0977c44">ARM_Storage_GetNextBlock</a> and</li>
138 <li><a class="el" href="group__storage__interface__gr.html#ga5fe9d27ce8afe65124dec62566114073">ARM_Storage_GetBlock</a>.</li>
139 </ul>
140 <p>This means that control returns to the caller with a relevant status code only after the completion of the operation (or the discovery of a failure condition).</p>
141 <p>The remainder of the APIs:</p><ul>
142 <li><a class="el" href="group__storage__interface__gr.html#gacc5dc090a35ac16caff8957030eaa174">ARM_Storage_Initialize</a></li>
143 <li><a class="el" href="group__storage__interface__gr.html#ga1d14b15ddcda2836c6e3c1d0b5e60dca">ARM_Storage_Uninitialize</a></li>
144 <li><a class="el" href="group__storage__interface__gr.html#ga979a2484bf05b2986de95a5d98307d54">ARM_Storage_PowerControl</a></li>
145 <li><a class="el" href="group__storage__interface__gr.html#gabaa24553c165add98020434c980b3ab4">ARM_Storage_ReadData</a></li>
146 <li><a class="el" href="group__storage__interface__gr.html#gabd20d561854c06918b0515b6c1bba230">ARM_Storage_ProgramData</a></li>
147 <li><a class="el" href="group__storage__interface__gr.html#gaceef4851d9181cce65c8b2d05f4429bc">ARM_Storage_Erase</a> and</li>
148 <li><a class="el" href="group__storage__interface__gr.html#ga04e77387a3c628d6fc661e82f7daddaa">ARM_Storage_EraseAll</a></li>
149 </ul>
150 <p>can function asynchronously if the underlying controller supports it; that is if <a class="el" href="group__storage__interface__gr.html#a15ade4ca762bc6ce72d435a16febb4cc" title="Used to indicate if APIs like initialize, read, erase, program, etc. can operate in asynchronous mode...">ARM_STORAGE_CAPABILITIES::asynchronous_ops</a> is set. In the case of asynchronous operation, the invocation returns early (with ARM_DRIVER_OK) and results in a completion callback later. If <a class="el" href="group__storage__interface__gr.html#a15ade4ca762bc6ce72d435a16febb4cc" title="Used to indicate if APIs like initialize, read, erase, program, etc. can operate in asynchronous mode...">ARM_STORAGE_CAPABILITIES::asynchronous_ops</a> is not set, then all such APIs execute synchronously, and control returns to the caller with a status code only after the completion of the operation (or the discovery of a failure condition).</p>
151 <p>If <a class="el" href="group__storage__interface__gr.html#a15ade4ca762bc6ce72d435a16febb4cc" title="Used to indicate if APIs like initialize, read, erase, program, etc. can operate in asynchronous mode...">ARM_STORAGE_CAPABILITIES::asynchronous_ops</a> is set, a storage driver may still choose to execute asynchronous operations in a synchronous manner. If so, the driver returns a positive value to indicate successful synchronous completion (or an error code in case of failure) and no further invocation of completion callback should be expected. The expected return value for synchronous completion of such asynchronous operations varies depending on the operation. For operations involving data access, it often equals the amount of data transferred or affected. For non data-transfer operations, such as EraseAll or Initialize, it is usually 1.</p>
152 <p>Here's a code snippet to suggest how asynchronous APIs might be used by callers to handle both synchronous and asynchronous execution by the underlying storage driver: </p><div class="fragment"><div class="line">ASSERT(<a class="code hl_define" href="group__execution__status.html#ga85752c5de59e8adeb001e35ff5be6be7">ARM_DRIVER_OK</a> == 0); <span class="comment">// this is a precondition; it doesn&#39;t need to be put in code</span></div>
153 <div class="line"> </div>
154 <div class="line">int32_t returnValue = drv-&gt;asynchronousAPI(...);</div>
155 <div class="line">     </div>
156 <div class="line"><span class="keywordflow">if</span> (returnValue &lt; <a class="code hl_define" href="group__execution__status.html#ga85752c5de59e8adeb001e35ff5be6be7">ARM_DRIVER_OK</a>) {</div>
157 <div class="line">    <span class="comment">// handle error.</span></div>
158 <div class="line">    </div>
159 <div class="line">} <span class="keywordflow">else</span> <span class="keywordflow">if</span> (returnValue == <a class="code hl_define" href="group__execution__status.html#ga85752c5de59e8adeb001e35ff5be6be7">ARM_DRIVER_OK</a>) {</div>
160 <div class="line">    ASSERT(drv-&gt;GetCapabilities().asynchronous_ops == 1);</div>
161 <div class="line">    <span class="comment">// handle early return from asynchronous execution; remainder of the work is done in the callback handler.</span></div>
162 <div class="line">    </div>
163 <div class="line">} <span class="keywordflow">else</span> {</div>
164 <div class="line">    ASSERT(returnValue == EXPECTED_RETURN_VALUE_FOR_SYNCHRONOUS_COMPLETION);</div>
165 <div class="line">    <span class="comment">// handle synchronous completion.</span></div>
166 <div class="line">}</div>
167 <div class="ttc" id="agroup__execution__status_html_ga85752c5de59e8adeb001e35ff5be6be7"><div class="ttname"><a href="group__execution__status.html#ga85752c5de59e8adeb001e35ff5be6be7">ARM_DRIVER_OK</a></div><div class="ttdeci">#define ARM_DRIVER_OK</div><div class="ttdoc">Operation succeeded.</div></div>
168 </div><!-- fragment --><p>This example is mixing synchronous and asynchronous APIs: <a class="el" href="group__SampleUseOfStorageDriver.html">Sample Use of Storage Driver</a> </p>
169 </div><!-- contents -->
170 </div><!-- doc-content -->
171 <!-- start footer part -->
172 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
173   <ul>
174     <li class="footer">
175       <script type="text/javascript">
176         <!--
177         writeFooter.call(this);
178         //-->
179       </script> 
180     </li>
181   </ul>
182 </div>
183 </body>
184 </html>