您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > 基于STM32的MP3播放器设计与实现(-电子系统设计论坛
///||[2010831]|||||||TV|||||||EDA/IC|/|||/||||||/STM32MP3(MDK2008-9-92:40Thankstar13548--STM32MP3PlayerSTM32SPISDTIMERFATUSBSTM103V100TIM4PWMwavSDTIM41MP3MP3SD2SDFAT16VS100312MP3Player1SDSTM103V100SDSPISTM3233SDSTM32SPISDSecureDigitalMemoryCardSDSDSPISPISPISTM32SDSDSD44SDSDCLK025MHzSD025MHzCMDDAT03SDSDSPI6SD1SDIIC-China20102010IIC1)2)3)LEDFPGAMCUHDMIPCBARMGPSDSPUSB--------------1SPIByte1/Byte2-5/Byte67,6,5,0/31,0/7,00,1/Command/CommandArgument/CRC,1------------------------------------SDSDu8MSD_ReadBlock(u8*pBuffer,u32ReadAddr,u16NumByteToRead);/******************************************************************FunctionName:MSD_ReadBlock*Description:ReadsablockofdatafromtheMSD.*Input:-pBuffer:pointertothebufferthatreceivesthedataread*fromtheMSD.*-ReadAddr:MSD'sinternaladdresstoreadfrom.*-NumByteToRead:numberofbytestoreadfromtheMSD.*Output:None*Return:TheMSDResponse:-MSD_RESPONSE_FAILURE:Sequencefailed*-MSD_RESPONSE_NO_ERROR:Sequencesucceed*****************************************************************/u8MSD_ReadBlock(u8*pBuffer,u32ReadAddr,u16NumByteToRead){u32i=0;u8rvalue=MSD_RESPONSE_FAILURE;/*MSDchipselectlow*/MSD_CS_LOW();/*SendCMD17(MSD_READ_SINGLE_BLOCK)toreadoneblock*/MSD_SendCmd(MSD_READ_SINGLE_BLOCK,ReadAddr,0xFF);/*CheckiftheMSDacknowledgedthereadblockcommand:R1response(0x00:noerrors)*/if(!MSD_GetResponse(MSD_RESPONSE_NO_ERROR)){/*Nowlookforthedatatokentosignifythestartofthedata*/if(!MSD_GetResponse(MSD_START_DATA_SINGLE_BLOCK_READ)){/*ReadtheMSDblockdata:readNumByteToReaddata*/for(i=0;iNumByteToRead;i++){/*Savethereceiveddata*/*pBuffer=MSD_ReadByte();/*Pointtothenextlocationwherethebytereadwillbesaved*/pBuffer++;}/*GetCRCbytes(notreallyneededbyus,butrequiredbyMSD)*/MSD_ReadByte();MSD_ReadByte();/*Setresponsevaluetosuccess*/rvalue=MSD_RESPONSE_NO_ERROR;}}/*MSDchipselecthigh*/MSD_CS_HIGH();/*Senddummybyte:8Clockpulsesofdelay*/MSD_WriteByte(DUMMY);/*Returnsthereponse*/returnrvalue;}SDu8MSD_WriteBlock(u8*pBuffer,u32WriteAddr,u16NumByteToWrite)/******************************************************************FunctionName:MSD_WriteBlock*Description:WritesablockontheMSD*Input:-pBuffer:pointertothebuffercontainingthedatatobe*writtenontheMSD.*-WriteAddr:addresstowriteon.*-NumByteToWrite:numberofdatatowrite*Output:None*Return:TheMSDResponse:-MSD_RESPONSE_FAILURE:Sequencefailed*-MSD_RESPONSE_NO_ERROR:Sequencesucceed*****************************************************************/u8MSD_WriteBlock(u8*pBuffer,u32WriteAddr,u16NumByteToWrite){u32i=0;u8rvalue=MSD_RESPONSE_FAILURE;/*MSDchipselectlow*/MSD_CS_LOW();20106??“”??ADC,DAC?PCBPCB??1PCB?PCB???LED()?ARM()?C105?()?FPGA99/*SendCMD24(MSD_WRITE_BLOCK)towritemultipleblock*/MSD_SendCmd(MSD_WRITE_BLOCK,WriteAddr,0xFF);/*CheckiftheMSDacknowledgedthewriteblockcommand:R1response(0x00:noerrors)*/if(!MSD_GetResponse(MSD_RESPONSE_NO_ERROR)){/*Sendadummybyte*/MSD_WriteByte(DUMMY);/*Sendthedatatokentosignifythestartofthedata*/MSD_WriteByte(0xFE);/*WritetheblockdatatoMSD:writecountdatabyblock*/for(i=0;iNumByteToWrite;i++){/*Sendthepointedbyte*/MSD_WriteByte(*pBuffer);/*Pointtothenextlocationwherethebytereadwillbesaved*/pBuffer++;}/*PutCRCbytes(notreallyneededbyus,butrequiredbyMSD)*/MSD_ReadByte();MSD_ReadByte();/*Readdataresponse*/if(MSD_GetDataResponse()==MSD_DATA_OK){rvalue=MSD_RESPONSE_NO_ERROR;}}/*MSDchipselecthigh*/MSD_CS_HIGH();/*Senddummybyte:8Clockpulsesofdelay*/MSD_WriteByte(DUMMY);/*Returnsthereponse*/returnrvalue;}STM32MP3MDKThankstar2008-9-92:52(4)(0)1STM32MP3(MDK2008-9-92:40Thankstar13548--2FAT16SDFAT165MBRDBRFATFDTDATASDMBRDBRDBRBPBBiosParameterBlockMBRBPBFATDBRtypedef__packedstruct{/*Cortex-M3“”__packed“”*/u8BS_jmpBoot[3];//ofs:0.0xEB,0x3E,0x90u8BS_OEMName[8];//ofs:3.“MSWIN4.1”u16BPB_BytesPerSec;//ofs:11.u8BPB_SecPerClus;//ofs:13.u16BPB_RsvdSecCnt;//ofs:14.DBRFATu8BPB_NumFATs;//ofs:16.FAT2u16BPB_RootEntCnt;//ofs:17.()FPGARFPCBWLANandRFCircuit--WiFi...cEMC——FCCPART15FPGAARMLEDPK3DLEDUSBHDMILEDu16BPB_TotSec16;//ofs:19.32Mu8BPB_Media;//ofs:21.SD0xF8u16BPB_FATSz16;//ofs:22.FATu16BPB_SecPerTrk;//ofs:24.SDu16BPB_NumHeads;//ofs:26.SDu32BPB_HiddSec;//ofs:28.MBRDBRu32BPB_TotSec32;//ofs:32.≥32Mu8BS_DrvNum;//ofs:36.0x000x80SDu8BS_Reservedl;//ofs:37.u8BS_BootSig;//ofs:38.0x29SDu32BS_VolID;//ofs:39.u8BS_VolLab[11];//ofs:43.“Msdos”u8BS_FilSysType[8];//ofs:54.“FAT16”u8ExecutableCode[448];//ofs:62.u8ExecutableMarker[2];//ofs:510.:0xAA55}FAT_BPB;FATFAT16SDFAT16FATFATFFF8H0000HFFF7HFFF8H-FFFFHFFF0H-FFF6HFDTFATFAT32FAT032typedef__packedstruct{u8FileName[8];//ofs:0.u8ExtName[3];//ofs:8.u8Attribute;//ofs:11.(0x20)(0x08)u8Reserved[10];//ofs:21.u16Time;//ofs:22.u16Data;//ofs:24.u16StartClus;//ofs:26.u32FileLength;//ofs:28.}DIR;ASCII83UNICODE211Attribute0FH13PCGB2312ASCIIUNICODEUNICODEGB2312ASCII7000UNICODEGB2312DATASDFAT3VS1003-MP3/WMAVS1003VLSISolutionOyMP3/WMA/MIDIADPCMDSPVS_DSP455VS1003MPEG1MPEG2IIICBR+VBR+ABRWMA4.0/4.1/7/8/95-384kbpsWAV(PCM+IMAAD-PCM)MIDI/SP-MIDIIMAADPCMMP3WAV12..13MHzPLL30I/O5.5KBRAMSPIFlashUART4GPIOVS1003VS1003SPI18DACVS1003
本文标题:基于STM32的MP3播放器设计与实现(-电子系统设计论坛
链接地址:https://www.777doc.com/doc-4938743 .html