Ejemplo n.º 1
0
void CGameText::Display( CBaseEntity *pActivator )
{
	if ( !CanFireForActivator( pActivator ) )
		return;

	#ifdef SecobMod__Enable_Fixed_Multiplayer_AI
		// also send to all if we haven't got a specific activator player to send to 
		if ( MessageToAll() || !pActivator || !pActivator->IsPlayer() ) 
	#else
		if ( MessageToAll() )
	#endif //SecobMod__Enable_Fixed_Multiplayer_AI

	if ( MessageToAll() )
	{
		UTIL_HudMessageAll( m_textParms, MessageGet() );
	}
	else
	{
	#ifdef SecobMod__Enable_Fixed_Multiplayer_AI
			UTIL_HudMessage( ToBasePlayer( pActivator ), m_textParms, MessageGet() );
	#else
	// If we're in singleplayer, show the message to the player.
			if ( gpGlobals->maxClients == 1 )
			{
				CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
				UTIL_HudMessage( pPlayer, m_textParms, MessageGet() );
			}
			// Otherwise show the message to the player that triggered us.
			else if ( pActivator && pActivator->IsNetClient() )
			{
				UTIL_HudMessage( ToBasePlayer( pActivator ), m_textParms, MessageGet() );
			}
	#endif //SecobMod__Enable_Fixed_Multiplayer_AI
	}
}
Ejemplo n.º 2
0
void CGameText::Display( CBaseEntity *pActivator )
{
	if ( !CanFireForActivator( pActivator ) )
		return;

	char fontbuf[48];
	FontGet(fontbuf);

	if ( MessageToAll() )
	{
		UTIL_HudMessageAll( m_textParms, MessageGet(), fontbuf );
	}
	else
	{
		// If we're in singleplayer, show the message to the player.
		if ( gpGlobals->maxClients == 1 )
		{
			CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
			UTIL_HudMessage( pPlayer, m_textParms, MessageGet(), fontbuf );
		}
		// Otherwise show the message to the player that triggered us.
		else if ( pActivator && pActivator->IsNetClient() )
		{
			UTIL_HudMessage( ToBasePlayer( pActivator ), m_textParms, MessageGet(), fontbuf );
		}
	}
}
Ejemplo n.º 3
0
void CGameText::Display( CBaseEntity *pActivator )
{
	if ( !CanFireForActivator( pActivator ) )
		return;

	// also send to all if we haven't got a specific activator player to send to
	if ( MessageToAll() || !pActivator || !pActivator->IsPlayer() )
		UTIL_HudMessageAll( m_textParms, MessageGet() );
	else
		UTIL_HudMessage( ToBasePlayer( pActivator ), m_textParms, MessageGet() );
}
void CGameText::Display( CBaseEntity *pActivator )
{
	if ( !CanFireForActivator( pActivator ) )
		return;

	if (MessageToAll() || !pActivator || !pActivator->IsPlayer())
	{
		UTIL_HudMessageAll( m_textParms, MessageGet() );
	}
	else
	{
		UTIL_HudMessage(ToBasePlayer(pActivator), m_textParms, MessageGet());
	}
}
Ejemplo n.º 5
0
void CGameText::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
	if (!CanFireForActivator(pActivator))
		return;

	if (MessageToAll())
	{
		UTIL_HudMessageAll(m_textParms, MessageGet());
	}
	else
	{
		if (pActivator->IsNetClient())
		{
			UTIL_HudMessage(pActivator, m_textParms, MessageGet());
		}
	}
}
Ejemplo n.º 6
0
VOID RtcStateCtrl(VOID)
{
	MESSAGE Event = MessageGet(MSG_FIFO_RTC);

#ifdef FUNC_STANDBY_EN
	if(gSys.SystemMode == SYS_MODE_STANDBY)
#endif
	{
		RtcMsgPro(Event);
	}
	
#ifdef FUNC_ALARM_EN	
	if(RtcSubState == RTC_SET_NONE)
	{
		//Check alarm
		if(gCurAlarmNum = CheckRtcAlarmFlag())
		{
			DBG(("\nRTC ALARM COME!\n"));
			
#ifdef	AU6210K_CAR_MODEL_DEMO
			gAlarmOnFlag = TRUE;
#endif
#ifdef FUNC_BREAK_POINT_EN
			BP_SaveInfo((BYTE*)&gBreakPointInfo.PowerMemory.AlarmList2Store, sizeof(gBreakPointInfo.PowerMemory.AlarmList2Store));
#endif

#ifdef AU6210K_BOOMBOX_DEMO
			if(gCurAlarmNum == 1)
			{
				gAlarm1OnFlag = TRUE;
			}
			else
			{
				gAlarm2OnFlag = TRUE;
			}
#endif
		}
	}
#endif

	//Display time
	RtcDisplay();
}
Ejemplo n.º 7
0
int main(int argc,char *argv[])
{
  int i,Result;      //MessageNumber;
  HWND Window;
  HMSG Message;
  ULONG Param1,Param2;
  char *opt;

  GetProfileString( ProfileName,InitSection, VectLibPathEntry,VectLibPath,
       "c:\\ezp\\fonts\\;c:\\;d:\\;e:\\;d:\\bttf;e:\\bttf;f:\\bttf;g:\\bttf");
  GetProfileString( ProfileName,InitSection, TrueTypeLibPathEntry,TrueTypeLibPath,
       "c:\\ezp\\fonts\\;d:\\cttf;e:\\cttf;f:\\cttf;g:\\cttf;d:\ttf;e:\\ttf;f:\\ttf;g:\\ttf");

  for (i=1;i<argc;i++)
  {
      opt = argv[i];
      if (*opt == '-'|| *opt == '/')
      {
          opt ++;
          switch (toupper(*opt)) {
              case '6':
                   if(!strcmp(opt,"640"))
                      ScreenMode=MODE640X480X16;
                   break;
              case '8':
                   if(!strcmp(opt,"800"))
                      ScreenMode=MODE800X600X16;
                   break;
              case '1':
                   if(!strcmp(opt,"1024"))
                      ScreenMode=MODE1024X768X16;
                   break;
              case 'E':
                   fEditor=TRUE;
                   break;
              case 'D':
              default:break;
          }     // switch
      } else
      if (*opt == '%')
      {
          opt ++;
          if(*opt=='%')
             Result=60000;
      }
      else
          MakeName(opt);
  } /*-- argc > 1 ---*/

  InitDot13LIB();

  i=Result;
  if ((Result=SystemConstruct())<OpOK)
  {
     SystemDestruct();
     Error(Result);
  }

  Result=i;
  FileSetMeterCM();
  WaitMessageEmpty();           // run all init, ByHance

/*-------------
//  test_speed();
  printf("size of Box = %d\n",sizeof(Boxs));
  printf("size of Pages = %d\n",sizeof(Pages));
  printf("size of window= %d\n",sizeof(Windows));
  printf("size of fillp = %d\n",sizeof(FILLP));
  printf("size of fillp = %d\n",sizeof(FILLP));
  getch();
  goto game_over;
-----------------*/

  if(!fEditor)
  {     // get printer type from file <EZP.INI>
     char str[80];
     GetProfileString( ProfileName,InitSection, PrinterEntry,str,
                        "HPϵÁм¤¹â´òÓ¡»ú(A4 300DPI)");
     i=0;
     while(PrinterName[i])
     {
       if( strcmp(str,PrinterName[i])==0 )
         break;
       i++;
     }
     if(PrinterName[i]==NULL) i=0;
     CurrentPrinter=i;

     MessageInsert(1,MENUCOMMAND,MENU_VIEWTOOLS,0L);
     MessageInsert(1,MENUCOMMAND,MENU_CLIBRATION,0L);
     strcpy(DefaultFileName,"*.EZP;*.FRA;*.TXT;*.*");
     WaitMessageEmpty();           // run all init, ByHance
  }
  else
  {
     strcpy(DefaultFileName,"*.TXT");
     GlobalBoxTool=IDX_INPUTBOX;
     DEFAULTTYPESTYLE.CharSize=DEFAULTTYPESTYLE.CharHSize=
       FormattingTextStyle.CharSize=FormattingTextStyle.CharHSize=160;  // 16*16
     DEFAULTTYPESTYLE.ParagraphAlign=
       FormattingTextStyle.ParagraphAlign=ALIGNLEFT;
     DEFAULTTYPESTYLE.VParagraphAlign=
       FormattingTextStyle.VParagraphAlign=ALIGNUPDOWN;
  }



  if(fAutoLoad)
     MessageInsert(1,MENUCOMMAND,MENU_OPEN,0L);
  else
     //if(fEditor) MessageInsert(1,MENUCOMMAND,MENU_NEW,0L);
  {
  MessageInsert(1,MENUCOMMAND,MENU_NEW,0L);    //By zjh 96.10.17 for auto load
  fNewA4=TRUE;
  }

// #define OLD_VERSION
#ifdef OLD_VERSION
  DrawIconImage();    // for debug
#endif

/*----------------- for test -----
  WaitMessageEmpty();
  for(i=0;i<200;i++)
  {
    //RedrawUserField();
    //WaitMessageEmpty();
    TextBoxRedrawPart(GlobalBoxHeadHandle,0,30000,0,FALSE);
  }
  goto game_over;
  -----------------*/

  GlobalTimer=TimerInsert(1,1);   // in main window, 18.2/second

  while(1)
  {
    if(Result==60000) {
        if(0==strcmp(&argv[1][2],"Han&Zhou"))
        {
           static unsigned char REDTEK_Company[32]={
              '±'+3,'±'+2,
              '¾'+1,'©'+0,
              'À'-1, 'í'-2,
              'µ'-3, 'Â'-4,
              'É'-5, 'Ì'-6,
              'Ó'-7, 'Ã'-8,
              '¼'-9, '¼'-10,
              'Ê'-11,'õ'-12,
              'Ó'-13,'Ð'-14,
              'Ï'-15,'Þ'-16,
              '¹'-17,'«'-18,
              'Ë'-19,'¾'-20,
              '°'-21,'æ'-22,
              'È'-23,'¨'-24,
              'Ë'-25,'ù'-26,
              'Ó'-27,'Ð'-28
           };

           Result=0;
           while(PageDialog[Result].ItemProcedure!=PageInitialBoxProcedure)
                Result++;
           PageDialog[Result].ItemUserData=1;       // pageInitBox=TRUE;

           //UserMenuCommand(1,MENUCOMMAND,MENU_NEW,0L);
           MenuHotKeyToMessage(1,ALT_F);        // ByHance
           MenuDefaultProc(1,KEYDOWN,'N',0);   // in UserMenu.C
           //MessageCreatbyKeyboard(ENTER,0);
           *(short *)0x41a=0x1e;
           *(short *)0x41c=0x20;
           *(short *)0x41e=0x1c0d;

           WaitMessageEmpty();
           for(Result=0;Result<32;Result++)
                REDTEK_Company[Result]+=(Result-3)&0xff;
           MessageCreatbyKeyString(REDTEK_Company,32);
        }
    }
    else

    KeyToMessage();
    if ((Result=MessageGet(&Window,&Message,&Param1,&Param2))<OpOK)
       break;
    if (Result<MAXMESSAGES)
    {
       if ((Result=MessageGo(Window,Message,Param1,Param2))==SYSTEMQUIT)
          break;
    }
    else
       MessageGo(1,SYSTEMIDLE,Param1,Param2);           // main window idle
  }

  TimerDelete(GlobalTimer);

//game_over:
#ifdef WELCOME_DISPLAY
  MessageNumber=Result;

  if ((Result=SystemDestruct())<OpOK)
  {
     SystemDealError(Result);
  }
  SystemDealError(MessageNumber);
#else
  SystemDestruct();
#endif

 //printf("OK.\n");
 return(0);
}
Ejemplo n.º 8
0
int MakeDialogBox(HWND FatherWindow,Dialogs *Dialog)
{
  HWND Window,/*MidWindow,*/DefaultActiveWindow=0;
  int  Result,width,height;
  HMSG Message,MessageNumber;
  ULONG Param1,Param2;

  SetIntSign();

  width=Dialog[0].ItemRight-Dialog[0].ItemLeft;
  height=Dialog[0].ItemBottom-Dialog[0].ItemTop;
  Dialog[0].ItemLeft = (getmaxx()-width)/2-4;     // ByHance, 96,3.13

  if(fDialogBoxAtTop)           // ByHance, 97,5.7
     Dialog[0].ItemTop = 6;
  else
     Dialog[0].ItemTop = (getmaxy()-height)/2+6;

  Dialog[0].ItemRight=Dialog[0].ItemLeft+width;
  Dialog[0].ItemBottom=Dialog[0].ItemTop+height;

  Window=CreatDialogBox(Dialog,&DefaultActiveWindow);
  if (Window<0)
     return(Window);

  MouseSetGraph(ARRAWMOUSE);            // ByHance, 95,12.4
  MessageInsert(Window,WINDOWINIT,0, MAKELONG(width,height));
  //MessageGo(Window,WINDOWINIT,0, MAKELONG(width,height));

/*------------------------   ByHance, 96,3.1
  MidWindow=WindowGetChild(Window);
  while (MidWindow)
  {
    if (WindowGetUserData(MidWindow)==DIALOGBOXOK)
    {
       MessageInsert(MidWindow,GETFOCUS,0l,0l);
       break;
    }
    MidWindow=WindowGetNext(MidWindow);
  }
---------------------------*/
  NowTabIdx[DialogImageN]=
  TotalTabLinkNum[DialogImageN]=TotalTabLinkNum[DialogImageN-1];

  CreatTabLink(Window);         // ByHance, 95,11.22
  MessageInsert(Window,REDRAWMESSAGE,0,MAKELONG(width,height));

  WaitMessageEmpty();
  MessageInsert(TabLinkArr[TotalTabLinkNum[DialogImageN-1]],GETFOCUS,0l,0l);

  ClearIntSign();

  while(1)
  {
    KeyToMessage();
    if ((Result=MessageGet(&Window,&Message,&Param1,&Param2))<OpOK)
       break;

    MessageNumber=Result;
    if (MessageNumber<MAXMESSAGES)
    {
       Result=MessageGo(Window,Message,Param1,Param2);
       if ((Result==DIALOGBOXOK)||(Result==DIALOGBOXCANCEL)
           ||(Result==MESSAGEBOXNODO)|| Result>10000)
          break;
    }
    else
       MessageGo(Window,SYSTEMIDLE,Param1,Param2);
  }

  //TotalTabLinkNum=0;            // ByHance, 96,1.24

  WaitMessageEmpty();

  if (Result==DIALOGBOXOK)
     return(0);
  if (Result==DIALOGBOXCANCEL)
     return(1);
  if (Result==MESSAGEBOXNODO)
     return(2);
  return(Result);
}
Ejemplo n.º 9
0
//按键响应
VOID RadioEventProcess(VOID)
{
	MESSAGE Event = MessageGet(MSG_FIFO_KEY);
	
	switch(Event)
	{
		case MSG_POWER:
		case MSG_MODE_SW:
			//DBG(("Exit FM, Event:%bx\n", Event));
			CancelSearch();
			MessageSend(MSG_FIFO_DEV_CTRL, Event);
			break;
			
		case MSG_SCAN://启动自动全频段搜台
		case MSG_INTRO:
		case MSG_PLAY_1CP:
#if !defined(AU6210K_HXX_B002)			
		case MSG_PLAY_PAUSE:
#endif			
#ifdef FUNC_DEVICE_FORCEPAUSE_EN
			if(gDevicePlayForcePauseFlag == TRUE)
			{
				gDevicePlayForcePauseFlag = FALSE;
				UnMute();
				break;
			}
#endif
			DBG(("SCAN\n"));
#ifdef FUNC_BEEP_SOUND_EN	
			PushKeyBeep(1);
#endif
			if(gRadioCtrl.State == RADIO_IDLE)
			{
				gRadioCtrl.State = RADIO_READ;
				
				gRadioCtrl.SeekMode = SEEK_AUTOSCAN;
#ifdef FUNC_SLAVE_UART_EN
                            gRadioData.CurrFreq = gRadioCtrl.RadioLowerBound;
#else
				gRadioData.CurrFreq = RADIO_LOWER_BOUND;
#endif
				gRadioData.CurrStation = 0;	
				gRadioData.Area1StationSum = 0;
				gRadioData.StationSum = 0;					
				memset(&gRadioData.Stations, 0, sizeof(gRadioData.Stations));
				
				MuteOn(TRUE, TRUE);				
				RadioSetFreq();		
#ifdef FUNC_SLAVE_UART_EN
#ifdef	FUNC_RADIO_AUTOSEEK_EN
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, gRadioCtrl.RadioUpperBound, gRadioCtrl.RadioSeekStep, 1, 1);
#else
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, gRadioCtrl.RadioUpperBound, gRadioCtrl.RadioSeekStep, 0, 1);
#endif

#else
#ifdef	FUNC_RADIO_AUTOSEEK_EN
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, RADIO_UPPER_BOUND, RADIO_SEEK_STEP, 1, 1);
#else
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, RADIO_UPPER_BOUND, RADIO_SEEK_STEP, 0, 1);
#endif
#endif				
				RadioMute(TRUE);
				TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioSeekTimeValue);
			}
			else
			{
				CancelSearch();
			}
			break;

		case MSG_SAVE_STATION:  //保存当前的频率到当前的频道
			if(gRadioCtrl.State == RADIO_IDLE)
			{		
				if(gRadioData.StationSum < MAX_RADIO_STATION_NUM)
				{		
					if((gRadioData.CurrFreq < RADIO_FREQ_BASE_875) && ((gRadioData.CurrStation + 1) <= gRadioData.Area1StationSum))
					{
						gRadioData.Stations[gRadioData.CurrStation] = (gRadioData.CurrFreq - RADIO_FREQ_BASE_760);
					}
					else if((gRadioData.CurrFreq > RADIO_FREQ_BASE_875) && ((gRadioData.CurrStation + 1) > gRadioData.Area1StationSum))
					{
						gRadioData.Stations[gRadioData.CurrStation] = (gRadioData.CurrFreq - RADIO_FREQ_BASE_875);
					}				
					RadioShowDebug(RadioShowSaveCurFreToCurChannle);
					RadioWriteData();
					RadioDisFlag = RadioDisCurFreBlink;
					RadioDisCount = 6;
					TimeOutSet(&gRadioCtrl.SeekPreviewTimer,RadioBlinkTime);
#ifdef FUNC_SLAVE_UART_EN
					SlaveRadioRetCurrentStatus();
#endif

				}
			}
			break;
		
		case MSG_NEXT://下一个台
		case MSG_PLAY_1:
#ifdef	FUNC_DEVICE_FORCEPAUSE_EN
			if(gDevicePlayForcePauseFlag == TRUE) 
			{
				break;
			}					
#endif

#ifdef AU6210K_BOOMBOX_DEMO
			if(gRadioCtrl.State == RADIO_PROG)
			{
				if(gRadioData.CurrStation < (MAX_RADIO_STATION_NUM / 2))
				{
					gRadioData.CurrStation++;
				}
				else
				{
					gRadioData.CurrStation = 0;
				}
				break;
			}
			
			if(gRadioCtrl.State == RADIO_IDLE)
			{
				if(RadioGetValidPresetNum(gRadioData.CurrStation, UP) == TRUE)
				{
					RadioDisFlag = RadioDisCurChChange;
					TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioPreVimeTimerValue);
					RadioChannelChange();
					UnMute();
					gSys.MuteFg = FALSE;
				}
				break;
			}
#endif

			if((gRadioData.StationSum > 0) && (gRadioCtrl.State == RADIO_IDLE))
			{
#ifdef FUNC_BEEP_SOUND_EN	
				PushKeyBeep(1);
#endif
				if(gRadioData.CurrStation < (gRadioData.StationSum - 1))
				{
					gRadioData.CurrStation++;
				}
				else
				{
					gRadioData.CurrStation = 0;
				}
				RadioDisFlag = RadioDisCurChChange;				
				RadioChannelChange();
				UnMute();
				TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioPreVimeTimerValue);
				gSys.MuteFg = FALSE;
#ifdef FUNC_SLAVE_UART_EN
				SlaveRadioRetCurrentStatus();
#endif
			}
			break;
			
		case MSG_PRE://上一个台
		case MSG_EQ_CH_SUB:
#ifdef	FUNC_DEVICE_FORCEPAUSE_EN
			if(gDevicePlayForcePauseFlag == TRUE) 
			{
				break;
			}					
#endif

#ifdef AU6210K_BOOMBOX_DEMO
			if(gRadioCtrl.State == RADIO_PROG)
			{
				if(gRadioData.CurrStation < (MAX_RADIO_STATION_NUM / 2))
				{
					gRadioData.CurrStation++;
				}
				else
				{
					gRadioData.CurrStation = 0;
				}
				break;
			}
			
			if(gRadioCtrl.State == RADIO_IDLE)
			{
				if(RadioGetValidPresetNum(gRadioData.CurrStation, DOWN) == TRUE)
				{
					RadioDisFlag = RadioDisCurChChange;
					TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioPreVimeTimerValue);
					RadioChannelChange();
					UnMute();
					gSys.MuteFg = FALSE;
					break;
				}
			}
#endif

			if((gRadioData.StationSum >  0) && (gRadioCtrl.State == RADIO_IDLE)) 
			{
#ifdef FUNC_BEEP_SOUND_EN	
				PushKeyBeep(1);
#endif
				if(gRadioData.CurrStation > 0)
				{
					gRadioData.CurrStation--;
				}
				else
				{
					gRadioData.CurrStation = gRadioData.StationSum - 1;
				}
				RadioDisFlag = RadioDisCurChChange;				
				RadioChannelChange();
				UnMute();
				TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioPreVimeTimerValue);
				gSys.MuteFg = FALSE;
#ifdef FUNC_SLAVE_UART_EN
				SlaveRadioRetCurrentStatus();
#endif
			}
			break;
			
#ifdef	FUNC_NUMBER_KEY_EN
		case MSG_RECV_NUM://选台(输入数值在有效台数内)或设置频率(输入数值在有效频率范围内)	
			if(gRadioCtrl.State == RADIO_IDLE)//SeanFu
			{
				if((gRecvNum > 0) && (gRecvNum <= gRadioData.StationSum))
				{
					//DBG(("RecvNum合法台号:%d\n", gRecvNum));				
					gRadioData.CurrStation = gRecvNum - 1;
					if(gRecvNum <= gRadioData.Area1StationSum)
					{
						gRadioData.CurrFreq = (gRadioData.Stations[gRadioData.CurrStation] + RADIO_FREQ_BASE_760);
					}
					else
					{
						gRadioData.CurrFreq = (gRadioData.Stations[gRadioData.CurrStation] + RADIO_FREQ_BASE_875);
					}	
					RadioWriteData();
					RadioShowDebug(RadioShowCurStationChange);
				}
#ifdef FUNC_SLAVE_UART_EN
                            else if((gRecvNum >= gRadioCtrl.RadioLowerBound) && (gRecvNum <= gRadioCtrl.RadioUpperBound))
#else
				else if((gRecvNum >= RADIO_LOWER_BOUND) && (gRecvNum <= RADIO_UPPER_BOUND))
#endif
				{
					//DBG(("RecvNum合法 频率:%d\n", gRecvNum));
					gRadioData.CurrFreq = gRecvNum;				
					RadioWriteData();
					RadioShowDebug(RadioShowSaveFre);
				}
				else 
				{
					//DBG(("RecvNum非法:%d\n", gRecvNum));	
					gRecvNum = 0;						
					NumKeyRadioFreqErrorFlag = TRUE;
					NumKeyErrorDispFlag = TRUE;					
#ifdef FUNC_DISP_EN						
					TimeOutSet(&DispTmr, NORMAL_INTERVAL);	//输入错误Err显示保留时间
#endif
					return;
				}			
				RadioSetFreq();
				RadioMute(FALSE);
				gRecvNum = 0;					
#ifdef FUNC_DISP_EN						
				TimeOutSet(&DispTmr, 0);	//退出数值显示
#endif
			}
			break;

		case MSG_NUM_SAVE_STAITON:	//将当前频率保存起来
			if(gRadioCtrl.State == RADIO_IDLE)
			{				
				//DBG(("RecvNum %d \n", gRecvNum));
				RadioArrayInsert();
				gRecvNum = 0;
				RadioWriteData();
				RadioShowDebug(RadioShowSaveFre);
				RadioDisFlag = RadioDisCurFreBlink;
				RadioDisCount = 4;
				TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioBlinkTime);
			}
			break;
#endif
			
#ifdef	FUNC_RADIO_STEPOVER_EN		
		case MSG_NEXT1:
		case MSG_FREQ_UP:
		case MSG_FREQUP_10TRK://循环递增微调频率(+100KHZ)	
			if(gRadioCtrl.State == RADIO_IDLE)
			{
#ifdef FUNC_SLAVE_UART_EN
                            if(++gRadioData.CurrFreq > gRadioCtrl.RadioUpperBound)
				{
					gRadioData.CurrFreq = gRadioCtrl.RadioLowerBound;
				}
#else
				if(++gRadioData.CurrFreq > RADIO_UPPER_BOUND)
				{
					gRadioData.CurrFreq = RADIO_LOWER_BOUND;
				}
#endif
				RadioSetFreq();
				RadioMute(FALSE);		
				RadioWriteData();
				RadioShowDebug(RadioShowFreChange);
			}
			break;
		
		case MSG_PREV1:
		case MSG_FREQ_DN:
		case MSG_FREQDN_10TRK://循环递减微调频率(-100KHZ)		
			if(gRadioCtrl.State == RADIO_IDLE)
			{
#ifdef FUNC_SLAVE_UART_EN
                            if(--gRadioData.CurrFreq < gRadioCtrl.RadioLowerBound)
				{
					gRadioData.CurrFreq = gRadioCtrl.RadioUpperBound;
				}	
#else
				if(--gRadioData.CurrFreq < RADIO_LOWER_BOUND)
				{
					gRadioData.CurrFreq = RADIO_UPPER_BOUND;
				}	
#endif
				RadioSetFreq();
				RadioMute(FALSE);		
				RadioWriteData();
				RadioShowDebug(RadioShowFreChange);
			}
			break;
#endif
		
#ifdef	FUNC_RADIO_SEMO_AUTOSEEK_EN		
		case MSG_FF_START:
		case MSG_10TRACK_ADD://递增方式搜台,搜到第一个后停止
			if(gRadioCtrl.State == RADIO_IDLE)
			{
				gRadioCtrl.SeekMode = SEEK_SCANUP;
#ifdef FUNC_SLAVE_UART_EN
                            if(gRadioData.CurrFreq >= gRadioCtrl.RadioUpperBound)
				{	
					gRadioData.CurrFreq = gRadioCtrl.RadioLowerBound;
				}
				else
				{
					gRadioData.CurrFreq++;
				}
#else
				if(gRadioData.CurrFreq >= RADIO_UPPER_BOUND)
				{	
					gRadioData.CurrFreq = RADIO_LOWER_BOUND;
				}
				else
				{
					gRadioData.CurrFreq++;
				}
#endif				
				MuteOn(TRUE, TRUE);	
				RadioSetFreq();						
				gRadioCtrl.State = RADIO_READ;
#ifdef FUNC_SLAVE_UART_EN
#ifdef	FUNC_RADIO_AUTOSEEK_EN
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, gRadioCtrl.RadioUpperBound, gRadioCtrl.RadioSeekStep, 1, 1);
#else
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, gRadioCtrl.RadioUpperBound, gRadioCtrl.RadioSeekStep, 0, 1);
#endif
#else
#ifdef	FUNC_RADIO_AUTOSEEK_EN
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, RADIO_UPPER_BOUND, RADIO_SEEK_STEP, 1, 1);
#else
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, RADIO_UPPER_BOUND, RADIO_SEEK_STEP, 0, 1);
#endif
#endif
				RadioMute(TRUE);
				TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioSeekTimeValue);
					
			}
			break;
		
		case MSG_FB_START:
		case MSG_10TRACK_SUB://递减方式搜台,搜到第一个后停止
			if(gRadioCtrl.State == RADIO_IDLE)
			{
				gRadioCtrl.SeekMode = SEEK_SCANDOWN;
#ifdef FUNC_SLAVE_UART_EN
                            if(gRadioData.CurrFreq <= gRadioCtrl.RadioLowerBound)
				{
					gRadioData.CurrFreq = gRadioCtrl.RadioUpperBound;
				}
				else
				{
					gRadioData.CurrFreq--;
				}
#else				
				if(gRadioData.CurrFreq <= RADIO_LOWER_BOUND)
				{
					gRadioData.CurrFreq = RADIO_UPPER_BOUND;
				}
				else
				{
					gRadioData.CurrFreq--;
				}
#endif				
				MuteOn(TRUE, TRUE);	
				RadioSetFreq();						
				gRadioCtrl.State = RADIO_READ;
#ifdef FUNC_SLAVE_UART_EN
#ifdef	FUNC_RADIO_AUTOSEEK_EN
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, gRadioCtrl.RadioLowerBound, gRadioCtrl.RadioSeekStep, 1, 1);
#else
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, gRadioCtrl.RadioLowerBound, gRadioCtrl.RadioSeekStep, 0, 1);
#endif
#else
#ifdef	FUNC_RADIO_AUTOSEEK_EN
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, RADIO_LOWER_BOUND, RADIO_SEEK_STEP, 1, 1);
#else
				MVFM_AutoSeekConfig(gRadioData.CurrFreq, RADIO_LOWER_BOUND, RADIO_SEEK_STEP, 0, 1);
#endif
#endif
				RadioMute(TRUE);
				TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioSeekTimeValue);
					
			}
			break;
#endif

		case MSG_VOL_ADD://音量加					
#if defined(AU6210K_NR_D_9X)||defined(AU6210K_NR_D_9X_XJ_HTS)
			if (gSys.Volume >= VOLUME_MAX)
			{
				SPI_PlaySelectNum(SPIPLAY_SONG_MAX_VOLUME, 0);
				InDacChannelSel(DAC_CH_ONCHIP_FM);
				RadioSetFreq();
				UnMute();
				SysClkDivSet(CLK_DIV_RATE);
			}
#endif

#ifdef FUNC_POWER_AMPLIFIER_EN
			ABPowerAmplifierOff();			
#endif

#ifdef FUNC_OTP_KEY_SOUND_EN
			OTP_PlaySelNum(OTPPLAY_NUM_VOLUP, 0);
			InDacChannelSel(DAC_CH_ONCHIP_FM);
			RadioSetFreq();
			UnMute();
			SysClkDivSet(CLK_DIV_RATE);
#endif
#ifdef FUNC_PT231X_EN
            VolType = VOL_MAIN;
            PT2313VolAdd();
#else
			VolumeAdjust(UP);
#endif
			break;
		
		case MSG_VOL_SUB://音量减			
#if defined(AU6210K_NR_D_9X)||defined(AU6210K_NR_D_9X_XJ_HTS)
			if (gSys.Volume <= VOLUME_MIN)
			{
				SPI_PlaySelectNum(SPIPLAY_SONG_MIN_VOLUME, 0);
				InDacChannelSel(DAC_CH_ONCHIP_FM);
				RadioSetFreq();
				SysClkDivSet(CLK_DIV_RATE);
			}
#endif

#ifdef FUNC_POWER_AMPLIFIER_EN
			ABPowerAmplifierOff();			
#endif

#ifdef FUNC_OTP_KEY_SOUND_EN
			OTP_PlaySelNum(OTPPLAY_NUM_VOLDN, 0);
			InDacChannelSel(DAC_CH_ONCHIP_FM);
			RadioSetFreq();
			UnMute();
			SysClkDivSet(CLK_DIV_RATE);
#endif
#ifdef FUNC_PT231X_EN
                    VolType = VOL_MAIN;
                    PT2313VolSub();
#else
			VolumeAdjust(DOWN);
#endif
			break;
#ifdef FUNC_PT231X_EN
              case MSG_TREBUP:
			VolType = VOL_TREB;
                     PT2313VolAdd();  	
			break;  	
		case MSG_TREBDN:
			VolType = VOL_TREB;
                     PT2313VolSub();  	
			break;  	
		case MSG_BASSUP:
			VolType = VOL_BASS;
                     PT2313VolAdd();  	
			break;  	
		case MSG_BASSDN:
			VolType = VOL_BASS;
                     PT2313VolSub();  	
			break;  	
		case MSG_DEFAULT:
			PT2313TrebBassSetDefault();
			break;  	
#endif
#if defined(AU6210K_HXX_B002)
		case MSG_PLAY_PAUSE:
#endif
		case MSG_MUTE:
			if(gRadioCtrl.State == RADIO_IDLE)
			{			
#if 0//def FUNC_SPI_KEY_SOUND_EN
				if(gSys.MuteFg)
				{
					SPI_PlaySelectNum(SPIPLAY_SONG_UNMUTE, 0);
				}
				else
				{	
					SPI_PlaySelectNum(SPIPLAY_SONG_MUTE, 0);
				}				
				InDacChannelSel(DAC_CH_ONCHIP_FM);
				if(gSys.MuteFg)
				{
					RadioSetFreq();
					gSys.MuteFg = TRUE;
				}
				SysClkDivSet(CLK_DIV_RATE);
#endif
				MuteStatusChange();			
			}
			break;	
		
#if (defined(AU6210K_BOOMBOX_DEMO))
		case MSG_CLOCK:			
			if(gRadioCtrl.State == RADIO_IDLE)
			{
				gRadioCtrl.State = RADIO_PROG;
				RadioDisFlag = RadioDisCurProgramNum;
				TimeOutSet(&gRadioCtrl.SeekPreviewTimer, RadioProgramWaitTime);
				break;
			}	

			if(gRadioCtrl.State == RADIO_PROG)
			{		
				if(gRadioData.CurrFreq < RADIO_FREQ_BASE_875) 
				{
					gRadioData.Stations[gRadioData.CurrStation] = (gRadioData.CurrFreq - RADIO_FREQ_BASE_760);
				}
				else if(gRadioData.CurrFreq > RADIO_FREQ_BASE_875)
				{
					gRadioData.Stations[gRadioData.CurrStation] = (gRadioData.CurrFreq - RADIO_FREQ_BASE_875);
				}				
				gRadioData.Stations[gRadioData.CurrStation + (MAX_RADIO_STATION_NUM / 2)] = gRadioData.CurrStation + 1;
				gRadioData.StationSum = (MAX_RADIO_STATION_NUM / 2);		
					
				RadioShowDebug(RadioShowSaveCurFreToCurChannle);
#ifdef FUNC_BREAK_POINT_EN
				RadioWriteData();
#endif
				RadioDisFlag = RadioDisCurFreNum;
				gRadioCtrl.State = RADIO_IDLE;
			}
			break;

		case MSG_FM_STERO_SW:
			if(gRadioCtrl.State == RADIO_IDLE)
			{
				gRadioMonoEnableFlag ^= 1;
				RadioMonoModeSet(gRadioMonoEnableFlag);			
			}
			break;
#endif

		default:	
			break;
	}//switch(Event)

#ifdef FUN_SYSTEM_POWEROFF_WAIT_TIME
	SystemOffTimeMsgPro(Event);
#endif
}
Ejemplo n.º 10
0
void* SntpService(void* pParam, int interval)
{
    fd_set r;
    struct timeval tv;
    NTP_TIME_FMT ct, lastTime = { 0 };
    NTP_PKT pkt;
    char tmpBuf[256], ntpServer[80+1];

    char ntpMode, bServer = 0, bClient = 1;
    struct sockaddr_in addr, addrReceive;
    int ret, sock = socket(PF_INET, SOCK_DGRAM, 0);
    socklen_t addrlen;
    
    if(sock==-1) {
        printf("SntpService: create sock failed.(%s)\r\n", strerror(errno));
        return NULL;
    }
    
    addr.sin_family = PF_INET;
    addr.sin_port = htons(SNTP_PORT); /* NTP port No. */
    addr.sin_addr.s_addr = 0;
    if (bind(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr))==-1)
    {
        printf("Bind socket on port %d fail, errno: %d.\r\n", SNTP_PORT, errno);
        close(sock);
        return NULL;
    }

    memset(ntpServer, 0, sizeof(ntpServer));

    strncpy(ntpServer, (char*)pParam, sizeof(ntpServer)-1);
    if(ntpServer[0])
    {
        bServer = 0;
        bClient = 1;
    }
    else
    {
        bServer = 1;
        bClient = 0;
    }

#ifdef SNTP_DBG
    printf("SntpService starting, mode = %d, ntpServer: %s ...\r\n", bServer | (bClient<<1), ntpServer);
#endif

    
    addr.sin_addr.s_addr = 0;
    while(1)
    {
        int tz = GetTimeZone();
        if(MessageGet(MSG_SNTP_QUIT, NULL, 0, 0)>=0)
        {
            break;
        }
        
        if(MessageGet(MSG_SNTP_MODE, &ntpMode, 1, 0)==1)
        {
            bServer = ntpMode & 0x01;
            bClient = ntpMode & 0x02;
            lastTime.seconds = 0;
            printf("SNTP service mode = %d ...\r\n", bServer | (bClient<<1));
        }

        memset(tmpBuf, 0, sizeof(tmpBuf));
        if(MessageGet(MSG_SNTP_SERVER, tmpBuf, sizeof(tmpBuf)-1, 0)>=0)
        {
            memset(ntpServer, 0, sizeof(ntpServer));
            strncpy(ntpServer, tmpBuf, sizeof(ntpServer)-1);
            if(ntpServer[0]=='\0')
            {
                bClient = 0;
            }
            addr.sin_addr.s_addr = 0;
            lastTime.seconds = 0;
            printf("SNTP server = %s ...\r\n", ntpServer);
        }
        if(bClient)
        {
            /* send request every minute */
            time(&ct.seconds);
            if(ct.seconds<lastTime.seconds || (ct.seconds-lastTime.seconds)>=interval)
            {
                if(addr.sin_addr.s_addr==0)
                {
                    if(ntpServer[0])
                    {
                        struct hostent* pHost = gethostbyname(ntpServer);
                        if(pHost)
                        {
                            addr.sin_addr.s_addr = ((struct in_addr*)pHost->h_addr_list[0])->s_addr;
                        }
                    }
                }
                if(addr.sin_addr.s_addr)
                {
                    lastTime.seconds = ct.seconds;
                    memset(&pkt, 0, sizeof(pkt));
                    pkt.basic.liVnMode=0x1b;
                    pkt.basic.transmitTimestamp.seconds = htonl(ct.seconds+SECONDS_FROM_1900_1970-tz);
                    pkt.basic.transmitTimestamp.fractional = htonl(ct.fractional);
#ifdef SNTP_DBG
                    printf("NTP-CLIENT sending %d bytes on socket %d to port %d ...\r\n",
                        sizeof(pkt.basic), sock, ntohs(addr.sin_port));
#endif
                    sendto(sock, (char*)&pkt.basic, sizeof(pkt.basic), 0, (struct sockaddr*)&addr, sizeof(struct sockaddr));
                }
            }
        }

        FD_ZERO(&r);
        FD_SET(sock, &r);
        tv.tv_sec = tv.tv_usec = 1;
        ret = select(sock+1, &r, NULL, NULL, &tv);
        if(ret<0)
            break;
        if(ret==0)
            continue;
        addrlen = sizeof(struct sockaddr);
        memset(&pkt, 0, sizeof(pkt));
        ret = recvfrom(sock, (char*)&pkt, sizeof(pkt), 0, (struct sockaddr*)&addrReceive, &addrlen);
        if(ret<=0)
            break;

        gettimeofday(&tv, NULL);
        ct.seconds = tv.tv_sec;
        ct.fractional = tv.tv_usec;
        if(pkt.basic.receiveTimestamp.seconds==0)
        {
            if(bServer)
            {
                /* response to client */
                NTP_TIME_FMT orgTime;
                
                orgTime.seconds=pkt.basic.transmitTimestamp.seconds;
                orgTime.fractional=pkt.basic.transmitTimestamp.fractional;

                memset(&pkt, 0, sizeof(pkt));
                pkt.basic.liVnMode = 0x1C;
                pkt.basic.stratum=10;
                memcpy(pkt.basic.referenceID, "WMR", 4);
                pkt.basic.referenceTimestamp.seconds = htonl(ct.seconds+SECONDS_FROM_1900_1970-tz);
                pkt.basic.referenceTimestamp.fractional = htonl(ct.fractional);
                pkt.basic.originateTimestamp.seconds = orgTime.seconds;
                pkt.basic.originateTimestamp.fractional = orgTime.fractional;
                pkt.basic.transmitTimestamp.seconds = pkt.basic.receiveTimestamp.seconds = pkt.basic.referenceTimestamp.seconds;
                pkt.basic.transmitTimestamp.fractional = pkt.basic.receiveTimestamp.fractional = pkt.basic.referenceTimestamp.fractional;
#ifdef SNTP_DBG
                printf("NTP-SERVER response %d bytes ...\r\n", ret);
#endif
                ret = sendto(sock, (char*)&pkt, ret, 0, (struct sockaddr*)&addrReceive, addrlen);
            }
        }
        else
        {
            if(bClient)
            {
                /* read time info */
                int trip;
                int trip_usec;
                struct tm* ptm;
#ifdef SNTP_DBG
                printf("LiVnMode = %d\r\n", (unsigned char)pkt.basic.liVnMode);
                printf("Stratum = %d\r\n", (unsigned char)pkt.basic.stratum);
                printf("poll = %d\r\n", (unsigned char)pkt.basic.poll);
                printf("precision = %d\r\n", (unsigned char)pkt.basic.precision);
                pkt.basic.rootDelay = ntohl(pkt.basic.rootDelay);
                printf("RootDelay = %lu\r\n", pkt.basic.rootDelay);
                pkt.basic.rootDispersion = ntohl(pkt.basic.rootDispersion);
                printf("RootDispersion = %lu\r\n", pkt.basic.rootDispersion);
                printf("RefrenceID = %02X %02X %02X %02X\r\n", pkt.basic.referenceID[0], pkt.basic.referenceID[1], pkt.basic.referenceID[2], pkt.basic.referenceID[3]);
#endif
                pkt.basic.referenceTimestamp.seconds = ntohl(pkt.basic.referenceTimestamp.seconds)-SECONDS_FROM_1900_1970+tz;
                pkt.basic.referenceTimestamp.fractional = ntohl(pkt.basic.referenceTimestamp.fractional);
#ifdef SNTP_DBG
                ptm = gmtime(&pkt.basic.referenceTimestamp.seconds);
                if(ptm) printf("ReferenceTime = %d-%02d-%02d %02d:%02d:%02d\r\n", ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
#endif
                pkt.basic.originateTimestamp.seconds = ntohl(pkt.basic.originateTimestamp.seconds)-SECONDS_FROM_1900_1970+tz;
                pkt.basic.originateTimestamp.fractional = ntohl(pkt.basic.originateTimestamp.fractional);
#ifdef SNTP_DBG
                ptm = gmtime(&pkt.basic.originateTimestamp.seconds);
                if(ptm) printf("OriginateTime = %d-%02d-%02d %02d:%02d:%02d\r\n", ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
#endif
                pkt.basic.receiveTimestamp.seconds = ntohl(pkt.basic.receiveTimestamp.seconds)-SECONDS_FROM_1900_1970+tz;
                pkt.basic.receiveTimestamp.fractional = ntohl(pkt.basic.receiveTimestamp.fractional);
#ifdef SNTP_DBG
                ptm = gmtime(&pkt.basic.receiveTimestamp.seconds);
                if(ptm) printf("ReceiveTime = %d-%02d-%02d %02d:%02d:%02d\r\n", ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
#endif
                pkt.basic.transmitTimestamp.seconds = ntohl(pkt.basic.transmitTimestamp.seconds)-SECONDS_FROM_1900_1970+tz;
                pkt.basic.transmitTimestamp.fractional = ntohl(pkt.basic.transmitTimestamp.fractional);
#ifdef SNTP_DBG
                ptm = gmtime(&pkt.basic.transmitTimestamp.seconds);
                if(ptm)
                {
                    printf("transmitTime = %d-%02d-%02d %02d:%02d:%02d (%d.%d s)\r\n",
                        ptm->tm_year+1900,
                        ptm->tm_mon+1,
                        ptm->tm_mday,
                        ptm->tm_hour,
                        ptm->tm_min,
                        ptm->tm_sec,
                        (int)pkt.basic.transmitTimestamp.seconds, (int)pkt.basic.transmitTimestamp.fractional);
                }
                printf("\r\n");
#endif
                trip = (ct.seconds - pkt.basic.originateTimestamp.seconds)
                    - ( pkt.basic.transmitTimestamp.seconds - pkt.basic.receiveTimestamp.seconds);
                trip_usec = (ct.fractional - pkt.basic.originateTimestamp.fractional)
                    - ( pkt.basic.transmitTimestamp.fractional - pkt.basic.receiveTimestamp.fractional);

#ifdef SNTP_DBG
                printf("RoundTripDelay = %d.%06d\r\n", trip, trip_usec);
#endif
                ct.seconds = pkt.basic.transmitTimestamp.seconds+trip/2;
                ct.fractional = pkt.basic.transmitTimestamp.fractional+trip_usec/2;
                /* 处理ct.fractional绝对值超过1秒的情况 */
#define USEC_PER_SEC   1000000L
                if (abs(ct.fractional) > USEC_PER_SEC)
                {
                    ct.seconds += ct.fractional / USEC_PER_SEC;
                    ct.fractional %= USEC_PER_SEC;
                }
                /* 处理ct.fractional与ct.seconds符号不同的情况 */
                if (ct.fractional < 0)
                {
                    ct.seconds -= 1;
                    ct.fractional += USEC_PER_SEC;
                }
                ptm = gmtime(&ct.seconds);
                if (ptm)
                {
                    struct timeval tv;
#ifdef SNTP_DBG
                    struct timeval cur_time;
                    gettimeofday(&cur_time, NULL);
#endif
                    memcpy(&tv.tv_sec, &ct.seconds, sizeof(time_t));
                    tv.tv_usec = ct.fractional;
                    ret = settimeofday(&tv, NULL);
                    if(ret)
                    {
                        printf("SNTP: set system time fail\r\n");
                    }
                    else
                    {
                        printf("SNTP: Synchronize system time to %d-%02d-%02d %02d:%02d:%02d\r\n",
                            ptm->tm_year+1900,
                            ptm->tm_mon+1,
                            ptm->tm_mday,
                            ptm->tm_hour,
                            ptm->tm_min,
                            ptm->tm_sec);
#ifdef SNTP_DBG
                        printf("previous time: %ld.%06lds, new time: %ld.%06lds.\r\n",
                            cur_time.tv_sec, cur_time.tv_usec, tv.tv_sec, tv.tv_usec);
#endif
                    }
                }
            }
        }
    }

    if(sock != -1)
        close(sock);

    return NULL;
}
Ejemplo n.º 11
0
//系统启动,包括系统从SLEEP状态下唤醒启动或者从POWER DOWN状态下以片内主电源上电方式启动的相关处理
//一般情况下,2种启动方式在用户产品中不会同时存在
VOID SystemOn(VOID)
{
	TIMER	WaitTimer;

	DBG1(("*******SystemOn************\n"));
	

#if (POWER_SAVING_MODE_OPTION == POWER_SAVING_MODE_SLEEP)
	
	//获得从SLEEP状态唤醒的触发源标志
	DBG1((">>WakeUpOp(), gWakeupTrigFlg:%bx\n", gWakeupTrigFlg));

	//系统定义了IR唤醒功能,IR接收头连接于GPIOB6/GPIOE0,IR信号唤醒系统后,则判断键值
#ifdef  WIS_FLG_IR
	if((gWakeupTrigFlg == WIS_FLG_GPB6) || (gWakeupTrigFlg == WIS_FLG_GPE0))
	{		
		DWORD IrKeyData;
		

		TimeOutSet(&WaitTimer, 3500);
		//如果在规定时间内未发现预定的IR键值,则继续睡眠
		while(!IsTimeOut(&WaitTimer))	
		{
#ifdef FUNC_WATCHDOG_EN
			FeedWatchDog();
#endif
			IrKeyData = IrKeyDataVal();
			DBG1(("IrKeyData = : %08LX\n", IrKeyData)); 

			//如果检测到预定的IR键值,则开始运行系统
			if( (IrKeyData == 0x5AA57F80) ||
				(IrKeyData == 0x5FA07F80) ||
				(IrKeyData == 0x5EA17F80) ||
				(IrKeyData == 0x5DA27F80) ||
				(IrKeyData == 0x5CA37F80) ||
				(IrKeyData == 0x59A67F80) ||
				(IrKeyData == 0x5BA47F80) )
			{
				MessageInit();
				DBG1(("WAKE UP FROM SLEEP BY IR!\n"));
				baGPIOCtrl[GPIO_A_IE] &= ~0x40;//A2
				return;
			}
			else
			{
			 	DBG1(("ERROR IR KEY!\n"));
				break;
			}
		}
		
		DBG1(("TIMEOUT!\n"));
#ifdef IR_KEY_PORT
		if(IR_KEY_PORT == IR_INPUT_GPIOB6)
		{
			SetWakeupSrcInSleep(WIS_GPB6_LOW);
			DBG1(("*GPIO_B_IN:%bx\n", GetGpioReg(GPIO_B_IN)));
			while((GetGpioReg(GPIO_B_IN) & 0x40) != 0x40)
			{
				DBG1(("请确保进入Sleep状态前WakeUp条件不成立!(GPIO_C_IN:%bx(GPIOC3 shoule be 0))\n", GetGpioReg(GPIO_B_IN)));
				WaitMs(10);
#ifdef FUNC_WATCHDOG_EN
				FeedWatchDog();
#endif
			}
		}
		else if(IR_KEY_PORT == IR_INPUT_GPIOE0)
		{
			SetWakeupSrcInSleep(WIS_GPE0_LOW);
			DBG(("*GPIO_E_IN:%bx\n", GetGpioReg(GPIO_E_IN)));
			while((GetGpioReg(GPIO_E_IN) & 0x01) != 0x01)
			{
				DBG1(("请确保进入Sleep状态前WakeUp条件不成立!(GPIO_C_IN:%bx(GPIOC3 shoule be 0))\n", GetGpioReg(GPIO_B_IN)));
				WaitMs(10);
#ifdef FUNC_WATCHDOG_EN
			FeedWatchDog();
#endif
			}
		}
#endif

		GoToSleepMode(SLEEP_MOD_OTP_PD);

		DBG1(("<<WakeUpOp()\n")); 
		return;
	}

	
#endif
	

#elif (POWER_SAVING_MODE_OPTION == POWER_SAVING_MODE_POWERDOWN)
#if	(PWR_KEY_MODE == PWR_KEY_PUSH_BUTTON)
	DBG(("\nPWR_KEY_PUSH_BUTTON\n\n"));	
	SetChip8SRstMode(CRM_IN_PUSH_BUTTON);

#elif(PWR_KEY_MODE == PWR_KEY_SLIDE_SWITCH)
	DBG(("\nPWR_KEY_SLIDE_SWITCH\n\n"));	
	SetChip8SRstMode(CRM_IN_SLIDE_SWITCH);
#endif

	gWakeupTrigFlg = GetWakeupFlgFromPD();			//获得从powerdown状态触发片内主电源上电系统启动的触发源标志
	DBG(("gWakeupTrigFlg:%bx\n", gWakeupTrigFlg));

	if(WIP_SRC_PWR_KEY & gWakeupTrigFlg)
	{
		DBG(("POWER KEY SYS ON\n"));
	}
	else if(WIP_SRC_LP_RTC & gWakeupTrigFlg)
	{
		DBG(("LP_RTC SYS ON\n"));
	}

	//如果POWER_KEY使用软开关(push button),并且定义了POWER KEY开关机保持时间
	//例如,要求按住POWER_KEY超过2秒后,系统才会点亮显示继续运行,否则系统再次关闭,用户不会感觉到系统运行过
	//POWER_KEY持续按下了规定时间的判定是在power_key.c内完成的。
#if	((PWR_KEY_MODE == PWR_KEY_PUSH_BUTTON) && defined(TIME_POWER_ON_HOLD))	
	if(WIP_SRC_PWR_KEY & gWakeupTrigFlg)		//必须是POWER_KEY唤醒系统时,才检查开机保持时间,而WTD复位等系统重新启动则不需要
	{
		TimeOutSet(&WaitTimer, (TIME_POWER_ON_HOLD * 2));
		
		while(!IsTimeOut(&WaitTimer))
		{
#ifdef FUNC_WATCHDOG_EN
			FeedWatchDog();
#endif
			KeyEventGet();	

			if(MessageGet(MSG_FIFO_KEY) == MSG_SYS_ON)		//如果达到开机保持时间,则系统继续运行
			{			
				MessageInit();
				DBG(("POWER_KEY Hold time,MSG_SYS_ON\n"));
				return;
			}
		}
		
		DBG(("TIMEOUT!\n"));
		//如果在规定时间内没有收到由power_key.c推送的MSG_SYS_ON消息,需要再次系统关闭。
		GoToPDMode();
	}

#elif(PWR_KEY_MODE == PWR_KEY_SLIDE_SWITCH)
	DBG(("\nPWR_KEY_MODE == PWR_KEY_SLIDE_SWITCH\n\n"));	
#endif		
		
#endif
}