⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 AT89C51SND1C是AT89C51核心的处理器
💻 C
字号:
/*  Copyright (C) 1996-2005 Brilliant Ideal Electronics. All rights reserved.
	MP3_Player+USB_Disk V3.0 Edit by JMBIE STUDIO 2005.07
*/


#include "AT89C51SND1_REG.H"
#include "MCU_UART.H"
#include "MCU_KEYPAD.H"
#include "UDISK_DEF.H"
#include "MP3_PLAYER.H"
#include "FILE_SYS.H"
#include "LCD.H"

/*JMBIE USB-DISK MP3 PLAYER MAIN FUNCTION*/
void main()
{   
	char i;

    
	init_uart(1200);
    printu("JMBIE U-DISK+MP3-Player Ver 3.0\n");
	CKCON|=X2;   //X2 Mode
	Flash_Reset();

	if(USB_INS)		//USB Cable Insert Sensor 								                 
 	  {	 //USB Disk													         
	     printu("Entering USB-DISK Mode...\n");
		 LCD_init(0);
		 DisplayBMP(8,0,JMBIE_BMP);
		 LCD_printen(60,0,"MP3@JMBIE");
		 LCD_printen(8,3,"in USB-DISK Mode...");
		 AtmelUSBInit();
		 EpEnable();
	     while(1)
	      {
	         if (UEPINT & EP0)   Ep0();
	         if (UEPINT & EP1)   main_txdone();	//UEPINT地址0xF8却不能位寻址		 
			 if (UEPINT & EP2)   main_rxdone(); //所以这里不能用位定义EPxINT
           }
	  }
	else													         
	  {	//MP3 Player

		printu("Entering MP3-PLAY Mode...\n"); 
	    MP3_Init(); 
		Mute(1);                                                 
		KeyBoardInit();                                              
		MP3InitFlag = 1;
		NowPlaying=0;
		EA = 1;                                                      
		LED = 0;   //LED Light on                                                 	
		LCD_init(1);
		Init_FAT_Info();
		NumofSong = GetMP3List(); 
                                 
 		if(NumofSong == 0) 
		  {
		   printu("There is no MP3 file in the USB Disk!\n");
		   LED = 1;                                                 	 
		  }
		else printuf("Song Number: %x\n", NumofSong);
        
		printu("PlayState: STOP    Hit PLAY key\n\n");
  		
		DisplayBMP(4,0,JMBIE_BMP);
		LCD_printen(50,0,"JMBIE STUDIO");
		LCD_printen(50,1,"MP3 + U-DISK");
		LCD_printen(72,3,"STOP..");
		
		
		while(1) 
		{
		    printuf("Now play the song No.%x   ",NowPlaying+1);
			for(i=0;i<11;i++)
			   printuf("%c",SONG[11 * NowPlaying + i]);
			printu("\n");
//LCD display
			for(i=0;i<8;i++)
			   LCD_chstr[i]=SONG[11 * NowPlaying + i];
			LCD_chstr[8]=0;
			LCD_printch(0,2,LCD_chstr);	//only can used with out of a playing of a song 
			
			LCD_chstr[0]=NowPlaying+1+0x30;//from number to ascii code 
			LCD_chstr[1]=' ';
			LCD_chstr[2]='o';
			LCD_chstr[3]='f';
			LCD_chstr[4]=' ';
			LCD_chstr[5]=NumofSong+0x30;
			LCD_chstr[6]=0;
			LCD_printen(72,2,LCD_chstr);
			
						 
			if(NumofSong != 0)
			{
				if(MP3InitFlag)
				{
					if ( !PlayInit(&SONG[11 * NowPlaying]) )
					   {
					     printu("Bad MP3 file or error!\n");
					     while(1);
						}
					MP3InitFlag = 0;
				}
				Mute(0);
				PlayMP3(&SONG[11 * NowPlaying]);
				Mute(1);
			}
			if(NowPlaying == NumofSong) 
			{	
			    NowPlaying= 0;
				//PlayState = STOP;  //Bypass this line to repeat playing circularly
 			}
			LED =~LED;
		} 
	  
	  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -