📄 misc.c
字号:
/******************************************************************************
Copyright (c) 2005 MStar Semiconductor, Inc.
All rights reserved.
[Module Name]: Misc.c
[Date]: 04-Jan-2005
[Comment]:
Misc subroutines.
[Reversion History]:
*******************************************************************************/
#define _MISC_C_
/********************
* INCLUDE FILES *
*********************/
#include "Project.h"
#include "Global.h"
#include "Misc.h"
#include "Ms7X_reg.h"
#include "Mcu_reg.h"
#include "Ms_Rwreg.h"
#include "Ms_Func.h"
#include "Timer0.h"
#include "Debug.h"
#include "PANEL.h"
/**********************
* FUNCTION PROTOTYPES *
***********************/
void miscGetDelayHandle(void)
{
g_ucDelayTimerHandle = sysTimer0Register();
g_ucOSDTimerHandle = sysTimer0Register();
//sysWriteUartOneByte(g_ucDelayTimerHandle);
}
void miscDelay1ms(WORD mstime)
{
sysTimer0Set(g_ucDelayTimerHandle, mstime);
while(!(sysTimer0Expired(g_ucDelayTimerHandle) == TIMER_EXPIRED));
}
void miscTurnOffPanel(void)
{
PANEL_BLIGHT_OFF(); // Turn off backlight
mstWriteByte(BK0_5C_FRAME_COLOR_1, 0xFF); // Send white pattern
mstWriteByte(BK0_5D_FRAME_COLOR_2, 0xFF);
mstWriteByte(BK0_02_ISELECT, mstReadByte(BK0_02_ISELECT)|NIS_B); // Mute display
miscDelay1ms(50); // Wait 50ms for panel discharge
#if PANEL_OFF_TIMING1 != 0
miscDelay1ms(PANEL_OFF_TIMING1);
#endif
#if (PANEL_TCON + PANEL_ANALOG_TCON)
mstWriteByte(GEN_00_REGBK, REGBANKADC); // Switch to Bank 1 for TCON control
mstWriteByte(BK1_D1_PTC_MODE2, (SET_PTC_MODE2&0xBC)); // Set L/R and U/D to low
mstWriteByte(BK1_D0_PTC_MODE1, (SET_PTC_MODE1&0x7F)); // Disable TCON
#endif
mstWriteByte(GEN_00_REGBK, REGBANKSCALER); // Switch to Bank 0 for data output control
mstWriteByte(BK0_F4_TRISTATE, 0x1F); // Disable data output
#if PANEL_OFF_TIMING2 != 0
miscDelay1ms(PANEL_OFF_TIMING2);
#endif
#if PANEL_ANALOG_TCON
mstWriteByte(GEN_00_REGBK, REGBANKADC); // Switch to Bank 1 for TCON control
mstWriteByte(BK1_4A, 0x0F); // Turn off VGL and VGH
mstWriteByte(BK1_4B, 0x4C);
mstWriteByte(GEN_00_REGBK, REGBANKSCALER); // Switch to Bank 0
#endif
#if (ENABLE_CCFL_FUNCTION)
mstWriteByte(GEN_00_REGBK,REGBANKLVDS_CCFL);
mstWriteByte(BK4_6B, 0x80);
mstWriteByte(BK4_6D, 0x00); //0x00-->0x02
mstWriteByte(BK4_6E, 0x05);
mstWriteByte(BK4_6B, 0x00);
mstWriteByte(GEN_00_REGBK, REGBANKSCALER);
#else
PANEL_VCC_OFF(); // Turn off panel VDD
#endif
}
void miscTurnOnPanel(void)
{
PANEL_VCC_ON(); // Turn on panel VDD
#if PANEL_ANALOG_TCON
mstWriteByte(GEN_00_REGBK, REGBANKADC); // Switch to Bank 1 for TCON control
mstWriteByte(BK1_4A, 0x00); // Turn on VGL and VGH
mstWriteByte(BK1_4B, 0x40);
mstWriteByte(BK1_45, 0x00);
#endif
#if PANEL_ON_TIMING1 != 0
miscDelay1ms(PANEL_ON_TIMING1);
#endif
mstWriteByte(GEN_00_REGBK, REGBANKSCALER); // Switch to Bank 0 for data output control
mstWriteByte(BK0_F4_TRISTATE, 0x00); // Enable data output
#if (PANEL_TCON + PANEL_ANALOG_TCON)
mstWriteByte(GEN_00_REGBK, REGBANKADC); // Switch to Bank 1 for TCON control
mstWriteByte(BK1_D1_PTC_MODE2, SET_PTC_MODE2); // Reload PTC_MODE2 value
mstWriteByte(BK1_D0_PTC_MODE1, SET_PTC_MODE1); // Enable TCON
mstWriteByte(GEN_00_REGBK, REGBANKSCALER); // Switch to Bank 0
#endif
#if USE_ROTATE_OSD
if((Display.ucSystemStauts & ROTATE_STATUS_FLAG) != 0)
mstSetDisplayRotate(1);
#endif // USE_ROTATE_OSD
#if PANEL_ON_TIMING2 != 0
miscDelay1ms(PANEL_ON_TIMING2);
#endif
#if (ENABLE_CCFL_FUNCTION)
mstWriteByte(GEN_00_REGBK,REGBANKLVDS_CCFL);
mstWriteByte(BK4_6B, 0x80);
mstWriteByte(BK4_6E, 0x0D);
mstWriteByte(BK4_6D, 0x03);
mstWriteByte(BK4_6B, 0x00);
mstWriteByte(GEN_00_REGBK, REGBANKSCALER);
#else
PANEL_BLIGHT_ON(); // Turn on backlight
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -