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

📄 power.c

📁 主要用于液晶电视解码,内置51单片机,全部代码用C编写,编译环境为KEILC
💻 C
字号:
#define _POWER_C_

#include "types.h"
#include "board.h"
#include "global.h"
#include "ms_reg.h"
#include "panel.h"
#include "misc.h"
#include "ms_rwreg.h"
#include "mstar.h"
#include "DEBUG.h"
#include "msOsd.h"
#include "Tda7052.h"
#include "devvd.h"
#include "menudef.h"

#define TurnOffOSD		1

void Power_TurnOffPanel(void);
void Power_PowerOffSystem(void);
extern void PanelReversal(BYTE Position);

//=============================================
// Control system power status
// caller : main()
void Power_PowerHandler(void)
{
	if (ForcePowerSavingFlag)
    {
    	Clr_ForcePowerSavingFlag(); // clear force power saving flag
      	if (!PowerSavingFlag)
      	{ printMsg("enter power saving");
      	  Power_PowerOffSystem();
      	}
    }
}

void Power_PowerOnSystem(void)
{
	Power_TurnOffPanel();
  	msPowerUp();
  	Clr_PowerSavingFlag();
  	Set_InputTimingChangeFlag();
  	SrcFlags|=SyncLoss;

  	Clr_SleepTimeoutFlag();
  	g_uwSleepTimeCounter=0;
  	g_ucSleepTime=SleepTimeOff;

  	Clr_ForcePowerONFlag();
  	Clr_EnableONTimeFlag();

#if TV_ENABLE
  	if (IsTVInUse())
		Set_ChannelChangFlag();
#endif

	Set_ShowSourceFlag();
  	hw_SetTunerOn();
}

void Power_PowerOffSystem(void)
{
	Power_TurnOffPanel();
  	msPowerDown();
  	Set_PowerSavingFlag();
  	Clr_InputTimingChangeFlag();
	Clr_FactoryModeFlag();
  	g_ucOsdCounter=0;
  	g_ucPowerDownCounter=0;

  	Clr_EnableOFFTimeFlag();

  	Clr_SleepTimeoutFlag();
  	g_uwSleepTimeCounter=0;
  	g_ucSleepTime=SleepTimeOff;

  	Clr_OsdTimeoutFlag();

       Clr_ChannelChangFlag();
       #if Enable_Logo_Display
       Clr_DrawLogoFlag();
       ucLogoDisplayCounter=0;
       #endif

 	hw_SetTunerOff();
}

void Power_TurnOnGreenLed(void)
{
	hw_SetGreenLed();
}
void Power_TurnOffGreenLed(void)
{
	hw_ClrGreenLed();
}

void Power_TurnOnPanel(void)
{
#if (PANEL_DIGITAL_TCON|PANEL_ANALOG_TCON)  //LSP2006-5-9
	msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU);	// Switch to Bank 1 for TCON control
	msWriteByte(BK1_D0_PTC_MODE1, SET_PTC_MODE1);		// Enable TCON
	msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);			// Switch to Bank 0
#endif

#if PANEL_ANALOG_TCON
	msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU);			// Switch to Bank 1 for TCON control
	msWriteByte(BK1_4A, 0x00);				                    // Turn on VGL and VGH
	msWriteByte(BK1_4B, 0x40);
	msWriteByte(BK1_45, 0x00);
#endif

  	//Delay1ms(PanelOnTiming1);
  	Delay1ms_AGC_Processor(PanelOnTiming1);

	hw_SetPanelPower();

	msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);			// Switch to Bank 0 for data output control
	msWriteByte(BK0_F4_TRISTATE, 0x00);				// Enable data output

   	PanelReversal(g_VideoSetting.DOWN);

  	//Delay1ms(PanelOnTiming2);
	Delay1ms_AGC_Processor(PanelOnTiming2);

 	if (g_bInputTimingChangeFlag)
    	Power_TurnOffPanel();
  	else
  	{
        #if (CCFL_FUNCTION)
		msWriteByte(BK0_00_REGBK, REG_BANK4_LVDS_CCFL);
		msWriteByte(BK4_6B, 0x80);
		msWriteByte(BK4_9A, 0xCF);

		#if CCFL_BURST_MODE
		msWriteByte(BK4_6E, 0x0D);
		#else
		msWriteByte(BK4_6E, 0x0C);
		#endif

	        if(!(g_VdInfo.wVideoStatus& VD_VSYNC_50HZ))
	            msWriteByte(BK4_AC, 0x61);
	        else
	            msWriteByte(BK4_AC, 0x81);
		msWriteByte(BK4_6D, 0x03);
		msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);
        #else
		hw_SetBlacklit();					// Turn on backlight
        #endif

	    devAudioInputSelect();
		if(!(g_VdInfo.wVideoStatus& VD_HSYNC_LOCKED))
			SetAudioMute();
		else
		{
			if(!g_VideoSetting.MuteStatus)
	            devAudioSetVolume(g_VideoSetting.volume);
		}
  	}
}

void Power_TurnOffPanel(void)
{
    //   devAudioWrite(0);
    //   Delay1ms(20);
	SetAudioMute();
#if TurnOffOSD
  	msWriteOSDByte(OSD_01_OSDDBC, 0x00); // disable osd double buffer
  	msWriteOSDByte(OSD_0C_IOSDC1, 0);
//  msWriteOSDByte(BK0_01_DBFC, 0x0); // disable double buffer
//  msWriteByte(OCTRL2, msReadByte(OCTRL2)|BLKS_B);
  	Delay4us();
#endif


	#if (CCFL_FUNCTION)
	msWriteByte(BK0_00_REGBK,REG_BANK4_LVDS_CCFL);
	msWriteByte(BK4_6B, 0x80);
	msWriteByte(BK4_6D, 0x00);
	msWriteByte(BK4_6E, 0x05);
	msWriteByte(BK4_6B, 0x00);
	msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);
	#else
	hw_ClrBlacklit();					// Turn off panel VDD
	#endif

  	//hw_ClrBlacklit();
  	Delay1ms(PanelOffTiming1);

#if (PANEL_DIGITAL_TCON|PANEL_ANALOG_TCON)
	msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU);			// Switch to Bank 1 for TCON control
	msWriteByte(BK1_D0_PTC_MODE1, (SET_PTC_MODE1&0x7F));		// Disable TCON
#endif

	PanelReversal(g_VideoSetting.DOWN);

	msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);			// Switch to Bank 0 for data output control
	msWriteByte(BK0_F4_TRISTATE, 0x1F);				// Disable data output

	Delay1ms(PanelOffTiming2);
	hw_ClrPanelPower();

#if PANEL_ANALOG_TCON
	msWriteByte(BK0_00_REGBK, REG_BANK1_ADC_ACE_MCU);			// Switch to Bank 1 for TCON control
	msWriteByte(BK1_4A, 0x0F);				// Turn off VGL and VGH
	msWriteByte(BK1_4B, 0x4C);
	msWriteByte(BK0_00_REGBK, REG_BANK_SCALER);			// Switch to Bank 0
#endif

#if TurnOffOSD
  	msWriteOSDByte(OSD_01_OSDDBC, 0x5); // enable double
#endif

	g_ucSyncMaxStableCounter=150;
}

⌨️ 快捷键说明

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