int main(void)
{
u8 key;
u8 state=0;
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
uart_init(115200); //串口初始化为115200
LED_Init(); //初始化与LED连接的硬件接口
KEY_Init(); //初始化按键
TPAD_Init(6); //初始化触摸按键
LCD_Init(); //初始化LCD
W25QXX_Init(); //初始化W25Q128
VS_Init(); //初始化VS1053
my_mem_init(SRAMIN); //初始化内部内存池
exfuns_init(); //为fatfs相关变量申请内存
f_mount(fs[0],"0:",1); //挂载SD卡
f_mount(fs[1],"1:",1); //挂载FLASH.
Remote_Init(); //红外接收初始化
POINT_COLOR=RED;
while(font_init()) //检查字库
{
LCD_ShowString(30,50,200,16,16,"Font Error!");
delay_ms(200);
LCD_Fill(30,50,240,66,WHITE);//清除显示
}
Show_Str(30,50,200,16,"战舰 STM32开发板",16,0);
Show_Str(30,70,200,16,"音乐播放器实验",16,0);
Show_Str(30,90,200,16,"正点原子@ALIENTEK",16,0);
Show_Str(30,110,200,16,"2017年6月17日",16,0);
Show_Str(30,130,200,16,"KEY0:NEXT KEY2
REV",16,0);
Show_Str(30,150,200,16,"KEY_UP:VOL+ KEY1:VOL-",16,0);
Show_Str(220,90,200,16,"遥控器按键功能(录音):",16,0);
Show_Str(220,110,200,16,"VOL+:VOL+ VOL-:VOL-",16,0);
Show_Str(220,130,200,16,"2:STOP&SAVE 3:REC/PAUSE",16,0);
Show_Str(220,150,200,16,"TPAD
lay The File",16,0);
while(1)
{
LED1=0;
Show_Str(30,170,200,16,"存储器测试...",16,0);
printf("Ram Test:0X%04X
",VS_Ram_Test());//打印RAM测试结果
Show_Str(30,170,200,16,"正弦波测试...",16,0);
VS_Sine_Test();
Show_Str(30,170,200,16,"<<音乐播放器>>",16,0);
LED1=1;
key=Remote_Scan();
if(key) //有键按下
{
switch(key)
{
case 0: break;
case 162: break;
case 98: break;
case 2: break;
case 226: break;
case 194: break;
case 34: break;
case 224: break;
case 168: break;
case 144: break;
case 104: state=2; break;
case 152: break;
case 176: break;
case 48: break;
case 24: break;
case 122: break;
case 16: break;
case 56: break;
case 90: break;
case 66: state=1; break;
case 82: break;
}
}
if(state==1)
{
mp3_play();
}
if(state==2)
{
recoder_play();
}
}
}
我想用红外来控制选择播放音乐和录音功能,红外遥控:0是音乐播放,1是录音;但是当程序进入mp3_play();怎么实现让它停止,然后当按下“1”时转到recoder_play();
一周热门 更多>