unsigned char buf[2048]; unsigned char play() { unsigned long SecCount,FileSize; unsigned char ThisLen; unsigned char s; unsigned int i; FileSize=CH376GetFileSize( ); //獲取文件大小 SecCount=FileSize/512; //計(jì)算扇區(qū)數(shù) if((FileSize%512)!=0) SecCount++; FileSize=SecCount; xEndCH376Cmd( ); do { _initspi_highspeed(); s = CH376SecRead( buf,4, &ThisLen ); //扇區(qū)讀 SecCount =SecCount+ThisLen; xEndCH376Cmd( ); if(s!=USB_INT_SUCCESS) return 0xff; _initspi_lowspeed(); i=0; GPIO_ResetBits(GPIOC,GPIO_Pin_9); //vs1053片選有效 do { while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_11)==0);//DQ for(s=0;s<32;s++) { SPI1_ReadWriteByte(buf[i]); //發(fā)送一字節(jié) i++ ; } } while(i!=ThisLen*512); GPIO_SetBits(GPIOC,GPIO_Pin_9); //vs1053片選無效 } while(SecCount!=FileSize) ; return 0x00; }
以上是播放部分代碼