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

📄 vs10xx_8c.html

📁 MP3播放器源代码, VS1003B
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<area href="board_8h.html#a51" shape="rect" coords="272,33,312,57" alt=""><area href="vs10xx_8c.html#a2" shape="rect" coords="132,57,222,81" alt=""></map>    </td>  </tr></table><a class="anchor" name="a2" doxytag="vs10xx.c::Mp3SoftReset" ></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 Mp3SoftReset           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Soft Reset of VS10xx (Between songs). <p><p>Definition at line <a class="el" href="vs10xx_8c-source.html#l00035">35</a> of file <a class="el" href="vs10xx_8c-source.html">vs10xx.c</a>.<p>References <a class="el" href="board_8c-source.html#l00036">Delay()</a>, <a class="el" href="board_8h-source.html#l00070">MP3_DREQ</a>, <a class="el" href="board_8h-source.html#l00061">Mp3DeselectData</a>, <a class="el" href="board_8h-source.html#l00058">Mp3SelectData</a>, <a class="el" href="vs10xx_8h-source.html#l00068">Mp3WriteRegister</a>, <a class="el" href="vs10xx_8h-source.html#l00022">SPI_CLOCKF</a>, <a class="el" href="vs10xx_8h-source.html#l00019">SPI_MODE</a>, <a class="el" href="board_8h-source.html#l00235">SPIPutChar</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="player_8c-source.html#l00765">main()</a>, and <a class="el" href="vs10xx_8c-source.html#l00069">Mp3Reset()</a>.<p><pre class="fragment"><div>00035                    {00036 00037   <span class="comment">/* Soft Reset of VS10xx */</span>00038   <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a> (SPI_MODE, 0x08, 0x04); <span class="comment">/* Newmode, Reset, No L1-2 */</span>00039 00040   <a class="code" href="board_8h.html#a51">Delay</a>(1); <span class="comment">/* One millisecond delay */</span>00041   <span class="keywordflow">while</span> (!<a class="code" href="board_8h.html#a9">MP3_DREQ</a>) <span class="comment">/* wait for startup */</span>00042     ;00043   00044   <span class="comment">/* Set clock register, doubler etc. */</span>00045 <span class="preprocessor">#ifdef VS1003</span>00046 <span class="preprocessor"></span>  <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(SPI_CLOCKF, 0xa6, 0x96);00047 <span class="preprocessor">#else</span>00048 <span class="preprocessor"></span>  <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(SPI_CLOCKF, 156, 204);00049 <span class="preprocessor">#endif</span>00050 <span class="preprocessor"></span>  00051   <a class="code" href="board_8h.html#a51">Delay</a>(1); <span class="comment">/* One millisecond delay */</span>00052 00053  00054   <span class="comment">/* Send null bytes to data interface */</span>00055   <a class="code" href="board_8h.html#a7">Mp3SelectData</a>();00056   <a class="code" href="board_8h.html#a45">SPIPutCharWithoutWaiting</a>(0);00057   <a class="code" href="board_8h.html#a44">SPIPutChar</a>(0);00058   <a class="code" href="board_8h.html#a44">SPIPutChar</a>(0);00059   <a class="code" href="board_8h.html#a44">SPIPutChar</a>(0);00060   <a class="code" href="board_8h.html#a43">SPIWait</a>();00061   <a class="code" href="board_8h.html#a8">Mp3DeselectData</a>();00062 00063 }</div></pre><p>Here is the call graph for this function:<p><center><img src="vs10xx_8c_a2_cgraph.png" border="0" usemap="#vs10xx_8c_a2_cgraph_map" alt=""></center><map name="vs10xx_8c_a2_cgraph_map"><area href="board_8h.html#a51" shape="rect" coords="157,7,197,30" alt=""></map>    </td>  </tr></table><a class="anchor" name="a6" doxytag="vs10xx.c::PlayDiskSectors" ></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 PlayDiskSectors           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">unsigned int&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>nSectorsToPlay</em>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Play disk sectors from disk. <p>Starting from current value in global variable sectorAddress, sends a number of disk sectors to vs10xx and returns. <p>How many sectors to send between ff/rew commands <p>Definition at line <a class="el" href="vs10xx_8c-source.html#l00202">202</a> of file <a class="el" href="vs10xx_8c-source.html">vs10xx.c</a>.<p>References <a class="el" href="player_8c-source.html#l00332">AvailableProcessorTime()</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="board_8h-source.html#l00081">GREEN_LED</a>, <a class="el" href="buffer_8h-source.html#l00129">Address::l</a>, <a class="el" href="board_8h-source.html#l00087">LED_OFF</a>, <a class="el" href="board_8h-source.html#l00084">LED_ON</a>, <a class="el" href="board_8h-source.html#l00070">MP3_DREQ</a>, <a class="el" href="board_8h-source.html#l00061">Mp3DeselectData</a>, <a class="el" href="vs10xx_8c-source.html#l00017">Mp3ReadRegister()</a>, <a class="el" href="board_8h-source.html#l00058">Mp3SelectData</a>, <a class="el" href="vs10xx_8h-source.html#l00068">Mp3WriteRegister</a>, <a class="el" href="aviplay_8c-source.html#l00144">PlayAvi()</a>, <a class="el" href="player_8c-source.html#l00226">playingState</a>, <a class="el" href="storage_8c-source.html#l00071">PrepareToReadDiskSector()</a>, <a class="el" href="ui_8h.html#a25a16">PS_CUE</a>, <a class="el" href="ui_8h.html#a25a18">PS_CUE_ACTION</a>, <a class="el" href="ui_8h.html#a25a17">PS_CUE_WAIT1003</a>, <a class="el" href="ui_8h.html#a25a13">PS_END_OF_SONG</a>, <a class="el" href="ui_8h.html#a25a21">PS_FALLBACK_1</a>, <a class="el" href="ui_8h.html#a25a22">PS_FALLBACK_N</a>, <a class="el" href="ui_8h.html#a25a14">PS_NEXT_SONG</a>, <a class="el" href="ui_8h.html#a25a12">PS_NORMAL</a>, <a class="el" href="ui_8h.html#a25a15">PS_PREVIOUS_SONG</a>, <a class="el" href="ui_8h.html#a25a23">PS_RECORDING</a>, <a class="el" href="ui_8h.html#a25a20">PS_REW_WAIT1003</a>, <a class="el" href="ui_8h.html#a25a19">PS_REWIND</a>, <a class="el" href="unionDiskBlock.html#o1">DiskBlock::raw</a>, <a class="el" href="storage_8c-source.html#l00110">ReadDiskSector()</a>, <a class="el" href="buffer_8c-source.html#l00015">sectorAddress</a>, <a class="el" href="vs10xx_8c-source.html#l00178">SendZerosToVS10xx()</a>, <a class="el" href="vs10xx_8h-source.html#l00033">SPI_AICTRL2</a>, <a class="el" href="vs10xx_8h-source.html#l00028">SPI_HDAT1</a>, <a class="el" href="board_8h-source.html#l00235">SPIPutChar</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="player_8c-source.html#l00724">PlayCurrentFile()</a>.<p><pre class="fragment"><div>00202                                                            {00203   00205   <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> fallbackCount = 0;00206 00207 00208 <span class="preprocessor">#ifdef AVIPLAY</span>00209 <span class="preprocessor"></span>  <span class="keywordflow">if</span> (!<a class="code" href="aviplay_8c.html#a6">PlayAvi</a>()) <span class="keywordflow">return</span> 0; <span class="comment">//try to play AVI file soundtrack starting from</span>00210                             <span class="comment">//current sector, if avifile is played, return.</span>00211 <span class="preprocessor">#endif</span>00212 <span class="preprocessor"></span>00213 00214   <a class="code" href="storage_8h.html#a1">PrepareToReadDiskSector</a>(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>);00215   <span class="keywordflow">while</span> (nSectorsToPlay--){00216 00217     <a class="code" href="player_8c.html#a12">AvailableProcessorTime</a>();00218 00219     <a class="code" href="storage_8h.html#a2">ReadDiskSector</a>(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>);00220 00221     <span class="comment">/* If playing state is something else than "play normally",</span>00222 <span class="comment">       exit returning the request number. */</span>00223     <span class="keywordflow">if</span> ((<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a13">PS_END_OF_SONG</a>)||00224         (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a14">PS_NEXT_SONG</a>)||00225         (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a23">PS_RECORDING</a>)||00226         (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a15">PS_PREVIOUS_SONG</a>)){00227       <span class="keywordflow">return</span> <a class="code" href="player_8c.html#a3">playingState</a>;00228     }00229 00230 00231     <span class="comment">/* === REWIND / FAST FORWARD FUNCTIONALITY CODE BEGINS === */</span>00232     <span class="comment">/* If you don't implement rewind / fast forward, leave these lines out */</span>00233 00234     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a22">PS_FALLBACK_N</a>){00235       <span class="keywordflow">if</span> ((--fallbackCount)==0){00236         <a class="code" href="player_8c.html#a3">playingState</a>=<a class="code" href="ui_8h.html#a25a12">PS_NORMAL</a>;00237       }00238     }00239 00240     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a21">PS_FALLBACK_1</a>){00241       <span class="comment">/* Now we should have brand new sector in memory ready for sending to</span>00242 <span class="comment">         VS1003, so let's send zeroes between old and new data. */</span>00243       ConsoleWrite(<span class="stringliteral">"(Zeros)"</span>);00244       <a class="code" href="vs10xx_8c.html#a5">SendZerosToVS10xx</a>();00245       ConsoleWrite(<span class="stringliteral">"-&gt;Fallback to normal"</span>);00246       fallbackCount = 24;00247       <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a22">PS_FALLBACK_N</a>;00248     }00249 00250 00251     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a16">PS_CUE</a>){ <span class="comment">//Request to start fast forward      </span>00252       <span class="keywordflow">if</span> (<a class="code" href="vs10xx_8h.html#a38">Mp3ReadRegister</a>(SPI_HDAT1)==((<span class="keywordtype">int</span>)<span class="charliteral">'W'</span>&lt;&lt; 8)+<span class="charliteral">'m'</span>){00253         ConsoleWrite(<span class="stringliteral">"\rWmCUE-&gt;Wait"</span>);00254         <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(SPI_AICTRL2, 0x12, 0x34);00255         <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a17">PS_CUE_WAIT1003</a>;00256       }<span class="keywordflow">else</span>{00257         <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a18">PS_CUE_ACTION</a>;00258       }00259     }00260     00261     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a17">PS_CUE_WAIT1003</a>){ <span class="comment">//Wait for permission to break data flow</span>00262       <span class="keywordflow">if</span> (<a class="code" href="vs10xx_8h.html#a38">Mp3ReadRegister</a>(SPI_AICTRL2)==0x2345){ <span class="comment">//permission granted</span>00263         ConsoleWrite(<span class="stringliteral">"-&gt;Action"</span>);00264         <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a18">PS_CUE_ACTION</a>;00265       }00266     }00267     00268     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a18">PS_CUE_ACTION</a>){00269       <span class="keywordflow">if</span> (nSectorsToPlay&gt;128){00270         <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> += 128; <span class="comment">//Skip sectors</span>00271         nSectorsToPlay -= 128;00272         <span class="comment">//adjust vs1003 song left </span>00273         ConsoleWrite(<span class="stringliteral">"-&gt;Fallback(5)"</span>);00274         <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a21">PS_FALLBACK_1</a>; <span class="comment">//Sector already in memory still goes.</span>00275       }00276     }00277 00278     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a19">PS_REWIND</a>){ <span class="comment">//Request to start fast forward      </span>00279       <a class="code" href="vs10xx_8h.html#a32">Mp3WriteRegister</a>(SPI_AICTRL2, 0x12, 0x34);00280       <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a20">PS_REW_WAIT1003</a>;00281     }00282 00283     <span class="keywordflow">if</span> (<a class="code" href="player_8c.html#a3">playingState</a>==<a class="code" href="ui_8h.html#a25a20">PS_REW_WAIT1003</a>){ <span class="comment">//Wait for permission to break data flow</span>00284       <span class="keywordflow">if</span> (1){00285         <span class="keywordflow">if</span> (1 || (<a class="code" href="vs10xx_8h.html#a38">Mp3ReadRegister</a>(SPI_AICTRL2)==0x2345)){ <span class="comment">//permission granted</span>00286           <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a> -= 128;00287           nSectorsToPlay += 128;00288           <a class="code" href="player_8c.html#a3">playingState</a> = <a class="code" href="ui_8h.html#a25a21">PS_FALLBACK_1</a>; <span class="comment">//Sector already in memory still goes.</span>00289         }00290       }00291     }00292     00293 00294     <span class="comment">/* === END OF REWIND / FAST FORWARD FUNCTIONALITY CODE === */</span>00295     00296  00297   00298     <a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>++;00299     <span class="keywordflow">if</span> (nSectorsToPlay){00300       <span class="comment">/*Do not seek after the last sector*/</span>00301       <a class="code" href="storage_8h.html#a1">PrepareToReadDiskSector</a>(<a class="code" href="buffer_8c.html#a2">sectorAddress</a>.<a class="code" href="unionAddress.html#o0">l</a>);00302     }00303 00304     <a class="code" href="board_8h.html#a7">Mp3SelectData</a>();00305 00306     <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>;00307     <span class="keywordflow">while</span> (<a class="code" href="buffer_8c.html#a1">dataBufPtr</a> &lt; <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){00308 00309       <span class="keywordflow">if</span> (!<a class="code" href="board_8h.html#a9">MP3_DREQ</a>){00310         <a class="code" href="board_8h.html#a11">GREEN_LED</a> = <a class="code" href="board_8h.html#a12">LED_ON</a>;00311         <span class="keywordflow">while</span> (!<a class="code" href="board_8h.html#a9">MP3_DREQ</a>){00312           <a class="code" href="board_8h.html#a8">Mp3DeselectData</a>();00313           <a class="code" href="player_8c.html#a12">AvailableProcessorTime</a>();00314           <a class="code" href="board_8h.html#a7">Mp3SelectData</a>();

⌨️ 快捷键说明

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