📄 i2c_panel.c
字号:
#ifdef SUPPORT_I2C_LCD_Panel
/*
** FUNCTION:init_command_cd4094b()
** PURPOSE:initialize the TFT-LCD CONTROLLER UPS017 using
** CD4094B
** CD4094B:8-Stage Shift-and-Store Bus Register
** Q1--ZX1,Q2--ZX2,Q3--ZX3,
** Q5--VM 1/0--pal/ntsc,
** Q6--UD,Q7--LRC
** tv_mode: 1/0 --- ntsc/pal
** tft_mode:1/0 --- 16:9/4:3
** tjf 2004-9-13
*/
#define SCL_GPIO 0
#define SDA_GPIO 1
#define STR_GPIO 49
//#define VIDEO_INOUT_GPIO 99
void init_command_cd4094b(BYTE tv_mode,BYTE tft_mode)
{
int i;
BYTE Data4094_pal_16_9[8]={0,0,0,1,0,1,1,1};
BYTE Data4094_pal_4_3[8]={0,0,0,1,0,1,0,0};
BYTE Data4094_ntsc_16_9[8]={0,0,0,0,0,1,1,1};
BYTE Data4094_ntsc_4_3[8]={0,0,0,0,0,1,0,0};
//NC,LR,UD,VM,NC,ZX3,ZX2,ZX1
GPIO_M_SET(47,1);
GPIO_E_SET(47,1);
GPIO_O_SET(47,1); //Set TFT_SB to H ,Enable TFT 9V.
GPIO_M_SET(STR_GPIO,1);
GPIO_E_SET(STR_GPIO,1);
GPIO_O_SET(STR_GPIO,0); //Set STROBE to L
GPIO_M_SET(SCL_GPIO,1); //Set I2C_CLK to RISC
GPIO_E_SET(SCL_GPIO,1);
GPIO_O_SET(SCL_GPIO,0); //Set I2C_CLK to L
GPIO_M_SET(SDA_GPIO,1); //Set I2C_DATA to RISC
GPIO_E_SET(SDA_GPIO,1);
GPIO_O_SET(SDA_GPIO,1); //Set I2C_DATA to H
delay_1us(100);
GPIO_O_SET(STR_GPIO,1); //Set STROBE to H for 4094 transfer data
delay_1us(10);
GPIO_O_SET(SCL_GPIO,0); //Set I2C_CLK to L
delay_1us(7);
if(tv_mode == 1)
{
for(i=0;i<8;i++)
{
if(tft_mode == 1)
GPIO_O_SET(SDA_GPIO,Data4094_ntsc_16_9[i]);
else
GPIO_O_SET(SDA_GPIO,Data4094_ntsc_4_3[i]);
delay_1us(7);
GPIO_O_SET(SCL_GPIO,1);
delay_1us(7);
GPIO_O_SET(SCL_GPIO,0);
delay_1us(7);
}
}
else
{
for(i=0;i<8;i++)
{
if(tft_mode == 1)
GPIO_O_SET(SDA_GPIO,Data4094_pal_16_9[i]);
else
GPIO_O_SET(SDA_GPIO,Data4094_pal_4_3[i]);
delay_1us(7);
GPIO_O_SET(SCL_GPIO,1);
delay_1us(7);
GPIO_O_SET(SCL_GPIO,0);
delay_1us(7);
}
}
GPIO_O_SET(STR_GPIO,0);
delay_1us(10);
}
/*
** FUNCTION:init_command_an2526fh(tv_mode)
** PURPOSE:initialize the Panasonic LCD color TV signal
** processor of AN2526FH
** AN2526FH i2c address: is 0x88 when pin49 is high,or
** is 0x8a
** AN2526FH i2c init command :16 byte,destination address
** is from 0 to 15
** communcated mode:i2c
** tv_mode: 1/0 --- ntsc/pal
** tjf 2004-9-13
*/
/* ntsc org param:
{
0x84, // 0 Vertical sync. signal output position
0x8e, // 1 Horizontal sync. signal output position
0xa0, // 2 PWM duty
0x18+0x80, // 3 Common pulse amplitude
0x7f, // 4 Y-gain
0x46+0x80, // 5 Color gain
0x3e, // 6 Hue
0x9f, // 7 Black-limiter level
0x30, // 8 Bright
0xa7, // 9 Y-aperture gain
0x9a, // 10 R-ch. sub bright
0xa2, // 11 B-ch. sub bright
0x80, // 12 White peak limiter
0x9c, // 13 Gamma-1 Knee level
0x89, // 14 Gamma-2 Knee level
0x12+0x80 // 15 RGB contrast
};
*/
void init_command_an2526fh(BYTE tv_mode)
{
int iRts;
//BYTE i = 0;
BYTE an2526_data_ntsc[16] =
{
0x84, // 0 Vertical sync. signal output position
0x8e, // 1 Horizontal sync. signal output position
0xa0, // 2 PWM duty
0x18+0x80, // 3 Common pulse amplitude
0x7f, // 4 Y-gain
0x46+0x80, // 5 Color gain
0x3e, // 6 Hue
0x9f, // 7 Black-limiter level
0x30, // 8 Bright
0xa7, // 9 Y-aperture gain
0x9a, // 10 R-ch. sub bright
0xa2, // 11 B-ch. sub bright
0x80, // 12 White peak limiter
0x9c, // 13 Gamma-1 Knee level
0x89, // 14 Gamma-2 Knee level
0x12+0x80 // 15 RGB contrast
};
BYTE an2526_data_pal[16] =
{
0x84, //Vertical sync. signal output position
0x0e, //Horizontal sync. signal output position
0xa0, //PWM duty
0x18+0x80, //Common pulse amplitude
0xad, //Y-gain
0x65+0x80, //Color gain
0x3e, //Hue
0x9f, //Black-limiter level
0x2c, //Bright
0xa7, //Y-aperture gain
0x8b, //R-ch. sub bright
0x87, //B-ch. sub bright
0x80, //White peak limiter
0x9c, //Gamma-1 Knee level
0x89, //Gamma-2 Knee level
0x31+0x80 //RGB contrast
};
GPIO_M_SET(SCL_GPIO,0); //Set I2C_CLK to IOP
GPIO_M_SET(SDA_GPIO,0); //Set I2C_DATA to IOP
//do{
if(tv_mode) //ntsc mode
iRts=WriteToI2c(0x88,0,an2526_data_ntsc,16);
else //pal mode
iRts=WriteToI2c(0x88,0,an2526_data_pal,16);
if(iRts == 1)
printf("write an2526 ok!\n");
else
printf("write an2526 error!\n");
//i++;
//} while (i < 50);
}
/*
** FUNCTION:init_I2C_panel()
** PURPOSE:initialize the panel,default is ntsc mode
** tjf 2004-9-13
*/
void init_I2C_panel(void)
{
//regs0->tv_mode[0] &= 0xfff0;
init_command_cd4094b(1,1); //ntsc mode,16:9
init_command_an2526fh(1);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -