www.pudn.com > MP3DIY.rar > main.c


//=========================================================== 
//   Project Name(项目名称):  SPCA755 rebuild 
//   File Name(模块名称): main.c 
//   Built Date(创建日期):2004-09-14 
//   Abstract(模块描述): 主函数模块 
//   Revision History(版本信息): 
//   Rev      Date           Author       Comment(修改说明) 
//   1.0      2004-09-14      XYQ         created 
//============================================================ 
#include "..\userdefine.h" 
#include "userinit.h" 
#include "main.h" 
#include "user.h" 
#include "interrupt.h" 
 
//================================================================================================ 
U8  code EXT_NameA[]={3,'M','P','3','W','M','A','W','M','V'}; 
U8  code EXT_NameB[]={1,'W','A','V',/*'A','S','F'*/}; 
U8  xdata EXT_NameC[4];  
U8 *code EXT_Name[] = {EXT_NameA,EXT_NameB,EXT_NameC,EXT_NameC,EXT_NameC,EXT_NameC,}; 
 
U8	data	gc_USB_Connect;//lyh add 
U16	xdata 	gw_TxtOffset;//lyh add 
U32	xdata 	gdw_TxtFilePointer;//lyh add 
bit     gb_UIEvent; 
bit		gb_Storage_Full; 
bit		gb_LowBatt_State; 
bit		gb_USB_PowerPlug_Interrupt;//_G_USB_PowerPlug_Interrupt;replaced 
data	bit		gb_PlayPause; 
xdata	U8	gc_EVENT; 
xdata	unsigned int G_DISPLAY_TotalSec; 
xdata	U8	gc_LowBatt_SecondCount; 
xdata	U8	gc_Battery_Level; 
xdata	U8	gc_AB_Cnt; 
xdata	U16	G_W_OldTime; 
code  U8		gc_Battery_GroupValue[]={2,3,4,5,6}; 
U8 code	gc_CurrentHZKMapMenuHZK[]={0,1,0,0,0,}; 
U8 xdata	gc_MenuHZK; 
//----------------------------------------------------------------------------- 
U32 xdata	gdw_Dos_FreeMemorySizeMB; 
U8 xdata	gc_PowerOnLogoSelect; 
U8 xdata	gc_BacklightCount; 
U8 xdata	gc_DVRE_Mode_Selected; 
U8 code	DSP_MenuMODE[] ={KDSP_MP3_MODE,	KDSP_DVRD_MODE,	KDSP_DVRE_MODE}; 
bit	gb_UI_UserSeeting_Changed; 
//================================================================================================ 
data	U8				_WMA=0;	//lyh add 
data	U8				_G723=0;//lyh add 
U8 data  gc_Busy_Timer;//lyh add 
U8 xdata gc_PlayMode;//lyh add 
U8 xdata	gc_SongNameNDSingerName_Length;//lyh add 
U8 data  gc_FileNameRollTimer;//lyh add 
bit	gb_USB_Setup_Ack;//lyh add 
 
//================================================================================================ 
void main(void); 
void MAIN_LockLoop(void); 
void UI_Process(void); 
//================================================================================================ 
//test 
#define DRM_ENABLE  
void main(void) 
/* 
Routine	Description:	main routine 
Arguments:				none 
Return Value:			none 
*/ 
{   
	Sys_Initialize(); 
	User_initialize(); 
	INITIO_Initialize(); 
	DbgPrint("WWW.TASO123.COM\n"); 
	//==initialize parameters==// 
	User_initialize2(); 
    User_initialize4_UI();//lyh add 
	DbgPrint("into loop\n"); 
//    SPLC501_Init(); 
	MAIN_LockLoop(); 
	 
} 
//================================================================================================ 
void MAIN_LockLoop(void) 
{ 
	U8 USB_State; 
	U8 tc_SuspendState; 
    
	while(1) 
	{       
		USB_State = USB_GetState(); 
  	    //printf("USB_State =%bx \n",USB_State); 
   		switch(USB_State) 
		{ 
			case NO_USB://0x00 
//HSTPrint("NO usb\n"); 
				UI_Process();//Process UI Flow!!! 
				tc_SuspendState = 0; 
				gc_USB_Connect=0;//lyh add 
				break;  
			case USB_PHY_CONNECT://0x01//this state to show that the USB-jump-Line is connected,if call USB_Connect that mean D+ is high,so,pc is setup_ack;else to show just phy connect. 
//HSTPrint("USB_PHY_CONNECT \n"); 
//SPLC501_Printf(0x6,0,"USB_PHY_CONNECT"); 
//ldelay(1); 
                if(gc_USB_Connect==0)//lyh add 
			    {				 
                   gb_USB_PowerPlug_Interrupt=1; 
                   UI_Process(); 
                   gb_USB_Setup_Ack=1; 
                   UI_Connect_USB(); 
 
                } 
#if 0	//REMOVE BY WSCHUNG 
				else if (tc_SuspendState)///????????????????????? 
				{//if state from SUSPEND to PHY_CONNECT,add user UI here  
				 	UI_Process();	 
				} 
#endif 
                //printf("gb_USB_PowerPlug_Interrupt=%bu\n",gb_USB_PowerPlug_Interrupt); 
                if((gc_SystemStateMode==SYSTEM_STATE0_IDLE)&&(!gc_USB_Connect)) 
                { 
                   USB_Connect(); 
			       gb_USB_PowerPlug_Interrupt=0; 
                } 
                gc_USB_Connect=1; 
//				BackLightOn; 
                //printf("gc_SystemStateMode1=%bu\n",gc_SystemStateMode); 
				//please add your UI code here 
				break; 
			case USB_REMOVE://0x02 
//SPLC501_Printf(0x6,0,"USB_REMOVE"); 
				//please add your UI code here 
//                HSTPrint("USB_REMOVE \n"); 
				USB_DisConnect(); 
				USER_Remove_USB(); 
               // SPLC501_Disp_AllMusicLogoOff();//lyh add 
                gc_USB_Connect=0;//lyh add 
//				BackLightOff; 
				break; 
			case USB_STAND_BY://0x03//  
//SPLC501_Printf(0x6,0,"USB_STAND_BY"); 
               //  HSTPrint("USB_STAND_BY \n"); 
            	SPLC501_Disp_AllMusicLogoOff();//lyh add 
				//please add your UI code here 
				break; 
			case USB_READ://0x04 
//SPLC501_Printf(0x6,0,"USB_READ"); 
//                HSTPrint("USB_READ \n"); 
            	LED_Blink();//lyh add 
				//please add your UI code here 
				break; 
			case USB_WRITE:	//0x05 
//SPLC501_Printf(0x6,0,"USB_WRITE"); 
//                HSTPrint("USB_WRITE \n"); 
            	LED_Blink();//lyh add 
				//please add your UI code here 
				break; 
		  	case USB_SUSPEND:  
				//please add your Process UI Flow here  
//                HSTPrint("USB_SUSPEND \n"); 
                //SPLC501_Disp_AllMusicLogoOff(); 
//SPLC501_Printf(0x6,0,"USB_SUSPEND"); 
				tc_SuspendState = 1; 
                if (USB_PlugDetect()) 
				{ 
				SPLC501_Printf(0x6,0,"PlugDetect"); 
				  USB_Suspend(); 
				  SPLC501_Init();				 
				}//else{ 
				//	UI_Process(); 
				//} 
				break; 
		   	default: 
//SPLC501_Printf(0x6,0,"default"); 
		   		break; 
		} 
		if(USB_State>USB_REMOVE) 
		{ 
		//	HSTPrint("USB Other state \n"); 
			USB_Process(); 
//			#if ((K_CARD_TYPE &0x02)== 0x02) 
//			CardDetectInUsb(); 
//			#endif 
//			Usb_WriteProtectFunc(DbgP11);  //lss 060622 
		} 
 
	} 
} 
//================================================================================================ 
void UI_Process(void) 
{ 
	#if (K_CARD_TYPE == 0x03) 
	SD_InsertState_Detect(); 
	#endif 
 
	UI_PreProcessor_scan_key();    // lyh add 
 
	UI_Processorstate_transition();// lyh add 
 
	UI_EventPostDpc();             // lyh add 
 
	Audio_CoDec();                 // lyh add 
		 
  	UI_Battery_Detect_ND_Display();//no suitable variable to show the USB is charging or not!  
	 
	if (gc_SystemStateMode != STATE_RECORD) 
	{ 
		System_IdleManage();//为系统空闲时间的管理,其包括剩余空间的检索和FreeCluster的检索。 
	} 
 
 
} 
 
void ldelay(U8 i){ 
	while(i--){ 
		USER_DelayDTms(250); 
		USER_DelayDTms(250); 
		USER_DelayDTms(250); 
		USER_DelayDTms(250); 
	} 
}