?? mp3_player_06.c
字號:
/********************* old ***************************/
/* MP3/Wma/Midi播放器 */
/* 環(huán)境WinAVR 20060421 */
/* 作者:Bozai(章其波) */
/* E-mail:sudazqb@163.com */
/* 2006年12月12日 */
/*************************************************************/
/* 20080308: rearrange the file, rewrite the key process (use interrupt) & volume*/
/* 20080205: a bug fixed(about lyric search, name comparision error ) */
/* 20071211: add low battery indication & remove all uart output, add message for sara ye */
/* 20071210: modify code for zl0801's mp3 PCB */
/* 20071122: add teminal control code */
/* 20071121: solve glitch problem when playing 320Kbps files */
/* 20071109: add & modify function for any directory music file playing */
/* 20071103: add function for lyric display */
#include"sys_config.h"
//#include"IDE/IDE.h"
uint8 HanziEnable = 0; /* Gloable variable to indicate wether the firmware are exist, and 1 means exist */
extern struct direntry MusicInfo; /* Music file information, 32Bytes short directory record, contain the short name and others */
//extern struct direntry LrcInfo; /* lyric file information, 32Bytes short directory record, the short name and others */
void (*BootLoaderEntry)(void) = 0xf800; /* boot loader entry, bootloader size: 2048Bytes */
extern uint16 totalsongs; /* total number of songs*/
extern uint8 type; /* current song's file type, mp3 wma mid or wav */
volatile uint8 key_count;
volatile uint8 key_value;
//Timer initialization offer seed of the srandom()
void Timer1_Initial()
{
key_value = 0;
key_count = 0;
TCNT1H=0x00;
TCNT1L=0x00;
TCCR1A=0x00;
TCCR1B=0x01;
TIMSK |= 1<<TOIE1;
sei();
}
SIGNAL(TIMER1_OVF_vect)
{
//TCCR1B = 0;
//printf_P(PSTR("\r\nvalue = %x"),key_value);
if((key_value&KEY_VALID) ==0)
{
//printf_P(PSTR("\r\nkey not valid"));
if((PINE&(STOP|MODE|NEXT|PREV|UP|DOWN)) == (STOP|MODE|NEXT|PREV|UP|DOWN))
{
//printf_P(PSTR("\r\nno key pressed"));
if(key_value&KEY_LONG)
{
key_value = 0;
}
else if((key_value&KEY_PRESEED) && (key_count>KEY_VALID_TIME))
{
//printf_P(PSTR("\r\nkey released"));
key_value |= KEY_RELEASED;
key_value |= KEY_VALID;
key_count = 0;
}
else
{
key_value = 0;
key_count = 0;
}
}
else if(key_value&KEY_PRESEED)
{
//printf_P(PSTR("\r\nkey used preseed"));
if(key_count == KEY_LONG_TIME)
{
//printf_P(PSTR("\r\nlong key prseed"));
key_value |= KEY_LONG|KEY_VALID;
key_count= 0;
}
if((key_value&KEY_LONG)==0)
{
key_count++;
}
}
else
{
if((PINE&STOP)!=STOP)
{
//printf_P(PSTR("\r\nstop key first pressed"));
key_value = KEY_STOP;
key_value |= KEY_PRESEED;
}
else if((PINE&MODE)!=MODE)
{
//printf_P(PSTR("\r\nmode key first pressed"));
key_value = KEY_MODE;
key_value |= KEY_PRESEED;
}
else if((PINE&NEXT)!=NEXT)
{
//printf_P(PSTR("\r\nnext key first pressed"));
key_value = KEY_NEXT;
key_value |= KEY_PRESEED;
}
else if((PINE&PREV)!=PREV)
{
//printf_P(PSTR("\r\nprev key first pressed"));
key_value = KEY_PREV;
key_value |= KEY_PRESEED;
}
else if((PINE&UP)!=UP)
{
//printf_P(PSTR("\r\nV+ key first pressed"));
key_value = KEY_UP;
key_value |= KEY_PRESEED;
}
else if((PINE&DOWN)!=DOWN)
{
//printf_P(PSTR("\r\nV- key first pressed"));
key_value = KEY_DOWN;
key_value |= KEY_PRESEED;
}
}
}
//TCCR1B = 0x01;
}
int main()
{
//unsigned char temp;
DDRE = 0x00;
PORTE = 0xff;
PORTB |= 1<<PB0; /* we should make sure that AVR's SS pin is held high no mater the spi is master or slave*/
LCD_BL_CON;
LCD_BL_ON;
OSCCAL = 0xff;
COM_Initial(MYUBRR);
VS1003B_Init();
lcdInit();
Timer1_Initial();
if(MCUCSR & 1<<BORF)
{
lcdClrDisBuf();
LCD_print12_P(0,12,PSTR("Low Battery!!!"));
lcdUpdateDisplay();
while(1);
}
#if 0
lcdClrDisBuf();
LCD_print12_P(0,0,PSTR(" Mp3 Player\nX-mas Special\nFor Sara Ye\n-- by Michael"));
lcdUpdateDisplay();
for(temp = 0;temp<40;temp++)
Delay(0xffff);
#endif
OSCCAL = 0xff;
lcdClrDisBuf();
LCD_print12_P(0,0,PSTR("Pls insert SD card!"));
lcdUpdateDisplay();
while(MMC_SD_Init());
FAT_ReadSector = MMC_SD_ReadSingleBlock;//device read
FAT_WriteSector = MMC_SD_WriteSingleBlock;//device write
FAT_ReadCapacity = MMC_SD_ReadCapacity;//read capacity
if(FAT_Init())
{
lcdClrDisBuf();
LCD_print12_P(0,0,PSTR("Wrong FAT!\nSystem halted!\nPls reset the\nsystem! -bozai"));
lcdUpdateDisplay();
while(1);
}//初始化FAT文件系統(tǒng)
if(GBK_Ini())
{
lcdClrDisBuf();
LCD_print12_P(0,0,PSTR("Firmware lost!\nPress start to\ncontinue!\n --By bozai"));
lcdUpdateDisplay();
HanziEnable = 0;
}
else
{
lcdClrDisBuf();
LCD_print12_P(0,0,PSTR("固件正常!\nMP3 player\nby 趙亮,章其波按開始鍵繼續(xù)"));
lcdUpdateDisplay();
HanziEnable = 1;
}
while(1)
{
if(key_value & KEY_VALID)
{
#if STOP_KEY
if((key_value&KEY_VALUE_MASK) == KEY_STOP)
#else
if((key_value&KEY_VALUE_MASK) == KEY_MODE)
#endif
{
key_value = 0;
break;
}
else key_value = 0;
}
}
#if FIX_DIRECTORY
//printf_P(PSTR("\r\nSearch the folder %s\r\n"),MUSIC_PATH);
Search(MUSIC_PATH,&MusicInfo,&totalsongs,&type);//搜索歌曲
#else
//printf_P(PSTR("\r\n\r\nSearch & record folder information....."));
//printf_P(PSTR("\r\nNOTE: MAX folder amount is %d for we only use %dBytes EEPROM to store the info\r\n"),(RECORD_ADDR_END-RECORD_ADDR_START)/4 -1,RECORD_ADDR_END-RECORD_ADDR_START);
SearchInit();
Search(0,&MusicInfo,&totalsongs,&type);//搜索歌曲
#endif
PlayMusicwithKey();
while(1);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -