?? nvram.c
字號:
#include <reg51.h>
#include "common.h"
#include "Struct.h"
#include "system.h"
#include "NVRam.h"
#include "TW10xReg.h"
#include "TwoWire.h"
#include "KeyPad.h"
#include "Video.h"
#include "gamma.h"
#include "T101_Util.h"
EEPVIDEO idata EepVideo;
#ifdef NVRAM
extern uWORD IDATA m_wBuff[3];
extern uCHAR IDATA m_cBuff[4];
#ifdef TV
extern bit m_bAir_Cable;
#endif
void EEPLoadPubData(void)
{
if(!(ReadPort()&kyMENU))
// if((ReadPort()&kyMENU))
{
InitEEPRom();
OSDResetVideoData();
while(!(ReadPort()&kyMENU)) {};
}
else
{
if(I2CReadByte(0xA0, 0x00) != '1' || I2CReadByte(0xA0, 0x01)!= '1' || I2CReadByte(0xA0, 0x02)!= '1' )
{
InitEEPRom();
OSDResetVideoData();
EEPSaveVideoData();//
}
else
I2CReadBytes(EEPVIDEOBLOCK, 0x04, (uCHAR *)&EepVideo, EEPVIDEOSIZE);
}
#ifdef TV
if(I2CReadByte(EEPVIDEOBLOCK, idVIDEO_FLAG_INDEX)&0x01)
{
m_bAir_Cable=1;
}
else
{
m_bAir_Cable=0;
}
#endif
OSDSetVideoValues();
EEPSaveVideoData();
}
void InitEEPRom(void)
{
I2CWriteByte(EEPBLOCK0, 0x00, '1');
twdDelay(NVRDELAY);
I2CWriteByte(EEPBLOCK0, 0x01, '1');
twdDelay(NVRDELAY);
I2CWriteByte(EEPBLOCK0, 0x02, '1');
}
void OSDResetVideoData(void)
{
EepVideo.cBright = V_BRIGHT_DEF;
EepVideo.cContrast = V_CONTRAST_DEF ;
EepVideo.cSharp = V_SHARP_DEF;
EepVideo.cHue = V_HUE_DEF;
EepVideo.cSat = V_SAT_DEF;
EepVideo.cVolume = 0x80;
EepVideo.cGamma = 0;
#ifdef T112 // add by Sherman 06'01'18
EepVideo.cRGB = V_RGB_DEF;
EepVideo.cVCOMA = V_VCOMA_DEF; // add by Sherman 06'01'23
EepVideo.cVCOMD = V_VCOMD_DEF; // add by Sherman 06'01'23
#endif
}
void OSDSetVideoValues(void)
{
// I2CWriteByte(VIDEO_ADDR,VSHARP,(I2CReadByte(VIDEO_ADDR,VSHARP)&0xF0)|EepVideo.cSharp);
I2CWriteByte(TW101+4,0x80,V_SHARP_MSK|(EepVideo.cSharp<<1));
// I2CWriteByte(VIDEO_ADDR,VBRIGHT,EepVideo.cBright);
// I2CWriteByte(VIDEO_ADDR,VCONTRAST,EepVideo.cContrast);
I2CWriteByte(TW101,VBRIGHT,EepVideo.cBright);
I2CWriteByte(TW101,VCONTRAST,EepVideo.cContrast);
I2CWriteByte(VIDEO_ADDR,VSAT,EepVideo.cSat);
I2CWriteByte(VIDEO_ADDR,VHUE,EepVideo.cHue-0x80);
#ifdef T112
I2CWriteByte(TW101,VRGB,EepVideo.cRGB); // add by Sherman 06'01'18
I2CWriteByte(TW101,VVCOMA,EepVideo.cVCOMA); // add by Sherman 06'01'23
I2CWriteByte(TW101,VVCOMD,EepVideo.cVCOMD); // add by Sherman 06'01'23
#endif
LoadGammaTable(EepVideo.cGamma);
#ifdef LG_7
I2CWriteByte(TW101+4, 0x80, 0x25);
#endif
}
void EEPSaveVideoData(void)
{
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_CONTRAST_INDEX,EepVideo.cContrast );
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_BRIGHT_INDEX, EepVideo.cBright);
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_SHARP_INDEX, EepVideo.cSharp);
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_HUE_INDEX, EepVideo.cHue);
twdDelay(NVRDELAY);
#ifdef T112
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_RGB_INDEX, EepVideo.cRGB); // add by Sherman 06'01'18
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_VCOMA_INDEX, EepVideo.cVCOMA); // add by Sherman 06'01'23
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_VCOMD_INDEX, EepVideo.cVCOMD); // add by Sherman 06'01'23
twdDelay(NVRDELAY);
#endif
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_SAT_INDEX, EepVideo.cSat);
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK, idVIDEO_VOLUME_INDEX, EepVideo.cVolume);
}
#ifdef TV
void EEPSaveTVChannel(uCHAR cTVNum, uWORD wTVFreq)
{
if(m_bAir_Cable)
{
I2CWriteByte(EEPVIDEOBLOCK+4, idTVCHANNEL_STAT+cTVNum*2, (uCHAR)(wTVFreq>>8));
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK+4, idTVCHANNEL_STAT+cTVNum*2+1, (uCHAR)(wTVFreq&0x00FF));
twdDelay(NVRDELAY);
}
else
{
I2CWriteByte(EEPVIDEOBLOCK+2, idTVCHANNEL_STAT+cTVNum*2, (uCHAR)(wTVFreq>>8));
twdDelay(NVRDELAY);
I2CWriteByte(EEPVIDEOBLOCK+2, idTVCHANNEL_STAT+cTVNum*2+1, (uCHAR)(wTVFreq&0x00FF));
twdDelay(NVRDELAY);
}
}
#endif
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -