今天把战舰的vs1005模块代码移植到探索者上,发现我买的vs1003模块正弦测试有声音,但是音乐播放不了,经过测试,发现是发送数据的时候DREQ引脚一直为高,导致不能播放!!!我想,这是不是引脚接错了,还是其他的问题
vs1003初始化代码
#define VS_DQ PCin(7) //DREQ
#define VS_RST PBout(6) //RST
#define VS_XCS PBout(7) //XCS
#define VS_XDCS PBout(8) //XDCS
下面是移植接口:
void VS_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOC, &GPIO_InitStructure);//
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
SPI2_Init();
下面是mp3play.c的播放特定歌曲部分
u8 mp3_play_song(u8 *pname)
{
FIL* fmp3;
u16 br;
u8 res,rval;
u8 *databuf;
u16 i=0;
u8 key;
rval=0;
fmp3=(FIL*)mymalloc(SRAMIN,sizeof(FIL));//éêÇëÄú′æ
databuf=(u8*)mymalloc(SRAMIN,4096); //¿a±ù4096×Ö½úμÄÄú′æÇøóò
if(databuf==NULL||fmp3==NULL)
{
LCD_ShowString(30,220,200,16,16,"memory apply failure!");
rval=0XFF ;//Äú′æéêÇë꧰ü.
}
if(rval==0)
{
VS_Restart_Play(); //ÖØÆô2¥·Å
VS_Set_All(); //éèÖÃòôá¿μèDÅÏ¢
VS_Reset_DecodeTime(); //¸′λ½aÂëê±¼ä
res=f_typetell(pname); //μÃμ½Îļtoó×o
/* if(res==0x4c)//èç1ûêÇflac,¼óÔØpatch
{
VS_Load_Patch((u16*)vs1053b_patch,VS1053B_PATCHLEN);
}
*/
res=f_open(fmp3,(const TCHAR*)pname,FA_READ);//′ò¿aÎļt
if(res==0)//′ò¿a3é1|.
{
Show_Str(60,190,240,16,"music′ò¿a3é1|",16,0);
VS_SPI_SpeedHigh(); //¸ßËù
while(rval==0)
{
res=f_read(fmp3,databuf,4096,(UINT*)&br);//¶á3ö4096¸ö×Ö½ú
Show_Str(60,240,240,16,"3é1|¶áè¡Ë¾áî¾íáô¸öêy¾Y",16,0);
i=0;
do//Ö÷2¥·ÅÑ-»·
{
if(VS_Send_MusicData(databuf+i)==0)//这里一直在不停地发送数据
{
i+=32;
Show_Str(60,190,240,16,"ò»Ö±Ôú·¢Ëíêy¾Y",16,0);
}else
{
key=KEY_Scan(0);
switch(key)
{
case KEY0_PRES:
rval=1; //ÏÂò»Çú
break;
case KEY2_PRES:
rval=2; //éÏò»Çú
break;
case WKUP_PRES: //òôá¿Ôö¼ó
if(vsset.mvol<250)
{
vsset.mvol+=5;
VS_Set_Vol(vsset.mvol);
}else vsset.mvol=250;
mp3_vol_show((vsset.mvol-100)/5); //òôá¿ÏTÖÆÔú:100~250,ÏÔê¾μÄê±oò,°′ÕÕ1«ê½(vol-100)/5,ÏÔê¾,ò2¾íêÇ0~30
break;
case KEY1_PRES: //òôῼõ
if(vsset.mvol>100)
{
vsset.mvol-=5;
VS_Set_Vol(vsset.mvol);
}else vsset.mvol=100;
mp3_vol_show((vsset.mvol-100)/5); //òôá¿ÏTÖÆÔú:100~250,ÏÔê¾μÄê±oò,°′ÕÕ1«ê½(vol-100)/5,ÏÔê¾,ò2¾íêÇ0~30
break;
}
mp3_msg_show(fmp3->fsize);//ÏÔê¾DÅÏ¢
}
}while(i<4096);//Ñ-»··¢Ëí4096¸ö×Ö½ú
if(br!=4096||res!=0)
{
rval=0;
break;//¶áíêáË.
}
}
f_close(fmp3);
}else
{
LCD_ShowString(30,230,200,16,16,"open file failure!");
rval=0XFF;//3öÏÖ′íÎó
}
}
myfree(SRAMIN,databuf);
myfree(SRAMIN,fmp3);
LCD_ShowxNum(30,200,rval,3,16,0);
return rval;
}
下面是发送音乐数据的函数
u8 VS_Send_MusicData(u8* buf)
{
u8 n;
if(VS_DQ!=0) //Ëíêy¾Y¸øVS10XX
{
VS_XDCS=0;
for(n=0;n<32;n++)
{
VS_SPI_ReadWriteByte(buf[n]);
}
VS_XDCS=1;
Show_Str(60,240,240,16,"VS10xx2»è±êy¾Y,±¾′Îêy¾YÎ′3é1|·¢Ëí",16,0);
}
else return 1;
return 0;//3é1|·¢ËíáË
}
一周热门 更多>