void Main(void)
{
char mute;
char volume;
……
……
rSRCPND = (0x1<<19)|(0x1<<28);
rSUBSRCPND = 0x1;
rINTPND = (0x1<<19)|(0x1<<28);
rINTSUBMSK = ~(0x1);
rINTMSK = ~((0x1<<19)|(0x1<<28));
//开启DMA2中断屏蔽
pISR_UART0 = (U32)uartISR;
pISR_DMA2=(U32)DMA_end;
result=0;
remainder=0;
flag=0;
cmd=0;
play_state =0;
while(1)
{
switch(cmd)
{
case 0x1:
//播放
if (play_state==0)
{
volume = 0;
//音量清零
mute=0xa0;
//初始化静音
playsound(music,sizeof(music));
}
else
{
while(!(rUTRSTAT0 & 0x2))
;
rUTXH0=0xff;
}
cmd = 0;
break;
case 0x2:
//停止
if (play_state==1)
{
rIISCON = 0x0;
//停止IIS
rIISFCON = 0x0;
//清IIS的FIFO
rDMASKTRIG2=1<<2;
//终止DMA2
flag = 0;
play_state = 0;
}
else
{
while(!(rUTRSTAT0 & 0x2))
;
rUTXH0=0xff;
}
cmd = 0;
break;
case 0x3:
//暂停,
if(play_state == 1)
{
rIISCON ^= 0x1;
//异或,
}
else
{
while(!(rUTRSTAT0 & 0x2))
;
rUTXH0=0xff;
}
cmd = 0;
break;
case 0x11:
//静音
if (play_state==1)
{
mute ^= 0x4;
WriteL3(0x14 + 0,1);
//DATA0 (000101xx+00)
WriteL3(mute,0);
//10,1,00,x,00:x,静音
}
else
{
while(!(rUTRSTAT0 & 0x2))
;
rUTXH0=0xff;
}
cmd = 0;
break;
case 0x12:
//音量递增
if (play_state==1)
{
if(volume>0)
{
volume --;
WriteL3(0x14 + 0,1);
//DATA0 (000101xx+00)
WriteL3(volume,0);
//音量提高
}
}
else
{
while(!(rUTRSTAT0 & 0x2))
;
rUTXH0=0xff;
}
cmd = 0;
break;
case 0x13:
//音量递减
if (play_state==1)
{
if(volume<61)
{
volume++;
WriteL3(0x14 + 0,1);
//DATA0 (000101xx+00)
WriteL3(volume,0);
//音量降低
}
}
else
{
while(!(rUTRSTAT0 & 0x2))
;
rUTXH0=0xff;
}
cmd = 0;
break;
}
}
} |