📄 mmc_8c.html
字号:
00198 <span class="comment">//mediaSerialNumber[1] = diskSect.raw.buf[11];</span>00199 <span class="comment">//mediaSerialNumber[2] = diskSect.raw.buf[12];</span>00200 <span class="comment">//mediaSerialNumber[3] = diskSect.raw.buf[13];</span>00201 00202 ConsolePutChar(<span class="charliteral">'\r'</span>);00203 00204 <span class="comment">/* print out card ident register</span>00205 <span class="comment"> for (c=0; c<30; c++){</span>00206 <span class="comment"> if ((c&0x03)==0) ConsolePutChar(' ');</span>00207 <span class="comment"> ConsolePutHex8(diskSect.raw.buf[c]);</span>00208 <span class="comment"> }</span>00209 <span class="comment"> */</span>00210 00211 <span class="keywordflow">return</span> 0; <span class="comment">/* All OK return */</span>00212 }</div></pre><p>Here is the call graph for this function:<p><center><img src="mmc_8c_a3_cgraph.png" border="0" usemap="#mmc_8c_a3_cgraph_map" alt=""></center><map name="mmc_8c_a3_cgraph_map"><area href="mmc_8c.html#a0" shape="rect" coords="212,31,308,55" alt=""><area href="mmc_8c.html#a2" shape="rect" coords="217,126,302,150" alt=""><area href="mmc_8c.html#a1" shape="rect" coords="205,79,314,102" alt=""><area href="board_8h.html#a51" shape="rect" coords="384,7,424,31" alt=""><area href="board_8h.html#a50" shape="rect" coords="366,55,441,79" alt=""><area href="board_8c.html#a1" shape="rect" coords="365,102,442,126" alt=""></map> </td> </tr></table><a class="anchor" name="a5" doxytag="mmc.c::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"> Public 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 00317 ConsoleWrite(<span class="stringliteral">"\rInitMMC ok.\r"</span>);00318 }00319 00320 <span class="comment">/* All OK return */</span>00321 <span class="keywordflow">return</span> 0; <span class="comment">//ok and MMC supports seek-before-read</span>00322 00323 }</div></pre><p>Here is the call graph for this function:<p><center><img src="mmc_8c_a5_cgraph.png" border="0" usemap="#mmc_8c_a5_cgraph_map" alt=""></center><map name="mmc_8c_a5_cgraph_map"><area href="board_8h.html#a51" shape="rect" coords="673,58,713,82" alt=""><area href="mmc_8c.html#a3" shape="rect" coords="276,254,412,278" alt=""><area href="mmc_8c.html#a0" shape="rect" coords="500,158,596,182" alt=""><area href="mmc_8c.html#a9" shape="rect" coords="281,305,406,329" alt=""><area href="mmc_8c.html#a4" shape="rect" coords="304,57,384,81" alt=""><area href="mmc_8h.html#a2" shape="rect" coords="121,142,199,166" alt=""><area href="mmc_8c.html#a2" shape="rect" coords="505,206,590,230" alt=""><area href="mmc_8c.html#a1" shape="rect" coords="493,254,602,278" alt=""><area href="board_8h.html#a50" shape="rect" coords="656,206,730,230" alt=""><area href="mmc_8c.html#a6" shape="rect" coords="490,353,605,377" alt=""><area href="mmc_8c.html#a7" shape="rect" coords="247,105,441,129" alt=""></map> </td> </tr></table><a class="anchor" name="a0" doxytag="mmc.c::MmcCommand" ></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 MmcCommand </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">unsigned char </td> <td class="mdname" nowrap> <em>c1</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned char </td> <td class="mdname" nowrap> <em>c2</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned char </td> <td class="mdname" nowrap> <em>c3</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned char </td> <td class="mdname" nowrap> <em>c4</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned char </td> <td class="mdname" nowrap> <em>c5</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -