?? mmc_8h.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>VLSI Solution Oy Evaluation MP3 Player Source Code Documentation</title><link href="doxygen.css" rel="stylesheet" type="text/css"><img src="vlsi_small.gif" hspace="20" bordercolor="#ffffff" alt="VLSI Solution Oy"><b>VLSI Solution Oy Evaluation MP3 Player Source Code Documentation</b><p></p></head><body><!-- Generated by Doxygen 1.3.7 --><div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div><h1>mmc.h File Reference</h1>MMC interface routines for <a class="el" href="storage_8c.html">storage.c</a>. <a href="#_details">More...</a><p><p>This graph shows which files directly or indirectly include this file:<p><center><img src="mmc_8h__dep__incl.png" border="0" usemap="#mmc.hdep_map" alt="Included by dependency graph"></center><map name="mmc.hdep_map"><area href="filesys_8c.html" shape="rect" coords="6,18,62,42" alt=""><area href="mmc_8c.html" shape="rect" coords="86,18,134,42" alt=""><area href="player_8c.html" shape="rect" coords="158,18,211,42" alt=""><area href="storage_8c.html" shape="rect" coords="235,18,297,42" alt=""></map><p><a href="mmc_8h-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>unsigned char </td><td class="memItemRight" valign=bottom><a class="el" href="mmc_8h.html#a1">InitMMC</a> ()</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Start-up the MMC card. <a href="#a1"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>unsigned char </td><td class="memItemRight" valign=bottom><a class="el" href="mmc_8h.html#a2">SeekSector</a> (unsigned long sectorN)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Perform MMC Seek Command for offset sectorN*512. <a href="#a2"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>unsigned char </td><td class="memItemRight" valign=bottom><a class="el" href="mmc_8h.html#a3">ReadPhysicalSector</a> ()</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Perform block read of previously sought sector to diskSect. <a href="#a3"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>unsigned char </td><td class="memItemRight" valign=bottom><a class="el" href="mmc_8h.html#a4">WritePhysicalSector</a> ()</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Perform MMC block write from <b>*dataBufPtr</b> to sector sectorAddress.l. <a href="#a4"></a><br><br></td></tr><tr><td colspan=2><br><h2>Variables</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>xdata unsigned char </td><td class="memItemRight" valign=bottom><a class="el" href="mmc_8h.html#a0">storageFlags</a></td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Storage status flags. <a href="#a0"></a><br><br></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>MMC interface routines for <a class="el" href="storage_8c.html">storage.c</a>. <p><p>Definition in file <a class="el" href="mmc_8h-source.html">mmc.h</a>.<hr><h2>Function Documentation</h2><a class="anchor" name="a1" doxytag="mmc.h::InitMMC" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> unsigned char InitMMC </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Start-up the MMC card. <p><ul><li>Returns 0 when successful and supports seek-before-read</li><li>Returns 0x0e when successful but no support for seek-before-read</li><li>Returns 1 when MMC card is not found</li><li>Returns 2 when MMC card seems to be present but can't be read from. </li></ul><p>Definition at line <a class="el" href="mmc_8c-source.html#l00246">246</a> of file <a class="el" href="mmc_8c-source.html">mmc.c</a>.<p>References <a class="el" href="buffer_8h-source.html#l00107">DiskBlock::Raw::buf</a>, <a class="el" href="board_8c-source.html#l00036">Delay()</a>, <a class="el" href="buffer_8c-source.html#l00010">diskSect</a>, <a class="el" href="mmc_8c-source.html#l00171">GetStorageInformation()</a>, <a class="el" href="board_8h-source.html#l00254">Temp::i</a>, <a class="el" href="board_8h-source.html#l00162">MMC_OFF</a>, <a class="el" href="mmc_8c-source.html#l00019">MmcCommand()</a>, <a class="el" href="board_8h-source.html#l00178">MMCDeselect</a>, <a class="el" href="board_8h-source.html#l00175">MMCSelect</a>, <a class="el" href="board_8h-source.html#l00159">NO</a>, <a class="el" href="board_8h-source.html#l00280">Public</a>, <a class="el" href="unionDiskBlock.html#o1">DiskBlock::raw</a>, <a class="el" href="mmc_8c-source.html#l00463">ReadPhysicalSector()</a>, <a class="el" href="mmc_8c-source.html#l00217">RebootMMC()</a>, <a class="el" href="mmc_8c-source.html#l00431">SeekSector()</a>, <a class="el" href="board_8h-source.html#l00235">SPIPutChar</a>, <a class="el" href="board_8h-source.html#l00238">SPIPutCharWithoutWaiting</a>, <a class="el" href="board_8h-source.html#l00232">SPIWait</a>, <a class="el" href="board_8c.html#a0">temp</a>, and <a class="el" href="board_8h-source.html#l00156">YES</a>.<p>Referenced by <a class="el" href="storage_8c-source.html#l00043">InitStorage()</a>, and <a class="el" href="filesys_8c-source.html#l00610">OpenFile()</a>.<p><pre class="fragment"><div>00246 {00247 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c;00248 00249 <span class="comment">//Switch off the MMC power supply</span>00250 <a class="code" href="board_8h.html#a28">MMC_OFF</a> = <a class="code" href="board_8h.html#a26">YES</a>; 00251 00252 ConsoleWrite (<span class="stringliteral">"Init: MMC\r"</span>);00253 <a class="code" href="board_8h.html#a51">Delay</a>(100);00254 00255 <span class="comment">//Switch on the MMC power supply</span>00256 <a class="code" href="board_8h.html#a28">MMC_OFF</a> = <a class="code" href="board_8h.html#a27">NO</a>;00257 <a class="code" href="board_8h.html#a51">Delay</a>(100);00258 00259 <a class="code" href="board_8h.html#a32">MMCSelect</a>();00260 <span class="comment">/* Allow MMC some time and clock cycles to reset */</span>00261 <span class="keywordflow">for</span> (c=0; c<200; c++){ 00262 <a class="code" href="board_8h.html#a45">SPIPutCharWithoutWaiting</a>(0xff);00263 <a class="code" href="board_8h.html#a43">SPIWait</a>();00264 }00265 <a class="code" href="board_8h.html#a51">Delay</a>(20);00266 00267 <span class="keywordflow">if</span> (<a class="code" href="mmc_8c.html#a4">RebootMMC</a>()) <span class="keywordflow">return</span> 1; <span class="comment">//not able to powerup;</span>00268 <span class="comment">//An existing MMC card should be able to respond now.</span>00269 00270 <a class="code" href="mmc_8c.html#a3">GetStorageInformation</a>();00271 00272 <span class="comment">/* Set Block Size of 512 bytes (2 == 512 << 8) */</span>00273 <span class="keywordflow">if</span> ((c=<a class="code" href="mmc_8c.html#a0">MmcCommand</a>(0x50,0,0,2,0))) <span class="keywordflow">return</span> c|0x80; <span class="comment">/* blocksize error */</span>00274 00275 <span class="comment">/* Check if MMC supports interrupted data transfer */</span>00276 <span class="comment">/* This does a simple checksum check to see if interrupted and </span>00277 <span class="comment"> * non-interrupted read blocks are the same. */</span>00278 <span class="comment">/* This could be a function, so it is in braces for clarity purposes */</span>00279 { 00280 <span class="keywordflow">if</span> (<a class="code" href="mmc_8h.html#a2">SeekSector</a>(0)) <span class="keywordflow">return</span> 2; <span class="comment">//Storage powerup failure </span>00281 <span class="keywordflow">if</span> (<a class="code" href="mmc_8c.html#a9">ReadPhysicalSector</a>()) <span class="keywordflow">return</span> 2; <span class="comment">//Storage powerup failure</span>00282 00283 <a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o1">i</a> = <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[511];00284 <span class="keywordflow">for</span> (c=0; c<250; c++){00285 <a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o1">i</a> += <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[c];00286 }00287 00288 <span class="keywordflow">if</span> (<a class="code" href="mmc_8h.html#a2">SeekSector</a>(0)) <span class="keywordflow">return</span> 2;<span class="comment">//Storage powerup failure</span>00289 00290 <span class="comment">/* Send some extra SPI clocks */</span>00291 <a class="code" href="board_8h.html#a33">MMCDeselect</a>();00292 <a class="code" href="board_8h.html#a45">SPIPutCharWithoutWaiting</a>(0xff);00293 <span class="keywordflow">for</span> (c=0; c<100; c++){00294 <a class="code" href="board_8h.html#a44">SPIPutChar</a>(0xff);00295 }00296 <a class="code" href="board_8h.html#a43">SPIWait</a>();00297 00298 <span class="keywordflow">if</span> (<a class="code" href="mmc_8c.html#a9">ReadPhysicalSector</a>()){00299 ConsoleWrite(<span class="stringliteral">"Interrupted read failed.\r"</span>);00300 ConsoleWrite(<span class="stringliteral">"Using compatibility mode.\r"</span>);00301 <span class="keywordflow">return</span> 0x0e; <span class="comment">//ok but no support for seek-before-read</span>00302 00303 }<span class="keywordflow">else</span>{00304 <span class="comment">//Check if received data was same</span>00305 <a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o1">i</a> -= <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[511];00306 <span class="keywordflow">for</span> (c=0; c<250; c++){00307 <a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o1">i</a> -= <a class="code" href="buffer_8c.html#a0">diskSect</a>.<a class="code" href="unionDiskBlock.html#o1">raw</a>.<a class="code" href="structDiskBlock_1_1Raw.html#o0">buf</a>[c];00308 }00309 }00310 00311 <span class="keywordflow">if</span> (<a class="code" href="board_8c.html#a0">temp</a>.<a class="code" href="unionTemp.html#o1">i</a>) { <span class="comment">/* Checksum does not match */</span>00312 ConsoleWrite(<span class="stringliteral">"This MMC has no support for interrupted read. "</span>);00313 ConsoleWrite(<span class="stringliteral">"Using compatibility mode.\r"</span>);00314 <span class="keywordflow">return</span> 0x0e; <span class="comment">//ok but no support for seek-before-read</span>00315 }00316
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -