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

📄 t108_util.c

📁 这是一个用T108加上瑞萨公司R8C2A做的一个OSD显示。希望能帮上大家。
💻 C
字号:
#include "init.h"
#include "t108_util.h"
#include "AU_7_A.c"
#include "OSD2_define.h"
#include "iic.h"
#include "GAMMA.H"

void InitT803(void);
void SET_Dismod(void);
void IR_Init(void);
void TconInit(void);
void ClosePanel(unsigned char uR, unsigned char uG, unsigned char uB);
void LoadGammaTable(unsigned char cGammaModeID);

unsigned char Dis_Mode=TOP_LEFT;


void InitT803(void)
{
	unsigned char RegIndex,RegAdr;

	RegIndex=0;
	RegAdr=stInitT10xP0[0].ucRegAdr;
	while (RegAdr != 0xFF)		// bruce, 2006/01/09
	{
		if(RegAdr==0x30){
			I2CWriteByte(TW803_P0,RegAdr,(I2CReadByte(TW803_P0,0x30)|0x01));  // enable Shadow
			I2CWriteByte(TW803_P0,RegAdr,(I2CReadByte(TW803_P0,0x30)&(~0x02))| DEINTERLACE); //Bruce, 2006/01/10
		}
		else{
			I2CWriteByte(TW803_P0,RegAdr,stInitT10xP0[RegIndex].ucRegVal);
		}
		RegAdr=stInitT10xP0[++RegIndex].ucRegAdr;
	}

	RegIndex=0;
	RegAdr=stInitT10xP1[0].ucRegAdr;
	while (RegAdr != 0xFF)		
	{
		I2CWriteByte(TW803_P0,RegAdr,stInitT10xP1[RegIndex].ucRegVal);
		RegAdr=stInitT10xP1[++RegIndex].ucRegAdr;
	}
	
	RegIndex=0;
	RegAdr=stInitT10xP2[0].ucRegAdr;
	while (RegAdr != 0xFF)		// bruce, 2006/01/09
	{
		if(RegAdr==0x01)
			I2CWriteByte(TW803_P2,RegAdr,(I2CReadByte(TW803_P2,0x01)|0x01));// enable black level correction for 10 blank-to-black pedestal
		else
			I2CWriteByte(TW803_P2,RegAdr,stInitT10xP2[RegIndex].ucRegVal);
		RegAdr=stInitT10xP2[++RegIndex].ucRegAdr;
	}
	//=========================================================================
	// Panel specified register settings
	//=========================================================================

	for(RegIndex=0;RegIndex < PanelSpecP0Cnt;RegIndex++)
	{
		I2CWriteByte(TW803_P0,ucaPanelSpecAdrP0[RegIndex],ucaPanelSpecDataP0[RegIndex]);
    }


   	for(RegIndex=0;RegIndex < PanelSpecP2Cnt;RegIndex++)
	{
		I2CWriteByte(TW803_P2,ucaPanelSpecAdrP2[RegIndex],ucaPanelSpecDataP2[RegIndex]);
    }
 
   		SET_Dismod();
		

		IR_Init();


}


void SET_Dismod(void)
{
	switch (Dis_Mode){
		case  TOP_LEFT: //Start from top-left
	
				I2CWriteByte(TW803_P0,0xE1, ScanMode[0]);
			
			break;
		case  TOP_RIGHT: //Start from top-right
		
				I2CWriteByte(TW803_P0,0xE1, ScanMode[1]);
			
			break;
		case  BOTTOM_RIGHT:  //Start from bottom-right
		
				I2CWriteByte(TW803_P0,0xE1, ScanMode[2]);
			
			break;
		case  BOTTOM_LEFT: //Start from bottom-left
		
				I2CWriteByte(TW803_P0,0xE1, ScanMode[3]);
			
			break;
	}
	#ifdef OUT_PIN_CONF
	I2CWriteByte(TW803_P0,0xE1, OUT_PIN_CONF);
	#endif
	return;
}

void IR_Init(void)
{
	I2CWriteByte(TW803_P0 + 2, 0x40, 0x10);
	I2CWriteByte(TW803_P0 + 2, 0x41, 0x3B);
	I2CWriteByte(TW803_P0 + 2, 0x47, 0x80);

	// turn on IR intterrupt
	I2CWriteByte(TW803_P0, 0x33, I2CReadByte(TW803_P0, 0x33) & 0x3F);
	I2CWriteByte(TW803_P0, 0x32, I2CReadByte(TW803_P0, 0x32) & 0xFF);
}


void TconInit(void)
{
	unsigned char TconIndex;

	for(TconIndex=0;TconIndex < P1TconCnt;TconIndex++)
	       	I2CWriteByte(TW803_P1, TconAddress+TconIndex, TconP1Data[TconIndex]);

	I2CWriteByte(TW803_P1, 0x47, 0x85);		//lucy for t128 display
	I2CWriteByte(TW803_P1, 0x52, 0xd0);
	I2CWriteByte(TW803_P1, 0x56, 0x19);
	I2CWriteByte(TW803_P1, 0x50, 0x30);
	I2CWriteByte(TW803_P1, 0x51, 0x11);
	I2CWriteByte(TW803_P1, 0xdf, 0x00);
	I2CWriteByte(TW803_P1, 0xf0, 0x0b);
	I2CWriteByte(TW803_P1, 0xf2, 0x80);
	I2CWriteByte(TW803_P1, 0xf5, 0x6e);
	I2CWriteByte(TW803_P1, 0xfd, 0x80);
	I2CWriteByte(TW803_P1, 0xfe, 0x00);
}


/*-------------------------------------------------------------------------
   ignore and block the input vsync triggering the output vsync ,
   display user define color in panel
-------------------------------------------------------------------------*/
void ClosePanel(unsigned char uR, unsigned char uG, unsigned char uB)
{
		I2CWriteByte(TW803_P0, 0xC2, I2CReadByte(TW803_P0, 0xC2)|(PSYNC_STR|IGNORE_VSYNC));
		I2CWriteByte(TW803_P0, 0x9d, uR);
		I2CWriteByte(TW803_P0, 0x9e, uG);
		I2CWriteByte(TW803_P0, 0x9f, uB);
		I2CWriteByte(TW803_P0, PATTERN_CTRL, 0x87);//enable frame background color 
		I2CWriteByte(TW803_P0, 0xe2, 0x11);   //enable registers shadow control,sync all shadow registers
}


void LoadGammaTable(unsigned char cGammaModeID)
{

  int i;
	unsigned char j,k;
	//uCHAR code **ppcGm;
	unsigned char *pcGm;

	for(j=0,k=3;j<3;j++,k--)
	{
  		pcGm=(unsigned char *)pcGammaData[j+cGammaModeID*GAMMA_PNUM];
	  	I2CWriteByte(TW803_P0,IMG_FUN_CTRL,(I2CReadByte(TW803_P0,IMG_FUN_CTRL)& ~GAMMA_CTL_MSK)|(k<<6));
  		I2CWriteByte(TW803_P0,GAMMA_ADDR,0x00);
  		for(i=0;i<GAMMA_TABLE_DATA_SIZE;i++)
		   I2CWriteByte(TW803_P0,GAMMA_DATA,pcGm[i]);		  

  	}
  I2CWriteByte(TW803_P0,TW_INTERFACE,I2CReadByte(TW803_P0,TW_INTERFACE)|AUTO_INC);

  I2CWriteByte(TW803_P0,IMG_FUN_CTRL,I2CReadByte(TW803_P0,IMG_FUN_CTRL)|ENGAMMA);
    return;
}

⌨️ 快捷键说明

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