📄 mmc_8c.html
字号:
00129 <span class="keywordflow">if</span> (c != 0xfe){00130 <span class="comment">// No data start token, read fail. In an OS an error message would display.</span>00131 <span class="comment">// Since we're in an embedded system, it's unclear what we should do now.</span>00132 <span class="comment">// Current approach is to say all ok but make read block return 0xff's.</span>00133 <span class="comment">// It's not disasterous at least as long as we don't WRITE to MMC.</span>00134 00135 <span class="comment">// Flush any data that might be pending from the MMC.</span>00136 <span class="preprocessor">#ifdef MMCLONGDEBUG </span>00137 <span class="preprocessor"></span> {00138 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;00139 ConsoleWrite(<span class="stringliteral">"\rMMCWaitForData failed. "</span>);00140 ConsoleWrite(<span class="stringliteral">"Expected 0xFE token, received: "</span>);00141 <span class="keywordflow">for</span> (i=0;i<550;i++){00142 ConsolePutHex8(c);00143 c=<a class="code" href="board_8c.html#a1">SPIGetChar</a>();00144 }00145 }00146 <span class="preprocessor">#else</span>00147 <span class="preprocessor"></span> <a class="code" href="board_8h.html#a48">SPI8Clocks</a>(200); <span class="comment">/* Flush MMC by sending lots of FF's to it */</span>00148 <a class="code" href="board_8h.html#a48">SPI8Clocks</a>(200);00149 <a class="code" href="board_8h.html#a48">SPI8Clocks</a>(200);00150 <span class="preprocessor">#endif</span>00151 <span class="preprocessor"></span>00152 <a class="code" href="board_8h.html#a29">MMC_XCS</a> = <a class="code" href="board_8h.html#a31">MMC_NOT_SELECTED</a>; <span class="comment">//Drop MMC offline now.</span>00153 DebugMessage(<span class="stringliteral">"!t>"</span>);00154 <span class="keywordflow">return</span> 5; <span class="comment">//Return error</span>00155 00156 }00157 00158 DebugMessage(<span class="stringliteral">"t>"</span>); <span class="comment">//Exit Token Wait</span>00159 <span class="keywordflow">return</span> 0;00160 00161 }</div></pre><p>Here is the call graph for this function:<p><center><img src="mmc_8c_a1_cgraph.png" border="0" usemap="#mmc_8c_a1_cgraph_map" alt=""></center><map name="mmc_8c_a1_cgraph_map"><area href="board_8h.html#a48" shape="rect" coords="180,7,254,31" alt=""><area href="board_8c.html#a1" shape="rect" coords="178,54,256,78" alt=""></map> </td> </tr></table><a class="anchor" name="a6" doxytag="mmc.c::PerformBlockRead" ></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"> void PerformBlockRead </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>Perform the actual reading of 512 octets from MMC. <p>Note: This is the fast routine to read complete disk block <p>Definition at line <a class="el" href="mmc_8c-source.html#l00332">332</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="buffer_8c-source.html#l00013">dataBufPtr</a>, <a class="el" href="buffer_8c-source.html#l00010">diskSect</a>, <a class="el" href="unionDiskBlock.html#o1">DiskBlock::raw</a>, <a class="el" href="board_8h-source.html#l00223">SPI_RESULT_BYTE</a>, <a class="el" href="board_8h-source.html#l00220">SPIPutCharWithoutWaiting</a>, and <a class="el" href="board_8h-source.html#l00214">SPIWait</a>.<p>Referenced by <a class="el" href="mmc_8c-source.html#l00477">ReadPhysicalSector()</a>.<p><pre class="fragment"><div>00332 {00333 00334 <span class="preprocessor">#ifdef MMCDEBUG</span>00335 <span class="preprocessor"></span> ConsoleWrite(<span class="stringliteral">"<R"</span>); <span class="comment">//Actual Read</span>00336 <span class="preprocessor">#endif</span>00337 <span class="preprocessor"></span>00338 <span class="comment">/* Use shared global buffer pointer for speed*/</span>00339 <span class="comment">/* Loop unrolled 16 times for SPEED! :) */</span>00340 <a class="code" href="buffer_8c.html#a1">dataBufPtr</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>;00341 <span class="keywordflow">while</span> (<a class="code" href="buffer_8c.html#a1">dataBufPtr</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>+512){00342 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00343 <a class="code" href="board_8h.html#a41">SPIWait</a>();00344 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00345 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00346 <a class="code" href="board_8h.html#a41">SPIWait</a>();00347 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00348 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00349 <a class="code" href="board_8h.html#a41">SPIWait</a>();00350 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00351 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00352 <a class="code" href="board_8h.html#a41">SPIWait</a>();00353 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00354 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00355 <a class="code" href="board_8h.html#a41">SPIWait</a>();00356 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00357 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00358 <a class="code" href="board_8h.html#a41">SPIWait</a>();00359 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00360 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00361 <a class="code" href="board_8h.html#a41">SPIWait</a>();00362 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00363 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00364 <a class="code" href="board_8h.html#a41">SPIWait</a>();00365 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00366 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00367 <a class="code" href="board_8h.html#a41">SPIWait</a>();00368 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00369 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00370 <a class="code" href="board_8h.html#a41">SPIWait</a>();00371 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00372 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00373 <a class="code" href="board_8h.html#a41">SPIWait</a>();00374 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00375 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00376 <a class="code" href="board_8h.html#a41">SPIWait</a>();00377 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00378 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00379 <a class="code" href="board_8h.html#a41">SPIWait</a>();00380 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00381 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00382 <a class="code" href="board_8h.html#a41">SPIWait</a>();00383 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00384 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00385 <a class="code" href="board_8h.html#a41">SPIWait</a>();00386 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00387 <a class="code" href="board_8h.html#a43">SPIPutCharWithoutWaiting</a>(0xff);00388 <a class="code" href="board_8h.html#a41">SPIWait</a>();00389 *<a class="code" href="buffer_8c.html#a1">dataBufPtr</a>++=<a class="code" href="board_8h.html#a44">SPI_RESULT_BYTE</a>;00390 }00391 00392 <span class="preprocessor">#ifdef MMCDEBUG</span>00393 <span class="preprocessor"></span> ConsoleWrite(<span class="stringliteral">"R>"</span>);00394 <span class="preprocessor">#endif</span>00395 <span class="preprocessor"></span>00396 }</div></pre> </td> </tr></table><a class="anchor" name="a9" doxytag="mmc.c::ReadPhysicalSector" ></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"> Public unsigned char ReadPhysicalSector </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>Perform block read of previously sought sector to diskSect. <p><p>Definition at line <a class="el" href="mmc_8c-source.html#l00477">477</a> of file <a class="el" href="mmc_8c-source.html">mmc.c</a>.<p>References <a class="el" href="board_8h-source.html#l00075">LED_OFF</a>, <a class="el" href="board_8h-source.html#l00072">LED_ON</a>, <a class="el" href="board_8h-source.html#l00159">MMC_NOT_SELECTED</a>, <a class="el" href="board_8h-source.html#l00156">MMC_SELECTED</a>, <a class="el" href="board_8h-source.html#l00153">MMC_XCS</a>, <a class="el" href="mmc_8c-source.html#l00102">MmcWaitForData()</a>, <a class="el" href="mmc_8c-source.html#l00332">PerformBlockRead()</a>, <a class="el" href="board_8h-source.html#l00262">Public</a>, <a class="el" href="board_8h-source.html#l00066">RED_LED</a>, and <a class="el" href="board_8c-source.html#l00026">SPI8Clocks()</a>.<p>Referenced by <a class="el" href="mmc_8c-source.html#l00249">InitMMC()</a>, and <a class="el" href="storage_8c-source.html#l00110">ReadDiskSector()</a>.<p><pre class="fragment"><div>00477 {00478 00479 <a class="code" href="board_8h.html#a10">RED_LED</a> = <a class="code" href="board_8h.html#a12">LED_ON</a>; <span class="comment">/* Disk Read LED on */</span>00480 00481 <a class="code" href="board_8h.html#a29">MMC_XCS</a> = <a class="code" href="board_8h.html#a30">MMC_SELECTED</a>;00482 <span class="comment">//ConsoleWrite("<wait>");</span>00483 <a class="code" href="mmc_8c.html#a1">MmcWaitForData</a>();00484 00485 <span class="comment">//ConsoleWrite("<read>");</span>00486 <a class="code" href="mmc_8c.html#a6">PerformBlockRead</a>();00487 00488 <span class="comment">//ConsoleWrite("<deselect>");</span>00489 <span class="comment">/* generate SPI clock edges to finish up the command */</span>00490 00491 <a class="code" href="board_8h.html#a48">SPI8Clocks</a>(4); <span class="comment">//Send 8*4=32 clocks (4 ff's) to MMC to be nice.</span>00492 <a class="code" href="board_8h.html#a29">MMC_XCS</a> = <a class="code" href="board_8h.html#a31">MMC_NOT_SELECTED</a>;00493 <a class="code" href="board_8h.html#a48">SPI8Clocks</a>(4); <span class="comment">//Again, give the poor MMC some clocks, it likes them.</span>00494 00495 <a class="code" href="board_8h.html#a10">RED_LED</a> = <a class="code" href="board_8h.html#a13">LED_OFF</a>; <span class="comment">/* Disk Read LED off */</span>00496 00497 <span class="keywordflow">return</span> 0; <span class="comment">//ok return</span>00498 }</div></pre><p>Here is the call graph for this function:<p><center><img src="mmc_8c_a9_cgraph.png" border="0" usemap="#mmc_8c_a9_cgraph_map" alt=""></center><map name="mmc_8c_a9_cgraph_map">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -