📄 mmc_8c.html
字号:
<td class="md" nowrap valign="top"> unsigned char RebootMMC </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>Try to switch on the MMC. <p><p>Definition at line <a class="el" href="mmc_8c-source.html#l00217">217</a> of file <a class="el" href="mmc_8c-source.html">mmc.c</a>.<p>References <a class="el" href="board_8c-source.html#l00036">Delay()</a>, <a class="el" href="mmc_8c-source.html#l00019">MmcCommand()</a>, and <a class="el" href="board_8c-source.html#l00026">SPI8Clocks()</a>.<p>Referenced by <a class="el" href="mmc_8c-source.html#l00246">InitMMC()</a>, and <a class="el" href="mmc_8c-source.html#l00431">SeekSector()</a>.<p><pre class="fragment"><div>00217 {00218 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c;00219 00220 <span class="comment">//Try (indefinitely) to switch on the MMC card</span>00221 <span class="keywordflow">do</span>{00222 <a class="code" href="board_8h.html#a50">SPI8Clocks</a>(8); 00223 <span class="comment">/* MMC Don't use CRC - seems to be required by some MMC cards? */</span>00224 <a class="code" href="mmc_8c.html#a0">MmcCommand</a>(0x7B,0,0,0,0);00225 <span class="comment">/* MMC Init, command 0x40 should return 0x01 (idle) if all is ok. */</span>00226 }<span class="keywordflow">while</span> (<a class="code" href="mmc_8c.html#a0">MmcCommand</a>(0x40,0,0,0,0)!=0x01);00227 <span class="comment">// 0x01(idle) response detected.</span>00228 00229 ConsoleWrite(<span class="stringliteral">"Card found, starting... "</span>);00230 <span class="comment">/*Try max 255 times MMC Wake-up call: set to Not Idle (mmc returns 0x00)*/</span>00231 c=255;00232 <span class="keywordflow">while</span> ((c--)&&(<a class="code" href="mmc_8c.html#a0">MmcCommand</a>(0x41,0,0,0,16))){00233 <a class="code" href="board_8h.html#a51">Delay</a>(10);00234 <span class="keywordflow">if</span> (c==1){00235 <span class="comment">//timeout</span>00236 ConsoleWrite(<span class="stringliteral">"Failed.\r"</span>);00237 <span class="keywordflow">return</span> 2; <span class="comment">/* Not able to power up mmc */</span>00238 }00239 }00240 00241 ConsoleWrite(<span class="stringliteral">"Ok.\r"</span>);00242 <span class="keywordflow">return</span> 0;00243 }</div></pre><p>Here is the call graph for this function:<p><center><img src="mmc_8c_a4_cgraph.png" border="0" usemap="#mmc_8c_a4_cgraph_map" alt=""></center><map name="mmc_8c_a4_cgraph_map"><area href="board_8h.html#a51" shape="rect" coords="309,9,349,33" alt=""><area href="mmc_8c.html#a0" shape="rect" coords="145,57,241,81" alt=""><area href="board_8h.html#a50" shape="rect" coords="292,105,366,129" alt=""><area href="board_8c.html#a1" shape="rect" coords="290,57,368,81" alt=""></map> </td> </tr></table><a class="anchor" name="a8" doxytag="mmc.c::SeekSector" ></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 SeekSector </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">unsigned long </td> <td class="mdname1" valign="top" nowrap> <em>sectorN</em> </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 MMC Seek Command for offset sectorN*512. <p>In English: Send the Read Sector command to MMC <p>Definition at line <a class="el" href="mmc_8c-source.html#l00431">431</a> of file <a class="el" href="mmc_8c-source.html">mmc.c</a>.<p>References <a class="el" href="unionAddress.html#o1">Address::b</a>, <a class="el" href="buffer_8h-source.html#l00131">Address::B::b0</a>, <a class="el" href="buffer_8h-source.html#l00132">Address::B::b1</a>, <a class="el" href="buffer_8h-source.html#l00133">Address::B::b2</a>, <a class="el" href="mmc_8c-source.html#l00397">ConsoleDecipherMMCResponse()</a>, <a class="el" href="buffer_8h-source.html#l00129">Address::l</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#l00280">Public</a>, <a class="el" href="mmc_8c-source.html#l00217">RebootMMC()</a>, and <a class="el" href="buffer_8c-source.html#l00015">sectorAddress</a>.<p>Referenced by <a class="el" href="mmc_8c-source.html#l00246">InitMMC()</a>, <a class="el" href="storage_8c-source.html#l00071">PrepareToReadDiskSector()</a>, and <a class="el" href="storage_8c-source.html#l00110">ReadDiskSector()</a>.<p><pre class="fragment"><div>00431 {00432 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c, retries;00433 00434 retries = 0;00435 <span class="keywordflow">do</span>{00436 retries++;00437 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> = sectorN * 2; <span class="comment">//convert to bytes (combined with 8bit shift)</span>00438 c=<a class="code" href="mmc_8c.html#a0">MmcCommand</a>(0x51,<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o2">b2</a>,<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o1">b1</a>,00439 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o0">b0</a>, 0);00440 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> = <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> >> 1; <span class="comment">//convert back to blocks</span>00441 00442 <span class="comment">// If MMC works properly, it returns Busy (== Not idle) at this stage. </span>00443 <span class="keywordflow">if</span> (c!=0x00){00444 <span class="keywordflow">if</span> (c != 0xff){ 00445 <span class="comment">//MMC returns something else than Busy or "Idle Bus", print what it is</span>00446 <a class="code" href="mmc_8c.html#a7">ConsoleDecipherMMCResponse</a>(c);00447 }00448 <span class="comment">// Something is wrong, take the standard action...</span>00449 <a class="code" href="mmc_8c.html#a4">RebootMMC</a>();00450 <span class="keywordflow">if</span> (retries > 10){ 00451 <span class="keywordflow">return</span> 7; <span class="comment">/* failed to execute mmc command */</span>00452 }00453 }00454 }<span class="keywordflow">while</span>(c!=0x00); <span class="comment">//repeat until we get busy signal from MMC.</span>00455 00456 <a class="code" href="board_8h.html#a33">MMCDeselect</a>();00457 00458 <span class="keywordflow">return</span> 0; <span class="comment">//ok return</span>00459 }</div></pre><p>Here is the call graph for this function:<p><center><img src="mmc_8c_a8_cgraph.png" border="0" usemap="#mmc_8c_a8_cgraph_map" alt=""></center><map name="mmc_8c_a8_cgraph_map"><area href="mmc_8c.html#a7" shape="rect" coords="270,9,465,33" alt=""><area href="mmc_8c.html#a0" shape="rect" coords="320,58,416,82" alt=""><area href="mmc_8c.html#a4" shape="rect" coords="142,108,222,132" alt=""><area href="board_8c.html#a1" shape="rect" coords="514,34,592,58" alt=""><area href="board_8h.html#a51" shape="rect" coords="533,96,573,120" alt=""><area href="board_8h.html#a50" shape="rect" coords="516,145,590,169" alt=""></map> </td> </tr></table><a class="anchor" name="a10" doxytag="mmc.c::WritePhysicalSector" ></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 WritePhysicalSector </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 MMC block write from <b>*dataBufPtr</b> to sector sectorAddress.l. <p><p>Definition at line <a class="el" href="mmc_8c-source.html#l00484">484</a> of file <a class="el" href="mmc_8c-source.html">mmc.c</a>.<p>References <a class="el" href="unionAddress.html#o1">Address::b</a>, <a class="el" href="buffer_8h-source.html#l00131">Address::B::b0</a>, <a class="el" href="buffer_8h-source.html#l00132">Address::B::b1</a>, <a class="el" href="buffer_8h-source.html#l00133">Address::B::b2</a>, <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="buffer_8h-source.html#l00129">Address::l</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="unionDiskBlock.html#o1">DiskBlock::raw</a>, <a class="el" href="buffer_8c-source.html#l00015">sectorAddress</a>, <a class="el" href="board_8c-source.html#l00026">SPI8Clocks()</a>, <a class="el" href="board_8c-source.html#l00018">SPIGetChar()</a>, <a class="el" href="board_8h-source.html#l00238">SPIPutCharWithoutWaiting</a>, and <a class="el" href="board_8h-source.html#l00232">SPIWait</a>.<p>Referenced by <a class="el" href="storage_8c-source.html#l00183">WriteDiskSector()</a>.<p><pre class="fragment"><div>00484 {00485 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c; 00486 00487 <span class="preprocessor">#ifdef MMCDEBUG</span>00488 <span class="preprocessor"></span> ConsoleWrite(<span class="stringliteral">"<W"</span>);00489 <span class="preprocessor">#endif </span>00490 <span class="preprocessor"></span>00491 00492 <span class="comment">//RED_LED = LED_ON;</span>00493 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> = <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> * 2; <span class="comment">//convert to bytes (combined with 8bit shift)</span>00494 c=<a class="code" href="mmc_8c.html#a0">MmcCommand</a>(0x40 | 24, <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o2">b2</a>, <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o1">b1</a>,00495 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o1">b</a>.<a class="code" href="structAddress_1_1B.html#o0">b0</a>, 0);00496 <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> = <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> >> 1; <span class="comment">//convert back to blocks</span>00497 00498 <span class="comment">//ConsolePutChar('w');</span>00499 <span class="comment">//ConsolePutHex8(c);</span>00500 00501 <span class="keywordflow">if</span> (c!=0x00) <span class="keywordflow">return</span> (c); <span class="comment">//Error - MMC did not go to write mode</span>00502 00503 <span class="comment">/*</span>00504 <span class="comment"> while (c!=0x00) { //wait for BUSY token, if you get 0x01(idle), it's an ERROR!</span>00505 <span class="comment"> c = SPIGetChar();</span>00506 <span class="comment"> ConsolePutHex8(c);</span>00507 <span class="comment"> } </span>00508 <span class="comment">*/</span> 00509 <a class="code" href="buffer_8c.html#a1"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -