找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 5634|回復(fù): 2
收起左側(cè)

VS1003&1053音頻解碼模塊資料下載 看過來,福利福利

[復(fù)制鏈接]
ID:184814 發(fā)表于 2017-3-30 16:25 | 顯示全部樓層 |閱讀模式
音頻解碼模塊看過來,福利福利,VS1003&1053音頻解碼模塊
0.png

VS1003中文數(shù)據(jù)手冊(cè).pdf:
0.png 0.png
mp3文件的數(shù)據(jù)格式_中文:
0.png


單片機(jī)源程序:
  1. /*
  2. * MP3模塊測(cè)試程序
  3. *
  4. * 用途:MP3模塊測(cè)試程序
  5. *       vs1003 的硬件測(cè)試程序,主控芯片為STC12LE5A60S2
  6. *       其他的微處理器(帶SPI接口的)只需稍加修改即可適用
  7. *       對(duì)于不帶硬SPI接口的微處理器可以用IO進(jìn)行SPI的時(shí)序模擬
  8. *
  9. * 作者                                        日期                                備注
  10. * Huafeng Lin                        20010/09/10                        新增
  11. * Huafeng Lin                        20010/09/10                        修改
  12. *
  13. */

  14. #include "vs1003.h"
  15. #include "MusicDataMP3.c"


  16. #include <intrins.h>

  17. #define uchar unsigned char
  18. #define uint unsigned int
  19. #define ulong unsigned long
  20. #define bool bit
  21. #define true 1
  22. #define flase 0


  23. //針對(duì)SD卡讀寫板調(diào)整引腳
  24. #define uint8 unsigned char

  25. sbit  MP3_XRESET  = P3^2;

  26. #define Mp3PutInReset()  { MP3_XRESET = 0; }

  27. #define Mp3ReleaseFromReset()  { MP3_XRESET =1; }

  28. sbit MP3_XCS = P3^3;

  29. #define Mp3SelectControl()  { MP3_XCS = 0; }

  30. #define Mp3DeselectControl()  { MP3_XCS = 1; }

  31. sbit MP3_XDCS  = P3^4;

  32. #define Mp3SelectData()                { MP3_XDCS = 0; }

  33. #define Mp3DeselectData()        { MP3_XDCS = 1; }

  34. sbit MP3_DREQ = P3^5;

  35. sbit c_SPI_SI = P1^5;
  36. sbit c_SPI_SO = P1^6;
  37. sbit c_SPI_CLK = P1^7;

  38. #define Macro_Set_SI_High()          c_SPI_SI = 1
  39. #define Macro_Set_SI_Low()          c_SPI_SI = 0
  40. #define Macro_Set_CLK_High()          c_SPI_CLK = 1
  41. #define Macro_Set_CLK_Low()          c_SPI_CLK = 0

  42. void LCD_write_english_string(unsigned char X,unsigned char Y,char *s);

  43. //#define SPIWait()        { while((S0SPSR & 0x80) == 0); }//等待SPI將數(shù)據(jù)發(fā)送完畢

  44. //#define SPI_RESULT_BYTE  S0SPDR

  45. //extern long volatile timeval; //用于延時(shí)的全局變量
  46. //1ms Delayfunction
  47. //void Delay(uchar ucDelayCount)
  48. void wait(uchar ucDelayCount)
  49. {
  50.         uchar ucTempCount;
  51.         uchar uci;

  52.         for(ucTempCount=0; ucTempCount<ucDelayCount; ucTempCount++)
  53.         {
  54. //                uci = 200;        //Err
  55. //                uci = 250;        //OK
  56.                 uci = 230;
  57.                 while(uci--)
  58.                 {
  59.                         _nop_();
  60.                    }
  61.         }
  62. }

  63. //#define wait(x) Delay(x)
  64. /**********************************************************/
  65. /*  函數(shù)名稱 :   MSPI_Init                                */
  66. /*  函數(shù)功能 : 初始化SPI接口,設(shè)置為主機(jī)。               */
  67. /*  參數(shù)     :  無                                        */
  68. /*  返回值   :  無                                        */
  69. /*--------------------------------------------------------*/
  70. void  MSPI_Init(void)
  71. {  
  72. /*
  73.         PINSEL0 = (PINSEL0 & 0xFFFF00FF) | 0x00005500;        //選擇 SPI
  74.         S0SPCCR = 0x08;                                        // SPI 時(shí)鐘設(shè)置
  75.         S0SPCR  = (0 << 3) |                                // CPHA = 0,
  76.                   (0 << 4) |                                // CPOL = 0,
  77.                   (1 << 5) |                                // MSTR = 1,
  78.                   (0 << 6) |                                // LSBF = 0,
  79.                   (0 << 7);                                // SPIE = 0,
  80. */
  81.         c_SPI_SO = 1;
  82.         MP3_DREQ = 1;

  83. }

  84. /**********************************************************/
  85. /*  函數(shù)名稱 :  InitPortVS1003                            */
  86. /*  函數(shù)功能 : MCU與vs1003接口的初始化                   */
  87. /*  參數(shù)     :  無                                        */
  88. /*  返回值   :  無                                        */
  89. /*--------------------------------------------------------*/
  90. void  InitPortVS1003(void)
  91. {
  92.         MSPI_Init();//SPI口的初始化
  93. //        IODIR &= 0xfffeffff;   //其他接口線的設(shè)置,其中dreq 為輸入口
  94. //        IODIR |= MP3_XRESET | MP3_XCS | MP3_XDCS;//xRESET,xCS,xDS均為輸出口
  95. //        IOSET |= MP3_XRESET | MP3_XCS | MP3_XDCS;//xRESET,xCS,xDS默認(rèn)輸出高電平       
  96.         MP3_DREQ = 1;                //置為輸入

  97.         MP3_XRESET = 1;
  98.         MP3_XCS = 1;
  99.         MP3_XDCS = 1;
  100. }

  101. //uint8 SD_SPI_ReadByte(void);
  102. //void SD_SPI_WriteByte(uint8 ucSendData);

  103. //#define SPI_RecByte()  SD_SPI_ReadByte()
  104. //#define SPIPutChar(x) SD_SPI_WriteByte(x)

  105. #if 1
  106. /**********************************************************/
  107. /*  函數(shù)名稱 :  SPIPutChar                                */
  108. /*  函數(shù)功能 : 通過SPI發(fā)送一個(gè)字節(jié)的數(shù)據(jù)                 */
  109. /*  參數(shù)     :  待發(fā)送的字節(jié)數(shù)據(jù)                          */
  110. /*  返回值   :  無                                        */
  111. /*--------------------------------------------------------*/
  112. void  SPIPutChar(unsigned char ucSendData)
  113. {      
  114. //        S0SPDR = c;
  115. //        while((S0SPSR & 0x80) == 0);         //等待SPI將數(shù)據(jù)發(fā)送完畢
  116.         uchar ucCount;
  117.         uchar ucMaskCode;

  118.         ucMaskCode = 0x80;
  119.         for(ucCount=0; ucCount<8; ucCount++)
  120.         {
  121.                 Macro_Set_CLK_Low();

  122.                 if(ucMaskCode & ucSendData)
  123.                 {
  124.                         Macro_Set_SI_High();
  125.                 }
  126.                 else
  127.                 {
  128.                         Macro_Set_SI_Low();
  129.                 }

  130.                 Macro_Set_CLK_High();
  131.                 ucMaskCode >>= 1;

  132.         }
  133. }

  134. /*******************************************************************************************************************
  135. ** 函數(shù)名稱: INT8U SPI_RecByte()                                Name:          INT8U SPI_RecByte()
  136. ** 功能描述: 從SPI接口接收一個(gè)字節(jié)                                Function: receive a byte from SPI interface
  137. ** 輸   入: 無                                                                        Input:          NULL
  138. ** 輸   出: 收到的字節(jié)                                                        Output:          the byte that be received
  139. ********************************************************************************************************************/
  140. static uchar SPI_RecByte(void)
  141. {
  142.         uchar ucReadData;
  143.         uchar ucCount;

  144.         ucReadData = 0;
  145.         Macro_Set_SI_High();

  146.         for(ucCount=0; ucCount<8; ucCount++)
  147.         {
  148.                 ucReadData <<= 1;
  149.                         //降低時(shí)鐘頻率
  150.                 Macro_Set_CLK_Low();

  151.        
  152.                 if(c_SPI_SO)
  153.                 {
  154.                         ucReadData |= 0x01;
  155.                 }
  156.                 Macro_Set_CLK_High();

  157.         }

  158.         return(ucReadData);
  159. }

  160. #endif

  161. /*************************************************************/
  162. /*  函數(shù)名稱 :  Mp3WriteRegister                             */
  163. /*  函數(shù)功能 : 寫vs1003寄存器                               */
  164. /*  參數(shù)     :  寄存器地址,待寫數(shù)據(jù)的高8位,待寫數(shù)據(jù)的低8位 */
  165. /*  返回值   :  無                                           */
  166. /*-----------------------------------------------------------*/
  167. void Mp3WriteRegister(unsigned char addressbyte, unsigned char highbyte, unsigned char lowbyte)
  168. {
  169.         Mp3DeselectData();
  170.         Mp3SelectControl();//XCS = 0
  171.         SPIPutChar(VS_WRITE_COMMAND); //發(fā)送寫寄存器命令
  172.         SPIPutChar(addressbyte);      //發(fā)送寄存器的地址
  173.         SPIPutChar(highbyte);         //發(fā)送待寫數(shù)據(jù)的高8位
  174.         SPIPutChar(lowbyte);          //發(fā)送待寫數(shù)據(jù)的低8位
  175.         Mp3DeselectControl();
  176. }

  177. /*************************************************************/
  178. /*  函數(shù)名稱 :  Mp3ReadRegister                              */
  179. /*  函數(shù)功能 : 寫vs1003寄存器                               */
  180. /*  參數(shù)     :  寄存器地址                                     */
  181. /*  返回值   :  vs1003的16位寄存器的值                       */
  182. /*-----------------------------------------------------------*/
  183. unsigned int Mp3ReadRegister(unsigned char addressbyte)
  184. {
  185.         unsigned int resultvalue = 0;
  186.         uchar ucReadValue;

  187.         Mp3DeselectData();
  188.         Mp3SelectControl();//XCS = 0
  189.         SPIPutChar(VS_READ_COMMAND); //發(fā)送讀寄存器命令
  190.         SPIPutChar((addressbyte));         //發(fā)送寄存器的地址

  191. //        SPIPutChar(0xff);                 //發(fā)送讀時(shí)鐘
  192. //        resultvalue = (SPI_RESULT_BYTE) << 8;//讀取高8位數(shù)據(jù)
  193.         ucReadValue = SPI_RecByte();
  194.         resultvalue = ucReadValue<<8;
  195. //        SPIPutChar(0xff);                   //發(fā)送讀時(shí)鐘
  196. //        resultvalue |= (SPI_RESULT_BYTE);  //讀取低8位數(shù)據(jù)
  197.         ucReadValue = SPI_RecByte();
  198.         resultvalue |= ucReadValue;

  199.         Mp3DeselectControl();              
  200.         return resultvalue;                 //返回16位寄存器的值
  201. }

  202. /**********************************************************/
  203. /*  函數(shù)名稱 :  Mp3SoftReset                              */
  204. /*  函數(shù)功能 : vs1003軟件復(fù)位                            */
  205. /*  參數(shù)     :  無                                        */
  206. /*  返回值   :  無                                        */
  207. /*--------------------------------------------------------*/
  208. void Mp3SoftReset(void)
  209. {
  210.         Mp3WriteRegister (SPI_MODE, 0x08, 0x04); //軟件復(fù)位

  211.         wait(1); //延時(shí)1ms
  212.         while (MP3_DREQ == 0); //等待軟件復(fù)位結(jié)束
  213.         Mp3WriteRegister(SPI_CLOCKF, 0x98, 0x00);//設(shè)置vs1003的時(shí)鐘,3倍頻
  214.         Mp3WriteRegister (SPI_AUDATA, 0xBB, 0x81); //采樣率48k,立體聲
  215.         Mp3WriteRegister(SPI_BASS, 0x00, 0x55);//設(shè)置重音
  216.         Mp3SetVolume(10,10);//設(shè)置音量
  217.     wait(1); //延時(shí)1ms
  218.            
  219.             //向vs1003發(fā)送4個(gè)字節(jié)無效數(shù)據(jù),用以啟動(dòng)SPI發(fā)送
  220.            Mp3SelectData();
  221.         SPIPutChar(0);
  222.         SPIPutChar(0);
  223.         SPIPutChar(0);
  224.         SPIPutChar(0);
  225.         Mp3DeselectData();

  226. }
  227. /**********************************************************/
  228. /*  函數(shù)名稱 :  Mp3Reset                                  */
  229. /*  函數(shù)功能 : vs1003硬件復(fù)位                            */
  230. /*  參數(shù)     :  無                                        */
  231. /*  返回值   :  無                                        */
  232. /*--------------------------------------------------------*/
  233. void Mp3Reset(void)
  234. {       
  235.         Mp3PutInReset();//xReset = 0   復(fù)位vs1003      
  236.         wait(200);//延時(shí)100ms
  237.         SPIPutChar(0xff);//發(fā)送一個(gè)字節(jié)的無效數(shù)據(jù),啟動(dòng)SPI傳輸
  238.         Mp3DeselectControl();   //xCS = 1
  239.         Mp3DeselectData();     //xDCS = 1
  240.         Mp3ReleaseFromReset(); //xRESET = 1
  241.         wait(200);            //延時(shí)100ms
  242.         while (MP3_DREQ == 0);//等待DREQ為高

  243.     wait(200);            //延時(shí)100ms
  244.         Mp3SetVolume(50,50);  
  245.     Mp3SoftReset();//vs1003軟復(fù)位
  246. }


  247. bool CheckVS1003B_DRQ(void)
  248. {
  249.         bool bResult;

  250.         bResult =MP3_DREQ;
  251.         return(bResult);
  252. }

  253. /***********************************************************/
  254. /*  函數(shù)名稱 :  VsSineTest                                 */
  255. /*  函數(shù)功能 : vs1003正弦測(cè)試,將該函數(shù)放在while循環(huán)中,  */
  256. /*              如果能持續(xù)聽到一高一低的聲音,證明測(cè)試通過 */                           
  257. /*  參數(shù)     :  無                                         */
  258. /*  返回值   :  無                                         */
  259. /*---------------------------------------------------------*/
  260. void VsSineTest(void)
  261. {
  262.         Mp3PutInReset();  //xReset = 0   復(fù)位vs1003
  263.         wait(200);        //延時(shí)100ms        
  264.         SPIPutChar(0xff);//發(fā)送一個(gè)字節(jié)的無效數(shù)據(jù),啟動(dòng)SPI傳輸
  265.         Mp3DeselectControl();  
  266.         Mp3DeselectData();     
  267.         Mp3ReleaseFromReset();
  268.         wait(200);                      
  269.         Mp3SetVolume(50,50);  

  270.         Mp3WriteRegister(SPI_MODE,0x08,0x20);//進(jìn)入vs1003的測(cè)試模式
  271.         while (MP3_DREQ == 0);     //等待DREQ為高
  272.         Mp3SelectData();       //xDCS = 1,選擇vs1003的數(shù)據(jù)接口
  273.        
  274.         //向vs1003發(fā)送正弦測(cè)試命令:0x53 0xef 0x6e n 0x00 0x00 0x00 0x00
  275.         //其中n = 0x24, 設(shè)定vs1003所產(chǎn)生的正弦波的頻率值,具體計(jì)算方法見vs1003的datasheet
  276.            SPIPutChar(0x53);      
  277.         SPIPutChar(0xef);      
  278.         SPIPutChar(0x6e);      
  279.         SPIPutChar(0x24);      
  280.         SPIPutChar(0x00);      
  281.         SPIPutChar(0x00);
  282.         SPIPutChar(0x00);
  283.         SPIPutChar(0x00);
  284. //        wait(500);
  285.         wait(250);
  286.         wait(250);
  287.         Mp3DeselectData();//程序執(zhí)行到這里后應(yīng)該能從耳機(jī)聽到一個(gè)單一頻率的聲音
  288.   
  289.         //退出正弦測(cè)試
  290.         Mp3SelectData();
  291.         SPIPutChar(0x45);
  292.         SPIPutChar(0x78);
  293.         SPIPutChar(0x69);
  294.         SPIPutChar(0x74);
  295.         SPIPutChar(0x00);
  296.         SPIPutChar(0x00);
  297.         SPIPutChar(0x00);
  298.         SPIPutChar(0x00);
  299. //        wait(500);
  300.         wait(250);
  301.         wait(250);

  302.         Mp3DeselectData();

  303.         //再次進(jìn)入正弦測(cè)試并設(shè)置n值為0x44,即將正弦波的頻率設(shè)置為另外的值
  304.     Mp3SelectData();      
  305.         SPIPutChar(0x53);      
  306.         SPIPutChar(0xef);      
  307.         SPIPutChar(0x6e);      
  308.         SPIPutChar(0x44);      
  309.         SPIPutChar(0x00);      
  310.         SPIPutChar(0x00);
  311.         SPIPutChar(0x00);
  312.         SPIPutChar(0x00);
  313. //        wait(500);
  314.         wait(250);
  315.         wait(250);

  316.         Mp3DeselectData();

  317.         //退出正弦測(cè)試
  318.         Mp3SelectData();
  319.         SPIPutChar(0x45);
  320.         SPIPutChar(0x78);
  321.         SPIPutChar(0x69);
  322.         SPIPutChar(0x74);
  323.         SPIPutChar(0x00);
  324.         SPIPutChar(0x00);
  325.         SPIPutChar(0x00);
  326.         SPIPutChar(0x00);
  327. //        wait(500);
  328.         wait(250);
  329.         wait(250);

  330.         Mp3DeselectData();
  331. }

  332. void test_1003_PlayMP3File();

  333. void TestVS1003B(void)
  334. {
  335.         Mp3Reset();
  336.         VsSineTest();
  337.         Mp3SoftReset();
  338.         test_1003_PlayMP3File();
  339. }

  340. //寫寄存器,參數(shù),地址和數(shù)據(jù)
  341. void VS1003B_WriteCMD(unsigned char addr, unsigned int dat)
  342. {
  343. /*
  344.         VS1003B_XDCS_H();
  345.         VS1003B_XCS_L();
  346.         VS1003B_WriteByte(0x02);
  347.         //delay_Nus(20);
  348.         VS1003B_WriteByte(addr);
  349.         VS1003B_WriteByte(dat>>8);
  350.         VS1003B_WriteByte(dat);
  351.         //delay_Nus(200);
  352.         VS1003B_XCS_H();
  353. */
  354.         Mp3WriteRegister(addr,dat>>8,dat);
  355. }

  356. //讀寄存器,參數(shù) 地址 返回內(nèi)容
  357. unsigned int VS1003B_ReadCMD(unsigned char addr)
  358. {
  359. /*
  360.         unsigned int temp;
  361.         unsigned char temp1;
  362.         VS1003B_XDCS_H();
  363.         VS1003B_XCS_L();
  364.         VS1003B_WriteByte(0x03);
  365.         //delay_Nus(20);
  366.         VS1003B_WriteByte(addr);
  367.         temp=  VS1003B_ReadByte();
  368.         temp=temp<<8;
  369.         temp1= VS1003B_ReadByte();
  370.         temp=temp|temp1;;
  371.         VS1003B_XCS_H();
  372.         return temp;
  373. */
  374.         return(Mp3ReadRegister(addr));
  375. }

  376. //寫數(shù)據(jù),音樂數(shù)據(jù)
  377. void VS1003B_WriteDAT(unsigned char dat)
  378. {
  379. //        VS1003B_XDCS_L();
  380. //        VS1003B_WriteByte(dat);
  381. //        VS1003B_XDCS_H();
  382. //        VS1003B_XCS_H();

  383.            Mp3SelectData();
  384.         SPIPutChar(dat);
  385.         Mp3DeselectData();
  386.         Mp3DeselectControl();

  387. }

  388. //開啟環(huán)繞聲
  389. void VS1003B_SetVirtualSurroundOn(void)
  390. {
  391.         uchar ucRepeatCount;
  392.         uint uiModeValue;

  393.         ucRepeatCount =0;

  394.         while(1)//寫時(shí)鐘寄存器
  395.         {
  396.                 uiModeValue = VS1003B_ReadCMD(0x00);
  397.                 if(uiModeValue & 0x0001)
  398.                 {
  399.                         break;
  400.                 }
  401.                 else
  402.                 {
  403.                         uiModeValue |= 0x0001;
  404.                         VS1003B_WriteCMD(0,uiModeValue);
  405.                 }
  406.                 ucRepeatCount++;
  407.                 if(ucRepeatCount++ >10 )break;
  408.         }

  409. }

  410. //關(guān)閉環(huán)繞聲
  411. void VS1003B_SetVirtualSurroundOff(void)
  412. {
  413.         uchar ucRepeatCount;
  414.         uint uiModeValue;

  415.         ucRepeatCount =0;

  416.         while(1)//寫時(shí)鐘寄存器
  417.         {
  418.                 uiModeValue = VS1003B_ReadCMD(0x00);
  419.                 if(uiModeValue & 0x0001)
  420.                 {
  421.                         break;
  422.                 }
  423.                 else
  424.                 {
  425.                         uiModeValue |= 0x0001;
  426.                         VS1003B_WriteCMD(0,uiModeValue);
  427.                 }
  428.                 ucRepeatCount++;
  429.                 if(ucRepeatCount++ >10 )break;
  430.         }

  431. }

  432. //增強(qiáng)重音
  433. //入口參數(shù)        1.強(qiáng)度0-15
  434. //                        2.頻率0-15 (X10Hz)
  435. void VS1003B_SetBassEnhance(uchar ucValue, ucFrequencyID)
  436. {
  437.         uchar ucRepeatCount;
  438.         uint uiWriteValue;
  439.         uint uiReadValue;       

  440.         ucRepeatCount =0;

  441.         uiWriteValue = VS1003B_ReadCMD(0x02);

  442.         uiWriteValue &= 0xFF00;
  443.         uiWriteValue |= ucValue<<4;
  444.         uiWriteValue &= (ucFrequencyID & 0x0F);

  445.         while(1)//寫時(shí)鐘寄存器
  446.         {

  447.                 VS1003B_WriteCMD(2,uiWriteValue);
  448.                 uiReadValue = VS1003B_ReadCMD(0x02);
  449.                
  450.                 if(uiReadValue == uiWriteValue)
  451.                 {
  452.                         break;
  453.                 }
  454.                 ucRepeatCount++;
  455.                 if(ucRepeatCount++ >10 )break;
  456.         }

  457. }


  458. uint uiVolumeCount;                //當(dāng)前音量值

  459. //VS1003初始化,0成功 1失敗
  460. unsigned char VS1003B_Init()
  461. {
  462.         unsigned char retry;
  463. /*
  464.         PORT_INI();
  465.         DDRB|=0xa0;
  466.         VS1003B_DDR &=~(1<<VS1003B_DREQ);
  467.         //delay_Nus(50);
  468.         VS1003B_XCS_H();
  469.         VS1003B_XDCS_H();
  470.         VS1003B_XRESET_L();
  471.         VS1003B_Delay(0xffff);
  472.         VS1003B_XRESET_H();//使能芯片
  473.         VS1003B_SPI_Low();//先以低頻操作
  474.         VS1003B_Delay(0xffff);//延時(shí)
  475. */
  476. Mp3Reset();

  477.         retry=0;
  478.         while(VS1003B_ReadCMD(0x00) != 0x0800)//寫mode寄存器
  479.         {
  480.                 VS1003B_WriteCMD(0x00,0x0800);
  481.                 if(retry++ >10 )break;//{PORTB|=_BV(PB1);break;}
  482.         }
  483.         retry=0;
  484.         /*while(VS1003B_ReadCMD(0x02) != 0x75)//寫mode寄存器
  485.         {
  486.                 VS1003B_WriteCMD(0x02,0x75);
  487.                 if(retry++ >10 )break;//{PORTB|=_BV(PB1);break;}
  488.         }*/
  489.         retry=0;
  490.         while(VS1003B_ReadCMD(0x03) != 0x9800)//寫時(shí)鐘寄存器
  491.         {
  492.                 VS1003B_WriteCMD(0x03,0x9800);
  493.                 if(retry++ >10 )break;
  494.         }
  495.         retry=0;
  496. //        while(VS1003B_ReadCMD(0x0b) != 0x1111)//設(shè)音量
  497. //        {
  498. //                VS1003B_WriteCMD(0x0b,0x1111);
  499. //                if(retry++ >10 )break;
  500. //        }
  501.         while(VS1003B_ReadCMD(0x0b) != uiVolumeCount)//設(shè)音量
  502.         {
  503.                 VS1003B_WriteCMD(0x0b,uiVolumeCount);
  504.                 if(retry++ >10 )break;
  505.         }

  506. //        VS1003B_SPI_High();//提高速度,全速運(yùn)行
  507.         if(retry > 10)return 1;
  508.         return 0;
  509. }

  510. //VS1003軟件復(fù)位
  511. void VS1003B_SoftReset()
  512. {
  513.         VS1003B_WriteCMD(0x00,0x0804);//寫復(fù)位
  514. //        VS1003B_Delay(0xffff);//延時(shí),至少1.35ms
  515.         wait(2);
  516. }

  517. void VS1003B_Fill2048Zero()
  518. {
  519.         unsigned char i,j;

  520.         for(i=0;i<64;i++)
  521.         {
  522.                 if(CheckVS1003B_DRQ())
  523.                 {
  524.                         Mp3SelectData();

  525.                         for(j=0;j<32;j++)
  526.                         {

  527.                                 VS1003B_WriteDAT(0x00);
  528.                         }
  529.                         Mp3DeselectData();
  530.                 }
  531.         }
  532. }


  533. void test_1003_PlayMP3File()
  534. {
  535.    unsigned int data_pointer;unsigned char i;
  536.         unsigned int uiCount;

  537.         uiCount = sizeof(MusicData);
  538.         data_pointer=0;
  539.         VS1003B_SoftReset();
  540.     while(uiCount>0)
  541.           {
  542.            if(CheckVS1003B_DRQ())
  543.               {
  544.                     for(i=0;i<32;i++)
  545.                    {
  546.                              VS1003B_WriteDAT(MusicData[data_pointer]);
  547.                              data_pointer++;
  548.             }
  549.                         uiCount -= 32;
  550.          }
  551.     }
  552.         VS1003B_Fill2048Zero();
  553. }
復(fù)制代碼

0.png
0.png

下載:
VS1003B MP3解碼模塊 載咪頭 STM32單片機(jī)開發(fā)板.rar (6.28 MB, 下載次數(shù): 65)
回復(fù)

使用道具 舉報(bào)

ID:185829 發(fā)表于 2017-5-6 10:06 | 顯示全部樓層
stc51還是stm32?
回復(fù)

使用道具 舉報(bào)

ID:691028 發(fā)表于 2023-4-26 09:21 | 顯示全部樓層
雖然沒有源代碼,但是還是很好的資料,感謝樓主的共享!
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表