⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 self__programming_8c.html

📁 AVR106 读写Flash程序空间的C函数
💻 HTML
📖 第 1 页 / 共 4 页
字号:
        <tr>          <td class="md" nowrap valign="top">unsigned char WriteFlashPage           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="Self__programming_8h.html#b6f1b2644de7b0bfdbda193929167b4a">MyAddressType</a>&nbsp;</td>          <td class="mdname" nowrap> <em>flashStartAdr</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap>unsigned char *&nbsp;</td>          <td class="mdname" nowrap> <em>dataPage</em></td>        </tr>        <tr>          <td class="md"></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>The function writes data from array dataPage[] to Flash page address flashStartAdr. The Number of bytes written is depending upon the Flash page size. Returns FALSE if input argument ucFlashStartAdr is not a valid Flash page address for writing, else TRUE. <p>Definition at line <a class="el" href="Self__programming_8c-source.html#l00130">130</a> of file <a class="el" href="Self__programming_8c-source.html">Self_programming.c</a>.<p>References <a class="el" href="Self__programming_8c-source.html#l00207">AddressCheck()</a>, <a class="el" href="Self__programming_8h-source.html#l00045">ADR_FLASH_BUFFER</a>, <a class="el" href="Self__programming_8h-source.html#l00132">FLASH_BUFFER_FULL_ID</a>, <a class="el" href="Self__programming_8c.html#e43874319c89f039d4c684ca71e3cc89">FlashBackup</a>, <a class="el" href="Self__programming_8h-source.html#l00133">TRUE</a>, and <a class="el" href="Self__programming_8c-source.html#l00228">WriteBufToFlash()</a>.<div class="fragment"><pre class="fragment"><a name="l00131"></a>00131 {<a name="l00132"></a>00132   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index;<a name="l00133"></a>00133   <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> eepromInterruptSettings;<a name="l00134"></a>00134   <span class="keywordflow">if</span>( <a class="code" href="Self__programming_8c.html#968efe3412fbf2252905db9c760c6aff">AddressCheck</a>(flashStartAdr) ){<a name="l00135"></a>00135     eepromInterruptSettings = EECR &amp; (1&lt;&lt;EERIE); <span class="comment">// Stoes EEPROM interrupt mask</span><a name="l00136"></a>00136     EECR &amp;= ~(1&lt;&lt;EERIE);                    <span class="comment">// Disable EEPROM interrupt</span><a name="l00137"></a>00137     <span class="keywordflow">while</span>(EECR &amp; (1&lt;&lt;EEWE));                <span class="comment">// Wait if ongoing EEPROM write</span><a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="preprocessor">    #ifdef __FLASH_RECOVER</span><a name="l00140"></a>00140 <span class="preprocessor"></span>    <a class="code" href="Self__programming_8c.html#e43874319c89f039d4c684ca71e3cc89">FlashBackup</a>.status=0;                   <span class="comment">// Inicate that Flash buffer does</span><a name="l00141"></a>00141                                             <span class="comment">// not contain data for writing</span><a name="l00142"></a>00142     <span class="keywordflow">while</span>(EECR &amp; (1&lt;&lt;EEWE));<a name="l00143"></a>00143     <span class="keywordflow">for</span>(index = 0; index &lt; PAGESIZE; index+=2){ <span class="comment">// Fills Flash write buffer</span><a name="l00144"></a>00144       _SPM_FILLTEMP(index, (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)dataPage[index]+((<span class="keywordtype">unsigned</span> int)dataPage[index+1] &lt;&lt; 8));<a name="l00145"></a>00145     }<a name="l00146"></a>00146     <a class="code" href="Self__programming_8c.html#d29e91755e1d3695b74c15e89019db39">WriteBufToFlash</a>(<a class="code" href="Self__programming_8h.html#7344bf2129730480f9e46fb7f2cb1ceb">ADR_FLASH_BUFFER</a>);      <span class="comment">// Writes to Flash recovery buffer</span><a name="l00147"></a>00147     <a class="code" href="Self__programming_8c.html#e43874319c89f039d4c684ca71e3cc89">FlashBackup</a>.pageNumber=(<span class="keywordtype">unsigned</span> int)(flashStartAdr/PAGESIZE);<a name="l00148"></a>00148     <a class="code" href="Self__programming_8c.html#e43874319c89f039d4c684ca71e3cc89">FlashBackup</a>.status = <a class="code" href="Self__programming_8h.html#d1d89ef93c516c3d36de362a540a082e">FLASH_BUFFER_FULL_ID</a>; <span class="comment">// Indicates that Flash recovery buffer</span><a name="l00149"></a>00149                                            <span class="comment">// contains unwritten data</span><a name="l00150"></a>00150     <span class="keywordflow">while</span>(EECR &amp; (1&lt;&lt;EEWE));<a name="l00151"></a>00151 <span class="preprocessor">    #endif</span><a name="l00152"></a>00152 <span class="preprocessor"></span>    <span class="keywordflow">for</span>(index = 0; index &lt; PAGESIZE; index+=2){ <span class="comment">// Fills Flash write buffer</span><a name="l00153"></a>00153       _SPM_FILLTEMP(index, (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)dataPage[index]+((<span class="keywordtype">unsigned</span> int)dataPage[index+1] &lt;&lt; 8));<a name="l00154"></a>00154     }<a name="l00155"></a>00155     <a class="code" href="Self__programming_8c.html#d29e91755e1d3695b74c15e89019db39">WriteBufToFlash</a>(flashStartAdr);         <span class="comment">// Writes to Flash</span><a name="l00156"></a>00156 <span class="preprocessor">    #ifdef __FLASH_RECOVER</span><a name="l00157"></a>00157 <span class="preprocessor"></span>      <a class="code" href="Self__programming_8c.html#e43874319c89f039d4c684ca71e3cc89">FlashBackup</a>.status=0;                 <span class="comment">// Inicate that Flash buffer does</span><a name="l00158"></a>00158                                             <span class="comment">// not contain data for writing</span><a name="l00159"></a>00159       <span class="keywordflow">while</span>(EECR &amp; (1&lt;&lt;EEWE));<a name="l00160"></a>00160 <span class="preprocessor">    #endif</span><a name="l00161"></a>00161 <span class="preprocessor"></span><a name="l00162"></a>00162     EECR |= eepromInterruptSettings;        <span class="comment">// Restore EEPROM interrupt mask</span><a name="l00163"></a>00163     <span class="keywordflow">return</span> <a class="code" href="Self__programming_8h.html#c0d83f0b82a6b30de8811e69e6d95c61">TRUE</a>;                            <span class="comment">// Return TRUE if address</span><a name="l00164"></a>00164                                             <span class="comment">// valid for writing</span><a name="l00165"></a>00165   }<a name="l00166"></a>00166   <span class="keywordflow">else</span><a name="l00167"></a>00167     <span class="keywordflow">return</span> <a class="code" href="Self__programming_8h.html#946003f97ccc52d5d3b54ac0ec31bbfc">FALSE</a>;                           <span class="comment">// Return FALSE if not address not</span><a name="l00168"></a>00168                                             <span class="comment">// valid for writing</span><a name="l00169"></a>00169 }</pre></div><p><p>Here is the call graph for this function:<p><center><img src="Self__programming_8c_fc13c9dcc9565c691d73a8e35ea3c3b0_cgraph.png" border="0" usemap="#Self__programming_8c_fc13c9dcc9565c691d73a8e35ea3c3b0_cgraph_map" alt=""></center><map name="Self__programming_8c_fc13c9dcc9565c691d73a8e35ea3c3b0_cgraph_map"><area href="Self__programming_8c.html#968efe3412fbf2252905db9c760c6aff" shape="rect" coords="179,7,288,34" alt=""><area href="Self__programming_8c.html#d29e91755e1d3695b74c15e89019db39" shape="rect" coords="173,58,293,84" alt=""></map>    </td>  </tr></table><hr><h2>Variable Documentation</h2><a class="anchor" name="e43874319c89f039d4c684ca71e3cc89"></a><!-- doxytag: member="Self_programming.c::FlashBackup" ref="e43874319c89f039d4c684ca71e3cc89" args="" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">__eeprom { ... }  <a class="el" href="Self__programming_8c.html#e43874319c89f039d4c684ca71e3cc89">FlashBackup</a>          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Declare global struct variable in EEPROM if Flash recovery enabled. FlashBackup pageNumber holds Flash pageaddress (/PAGESIZE) the data in Flash recovery buffer should be written to if data need to be recovered. <a class="el" href="Self__programming_8c.html#9acb44549b41563697bb490144ec6258">FlashBackup.status</a> tells if data need to be recovered. <p>Referenced by <a class="el" href="Self__programming_8c-source.html#l00178">RecoverFlash()</a>, <a class="el" href="Self__programming_8c-source.html#l00082">WriteFlashByte()</a>, and <a class="el" href="Self__programming_8c-source.html#l00130">WriteFlashPage()</a>.    </td>  </tr></table><a class="anchor" name="37762d11479e633bc60b4d306ebffa55"></a><!-- doxytag: member="Self_programming.c::pageNumber" ref="37762d11479e633bc60b4d306ebffa55" args="" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">unsigned int <a class="el" href="Self__programming_8c.html#37762d11479e633bc60b4d306ebffa55">pageNumber</a>          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="Self__programming_8c-source.html#l00045">45</a> of file <a class="el" href="Self__programming_8c-source.html">Self_programming.c</a>.    </td>  </tr></table><a class="anchor" name="9acb44549b41563697bb490144ec6258"></a><!-- doxytag: member="Self_programming.c::status" ref="9acb44549b41563697bb490144ec6258" args="" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">unsigned char <a class="el" href="Self__programming_8c.html#9acb44549b41563697bb490144ec6258">status</a>          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p><p>Definition at line <a class="el" href="Self__programming_8c-source.html#l00046">46</a> of file <a class="el" href="Self__programming_8c-source.html">Self_programming.c</a>.    </td>  </tr></table><hr size="1"><address style="align: right;"><small>Generated on Wed Jan 18 16:19:23 2006 for AVR106 - C Functions for Reading and Writing to Flash Memory by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.5 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -