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

📄 main.c

📁 凌阳MP3 spSPCA755yuanma
💻 C
📖 第 1 页 / 共 2 页
字号:
	G_USB_PlugInTimeOut=0;

	_G_DispUSBBSY=0;
	_G_Disp_PC=0;

	_G_Storage_Full=0;
	_G_UIPostError=0;
	G_AB_Cnt=0;

	L10_disp_Count=0;

	Variable_init();

	UI_idle_Display();

	_G_Battery_ChargeFull=0;

	_G_USB_Setup_Ack=0;
	_G_USB_Setup_Interrupt1=0;
	_G_USB_PowerPlug_Interrupt=0;

#if  (Auto_Repeat_OPTION==1)
	_G_StudyFunc=0;
	G_StudyRepTimes=3;
	G_VOXSensitiveLevel=5;
	G_VOXDetectTime=5;
#endif
	if(_G_USB_or_Batt_Power)//hxd030508  add
	{
		G_Powerstate=0;
	}else{
		G_Powerstate=0x80;
	}		//hxd030508 add end

	MAIN_LockLoop();
}

//-----------------------------------------------------------------------------
//MAIN_LockLoop
//-----------------------------------------------------------------------------
void MAIN_LockLoop(void) USING_0
{
	while (G_btSoftwareResetFlag == 0)
	{
		MAIN_PreDpc();
		if(G_Powerstate==0x02)
		{
			_UIEvent = FALSE;
		}
		else
		{
			MAIN_EventPreDpc();
			//==Get Key Event==//
			UI_PreProcessor_scan_key();
			//==Please reference to UI implementation note==//
			UI_EventPreDpc();

			UI_Processorstate_transition();

			UI_EventPostDpc();

			//==PLAY&REC==//
			Audio_CoDec();
			MAIN_EventPostDpc();
		}
		if(SPL10_Disp_Event)
		{
			LCD10_Disp_AllIcon();
		}
		MAIN_PostDpc();
	}
}
//---------------------------------------------------------
void UI_GetFileAttr(void)
{
	
	//if(G_USR_DirList[G_UIMODE].totalFile)
	//{
		if(!G_FileCurrentIndex) G_FileCurrentIndex = G_USR_DirList[G_UIMODE].totalFile;
		if(!USR_FileOpenPlay(G_DSPPrimeMODE, G_FileCurrentIndex))                                                                                                                                                                                                            				//sts = USR_FileOpenPlay(G_DSPPrimeMODE, G_DSPMinorMODE, G_FileCurrentIndex); //@@chchang_012203
		{
			G_FileTotalSecond = 0;			
			G_FileLock=0;
            G_DOS_FileSize=0;
			//_G_UIPostError = TRUE;
					
		}
		else
		{
			UI_GetFileTotalTime();
			File_Close(1,NULL,K_DOS_ReadFile,0);
		}
	/*}
	else
	{
		G_FileCurrentIndex = 0;
		G_FileTotalSecond= 0;
		G_FileLock=0;
	}*/

}
//-----------------------------------------------------------------------------
void UI_Remove_USB()
{
	unsigned char i;
	XBYTE[0x2030]=XBYTE[0x2030] & 0xfd;	//GPIO 1 disable USB connect
	///---Patch@2.04.00@chamber@improve the USB stability !
	///--- The USB Ready is controlled by P1.3
	///---
	DbgP13=0;		//turn off USB D+
	///---End of Patch@2.04.00@chamber !
	///
	INITIO_StorageInitialize();      	//if PC format flash memory,need initio storage
	_G_USB_Setup_Ack=FALSE;
    i=1;
    while(i<Current_Dvr_Dir)
	{
    	MultiDvrProcUp();
		i++;
	};
	USR_ClearFile();
	G_FileCurrentIndex = 0;//G_USR_DirList[G_UIMODE].totalFile;
	UI_GetFileAttr();
	_WMA = 0;				//patch@chamber0313
   	G_Power_Off_Timer=240;
   	_G_LowBatt_State=0;
	//LCD_Disp_PC_Link(OFF);
	G_DisplayEvent_Happened=1;
}
//-----------------------------------------------------------------------------
void UI_Battery_Detect_ND_Display()
{
	if(!G_Battery_Detect_Timer)
	{
		UI_Battery_Detect();
		//if(!G_Battery_GroupNum)
		//{
		//	if(_G_USB_Setup_Ack)
		//	{
				//LCD10_Disp_Battery_Level(3);//disp battery full
		//	}
		//	else
		//	{
   	LCD10_Disp_Battery();
		//	}
	  //	}
		/* sgjm del
      else
		{
			if(G_Powerstate==0x80)
			{
				LCD10_Disp_Battery();
			}
		}*/
		// sgjm del SPL10_ReadKey();//just for judge if SPL10 plug in
		G_Battery_Detect_Timer=4;   // sgjm 2second-->0.5second 16;
	}
}
//-----------------------------------------------------------------------------
//MAIN_PreDpc
//-----------------------------------------------------------------------------
void MAIN_PreDpc(void) USING_0
/*++
Routine Description:        pre-processing before deferred procedure call
Arguments:                  none
Return Value:               none
--*/
{
	// Chamber 02142003 for USB Suspend/Resume Function
#if 1
//	if(_DebugUSB)
//	{
//		DbgPrint("G_Powerstate=%bx\n",G_Powerstate);
//		DbgPrint("G_STATE=%bx\n",G_STATE);
//		_DebugUSB= 0;
//	}

	switch(G_Powerstate)
	{
	case 0x00://USB port power first, i.e. USB Bus Power is activity !
		if(!G_DisplayEvent_Happened)
		{
//===================================================================
#if (USBVendorConfiguration_OPTION == 1) //NO DEFINE
				//printf("\n");	
				//printf("card to sram2\n");

				G_AccessRevBlockPhyAddr = G_SMC_ReservePhyBlkAddr[K_ConfigurationBlockAddress] * G_NANDF_BlockSize+(2<<9);
				SMC_Card2Sram(G_AccessRevBlockPhyAddr);
				
				dump_G_ucStorData();
				//printf("\n");
#endif
//===================================================================
			XBYTE[0x2030] |= 0x02;// GPIO1 is High for USB Token Enable ,
			///---Patch@2.04.00@chamber@improve the USB stability !
			///--- The USB Ready is controlled by P1.3
			///---
			DbgP13=1;		//turn on USB D+
			///---End of Patch@2.04.00@chamber !	
			///			
		 	_G_USBSuspendPermit = TRUE;
			G_UI_USBConnect = K_UI_USB_CONNECT;
			G_USB_PlugInTimeOut=8;		// USB Time-out for Setup Ack
			G_Busy_Timer=2;//wait 0.25 second for USB setup interrupt
			G_Powerstate=0x01;		// go to next state for USB !
		}
		break;
	case 0x01:	//USB port power ready, USB State Display (transition)
		if(!G_Busy_Timer)
		{
			if(_G_USB_Setup_Ack)	// Wait the USB Enumeration procedure !
			{//USB Setup happend
//				DbgPrint("PC ON\n");
			//	LCD_Disp_PC_Link(ON);
				//LCD10_Disp_Battery_Level(3);
				G_Powerstate=0x02;		// USB Enunmeration finished !
			}
			else
			{					// Wait the USB Setup Ack or Time-out for USB Power Chagre
				if(!G_USB_PlugInTimeOut)	// Wait for Setup Ack is Time-Out, then is USB power for Charge !
				{
//					DbgPrint("USB Time-Out, Enter to Charge Mode\n");
					G_Powerstate=0x03;
				}
			}
		}
		break;
	case 0x02:	//USB read write state under USB power
		if(G_Busy_Timer)
		{
			if(!_G_DispUSBBSY)
			{
				_G_Disp_PC=0;
				_G_DispUSBBSY=1;			// LCD Hold "BUSY" characteristic
				LCD10_Disp_USBBusy();
			}
			//LED_Blink(1,1);
		}
		else
		{
			if(!_G_Disp_PC)					// Reset LCD to "PC" Idle link 
			{
//				DbgPrint("display PC\n");
				_G_DispUSBBSY=0;
				_G_Disp_PC=1;
				LCD10_Disp_PC();
			}
				// is there Suspend request from USB Host ?!

			if(!_G_USBConnect)				// Polling USB Connect
			{
//				DbgPrint("Reurn to Self-Power\n");
				Reset_LED();
				UI_Remove_USB();
				_G_USB_Setup_Interrupt1=0;
				_G_Disp_PC=0;
				G_Powerstate=0x80;
//				_DebugUSB= 1;
				break;
			}
			else
			{	// Return to Self-Power State. If USB is Bus-Power. then system will turn-Off.
				if(XBYTE[0x2040] & 0x04)		// UI Enable USB Power Charge Function !
			  	{
					USER_DelayDT(4000);		// Delay 10mS for de-bounce
					if(XBYTE[0x2040]&0x04)
					{
//						DbgPrint("Enter to Charge Mode\n");
						UI_Remove_USB();
						_G_USB_Setup_Interrupt1=0;
						_G_Disp_PC=0;
						G_Powerstate=0x03;
//						_DebugUSB= 1;
						break;
					}
			  	}

#if (EVBoard_OPTION==0)
				//patch2.2.1@chamber@USB_WriteProtected
				//XBYTE[0x2102]=XBYTE[0x2102] & 0xfd;  //P11 input enable for Hold key
            XBYTE[0x2038]=XBYTE[0x2038] &	0xfe;
            //if(DbgP11)
				if(HOLDDETECT)
				{
					G_USBMSDC_ucCardLock = 1;	// lock
					_G_USB_LockTG0=TRUE;
				}
				else
				{
					G_USBMSDC_ucCardLock = 0;	//unlock
					_G_USB_LockTG0=FALSE;
				}

				if(_G_USB_LockTG0!=	_G_USB_LockTG1)
				{
					G_USBMSDC_ubRefreshNeeded = 1;
					_G_USB_LockTG1=~_G_USB_LockTG1;
					 //DbgPrint("Key Lock TG!\n");
				}
				//End of patch2.2.1@chamber@USB_WriteProtected				//End of patch2.2.1@chamber
#endif
#if 1
				if(_G_ucSuspend)
				{
//					DbgPrint("Receive the Suspend Request!\n");
					USB_Intr_Suspend_Process();
//					DbgPrint("Resume from USB Suspend:G_Powerstate=%bx\n",G_Powerstate);
					_G_ucSuspend = 0;
					_G_Disp_PC=0;
//					_DebugUSB= 1;
				}
#endif
			}
			Reset_LED();
		}
		break;
	case 0x03://USB port power only

		if(_G_USB_Setup_Ack)
		{
			//LCD_Disp_PC_Link(ON);	//--Added by Chamber@030114 follow xyq
	        //  	LCD10_Disp_Battery_Level(3); //糤

⌨️ 快捷键说明

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