📄 52xx-main.c
字号:
/*
$Workfile: 52xx-main.c $
$Revision: 1.66 $
$Date: Aug 23 2006 23:17:36 $
*/
//******************************************************************
//
// Copyright (C) 2002. GENESIS MICROCHIP INC.
// All rights reserved. No part of this program may be reproduced.
//
// Genesis Microchip Corp., 2150 Gold Street
// Alviso, CA 95002 USA
// Genesis Microchip Inc., 165 Commerce Valley Dr. West
// Thornhill, Ontario, Canada, L3T 7V8
//
//================================================================
//
// MODULE: 52xx_main.c
//
//************************************************************************
#include "..\inc\all.h"
#include ".\AppsTest\appstest.h"
#if DEBUG_MSG
#define msg(a,b) gm_Print((const char far *)a,b)
#else
#define msg(a,b)
#endif
#ifdef USE_PIXCR_DATAINVIDEO
extern void PixCrDataInVideoRun(void);
#endif
//**************************************************************
// F U N C T I O N P R O T O T Y P E S
//**************************************************************
static void __near Application_Init(void);
void main(void)
{
// initialize system timer and post custom timers that timer isr should process
gm_TimerInit((DWORD)CPU_CLK_KHZ*1000UL, &UserTimers[0], Num10mstimers, Num100mstimers);
// Initial ExceptionHandler earily, in case of system hang-up when exception occurs during system init.
//***************************************************************************
//
// init exception handler, please see exceptions.h for options
// exception handler traps unused op-codes, divide by 0 interrupts, etc.
// In addition, it has options to activate the watch dog timer (WDT)
// The default timeout for the WDT is set by WDT_TIMEOUT_SECONDS in exceptions.h.
// The function PetWatchdog() must be invoked at an interval less than WDT_TIMEOUT_SECONDS
//
//***************************************************************************
InitExceptionHandler();
#if UART_OFF
gm_ClearRegBitsByte(OCM_CONTROL, OCM_UART_EN); // UART disabled
#else
gm_SetRegBitsByte(OCM_CONTROL, OCM_UART_EN); // UART enabled
#if (UART_PORT == 0)
gm_ClearRegBitsByte(OCM_CONTROL, OCM_UART_PIN_SEL); // UART on DDC
#elif (UART_PORT == 1)
gm_SetRegBitsByte(OCM_CONTROL, OCM_UART_PIN_SEL); // UART on GPO
#endif // UART_PORT
#endif // UART_OFF
//***************************************************************************
// init RCLK and OCM clock based on bootstrap jumper settings.
// note, this is an IROM routine, to ignore bootstrap jumper settings
// rclk pll, and ocm clock selection must be set up based on TCLK frequency, rom characteristics, and selected OCM clock
//***************************************************************************
gm_SystemInit();
Application_Init(); // Global Variable Init
#if DEBUG_MSG
PrintVersion(); // Prints Product ID and Firmware Revision
#endif
System_Init();
Osd_Init();
#if (WB_MAJOR >= 4)
KeypadInit(); //For WB4, all keypad drivers (IR, GPIO, LBADC) are initialized here.
#endif // PHOENIX_U
if(!GetPowerOnFlag())
{
//PowerUpFlag.ReqPowerOff_Key = gmd_TRUE;
PowerUpFlag.SoftPowerOnState = gmd_FALSE;
SendMsg(&OsdQ, MTO_REQ_HARD_POWER_DOWN );
SendMsg(&PowerHandlerQ, MTP_SOFTKEY_OFF);
}
#if USE_SPLASH_SCREEN
else
{
// Display Splash Screen OSD only when power is on.
SplashScreen();
#ifdef PHOENIX_U
gm_PowerUpPanel();
#endif
}
#endif
#if DEBUG_MSG
ListNvramMappingDirectory();
#endif
#ifdef USE_PIXCR_DATAINVIDEO
DIVControl = 0;
#endif
while(1)
{
#if While_Loop_Test
WORD t1,t2;
t1 = (WORD)gm_ReadSystemTime();
#endif
PetWatchdog();
#if DEBUG_MSG
if(!DebugOnly)
#endif
{
if ( SystemFlags.SplashScreen )
{
// force SplashScreen to 0 if osd application failed to reset
// within N seconds. N is longest wait period
static WORD SplashScrTimeout = 30000;
if ( 0 == SplashScrTimeout-- )
SystemFlags.SplashScreen = gmd_FALSE;
}
else
{
// If soft power off, no need to do mode and power management handlers.
if (PowerUpFlag.SoftPowerOnState)
{
Mode_Handler();
}
PowerMgmt_Handler();
}
OSD_Handler();
AutoAdjust_Handler();
OSD_Handler();
#ifdef USE_PIXCR_DATAINVIDEO
if(DIVControl > 0 && ((gm_ReadRegByte(OSD_ENABLES) & (OSD_REC1_EN | OSD_REC2_EN)) == 0))
{
if((DIVControl++) >= 10)
{
PixCrDataInVideoRun();
DIVControl = 1;
}
}
#endif
#if USE_TEST_PATTERN
if (!SystemFlags.SplashScreen )
{
if(PowerUpFlag.SoftPowerOnState)
{
TestPattern_Handler();
}
}
#endif // USE_TEST_PATTERN
#ifdef UserPrefMonitorOnTime
OnTimeKeeper();
#endif
#if defined(PHOENIX) || defined(TUCSON) || defined(PHOENIX_U)
#ifdef USE_LBADC_CABLE_DETECTION
CableDetect_Handler();
#endif
#endif
#ifdef PHOENIX_U
if (!SystemFlags.TestPatternRunning) //When testpattern running, no need to do update hardware
#endif // Fix for softkey on/off during testpattern running.
{
gm_HardwareUpdate();
}
ADCCalibration();
}// DebugOnly
gm_Ddc2biHandler(); // check for ddc2bi packets
DDCCI_Handler();
#if THEFT_DETERRENCE_SUPPORT
DDC2Bi_TheftDeterrenceHandler();
#endif
#if DEBUG_MSG
// debugger handler
gm_SerialHandler(); // check for packets from the serial port
// Capture GProbe commands not handled by gm_SerialHandler() or gm_Ddc2biHandler()
AppsTestHandler();
#endif
#if (UART_PORT == 0)
if((gm_ReadRegByte(OCM_CONTROL) & OCM_UART_PIN_SEL))
gm_ClearRegBitsByte(OCM_CONTROL, OCM_UART_PIN_SEL); // UART on DDC
#elif (UART_PORT == 1)
if(!(gm_ReadRegByte(OCM_CONTROL) & OCM_UART_PIN_SEL))
gm_SetRegBitsByte(OCM_CONTROL, OCM_UART_PIN_SEL); // UART on GPO
#endif // UART_PORT
#if While_Loop_Test
t2 = (WORD)gm_ReadSystemTime();
if(t2 > t1)
gm_Print("Time ............... = %d", t2 - t1);
else
gm_Print("Time ............... = %d", t1 - t2);
#endif
}// while(1)
}
static void __near Application_Init(void)
{
GlobalVariablesInit();
// Enable_Interrupt; // macro to enable global interrupts
// BUG - initialize wait state generator, rclk, and ocm clock domain.
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -