基于6410的3.5寸电阻屏驱动修改
主要配置片选信号,时钟信号。复位信号,数据信号初始化
代码如下
在bsp_cfg.h添加
#elif (LCD_MODULE_TYPE == LCD_MODULE_BT035H)
#define LCD_WIDTH 320
#define LCD_HEIGHT 480
#define LCD_BPP 16
#define LCD_VBPD 1
#define LCD_VFPD 1
#define LCD_VSPW 2
#define LCD_HBPD 2
#define LCD_HFPD 2
#define LCD_HSPW 41
#define LCD_RGB_OUT_MODE DISP_16BIT_RGB565_P
#define LCD_VCLK_POLARITY IVCLK_FALL_EDGE
#define LCD_HSYNC_POLARITY IHSYNC_LOW_ACTIVE
#define LCD_VSYNC_POLARITY IVSYNC_LOW_ACTIVE
#define LCD_VDEN_POLARITY IVDEN_HIGH_ACTIVE
#define LCD_PNR_MODE PNRMODE_RGB_P
#define LCD_VCLK_SOURCE CLKSEL_F_HCLK
#define LCD_VCLK_DIRECTION CLKDIR_DIVIDED
#define LCD_FRAME_RATE 100
#define LCD_TFT_CLKVAL 9
在s3c2416_ldi.c添加
LDI_ERROR LDI_initialize_LCD_module(void)
{
LDI_ERROR error = LDI_SUCCESS;
LDI_MSG((_T("[LDI]++LDI_initialize_LCD_module()\n\r")));
#if 1
{
LDI_BT035H_RGB_port_initialize();
LDI_BT035H_RGB_power_on();
LDI_BT035H_RGB_initialize();
//LDI_ERR((_T("[LDI]--LDI_initialize_LCD_module(): %d\n\r"), error));
}
#endif
LDI_MSG((_T("[LDI]--LDI_initialize_LCD_module() : %d\n\r"), error));
return error;
}
添加三个函数代码
#define BT035_RESET_H (g_pGPIOReg->GPDDAT|= (1<<1))
#define BT035_RESET_L (g_pGPIOReg->GPDDAT &= ~(1<<1))
#define BT035_CS_H (g_pGPIOReg->GPCDAT |= (1<<8))
#define BT035_CS_L (g_pGPIOReg->GPCDAT &= ~(1<<8))
#define BT035_CLK_H (g_pGPIOReg->GPDDAT |= (1<<0))
#define BT035_CLK_L (g_pGPIOReg->GPDDAT &= ~(1<<0))
#define BT035_DAT_H (g_pGPIOReg->GPCDAT |= (1<<9))
#define BT035_DAT_L (g_pGPIOReg->GPCDAT &= ~(1<<9))
static void LCD_ILI9486_CMD(unsigned char cmd)
{
unsigned long i,j,k;
BT035_CS_L;
BT035_CLK_L;
BT035_DAT_L ; //sda=0
BT035_CLK_H;
for(i=0;i<8;i++)
{
BT035_CLK_L;
if(cmd&0x80)
{
BT035_DAT_H;
}
else
{
BT035_DAT_L;
}
BT035_CLK_H;
cmd=cmd<<1;
}
BT035_CS_H ;
}
void LCD_ILI9486_INDEX(unsigned char data)
{
unsigned long i,j,k;
BT035_CS_L;
BT035_CLK_L;
BT035_DAT_H ; //sda=1
BT035_CLK_H;
for(i=0;i<8;i++)
{
BT035_CLK_L;
if(data&0x80)
{
BT035_DAT_H;
}
else
{
BT035_DAT_L;
}
BT035_CLK_H;
data=data<<1;
}
BT035_CS_H ;
}
static void LDI_BT035H_RGB_port_initialize()
{
//vd0 vd1 vd8 vd9 out
g_pGPIOReg->GPCCON = g_pGPIOReg->GPCCON&(~(0xf<<16)) | (0x5<<16);
g_pGPIOReg->GPDCON = g_pGPIOReg->GPDCON&(~(0xF<<0)) | (0x5<<0);//|(0x1<<16)|(0x1<<18);
}
static void LDI_BT035H_RGB_power_on()
{
}
static void LDI_BT035H_RGB_power_off()
{
}
static LDI_ERROR LDI_BT035H_RGB_initialize()
{
// VCI=2.8V
//************* Reset LCD Driver ****************//
BT035_RESET_H;
DelayLoop_1ms(1); // Delay 1ms
BT035_RESET_L;
DelayLoop_1ms(100); // Delay 10ms // This delay time is necessary
BT035_RESET_H;
DelayLoop_1ms(20); // Delay 100 ms
//************* Start Initial Sequence **********//
LCD_ILI9486_CMD(0XF1);
LCD_ILI9486_INDEX(0x36);
LCD_ILI9486_INDEX(0x04);
LCD_ILI9486_INDEX(0x00);
LCD_ILI9486_INDEX(0x3c);
LCD_ILI9486_INDEX(0x0f);
LCD_ILI9486_INDEX(0x8f);
LCD_ILI9486_CMD(0XF2);
LCD_ILI9486_INDEX(0x18);
LCD_ILI9486_INDEX(0xa3);
LCD_ILI9486_INDEX(0x12);
LCD_ILI9486_INDEX(0x02);
LCD_ILI9486_INDEX(0xb2);
LCD_ILI9486_INDEX(0x12);
LCD_ILI9486_INDEX(0xff);
LCD_ILI9486_INDEX(0x10);
LCD_ILI9486_INDEX(0x00);
LCD_ILI9486_CMD(0XF8);
LCD_ILI9486_INDEX(0x21);
LCD_ILI9486_INDEX(0x04);
LCD_ILI9486_CMD(0XF9);
LCD_ILI9486_INDEX(0x00);
LCD_ILI9486_INDEX(0x08);
LCD_ILI9486_CMD(0XB1);
LCD_ILI9486_INDEX(0xB0);
LCD_ILI9486_INDEX(0x11);
LCD_ILI9486_CMD(0XB4);
LCD_ILI9486_INDEX(0x02);
LCD_ILI9486_CMD(0XB6);
LCD_ILI9486_INDEX(0x32); //0x22 internal syytem clock
LCD_ILI9486_INDEX(0x62);
LCD_ILI9486_INDEX(0x3B);
LCD_ILI9486_CMD(0XC0);
LCD_ILI9486_INDEX(0x09);
LCD_ILI9486_INDEX(0x09);
LCD_ILI9486_CMD(0XC1);
LCD_ILI9486_INDEX(0x41);
LCD_ILI9486_CMD(0XC2);
LCD_ILI9486_INDEX(0x22);
LCD_ILI9486_CMD(0XC5);
LCD_ILI9486_INDEX(0x00);
LCD_ILI9486_INDEX(0x36);
LCD_ILI9486_CMD(0x36);
LCD_ILI9486_INDEX(0x88);
LCD_ILI9486_CMD(0x3A);
LCD_ILI9486_INDEX(0x66); // 8bit,16bit=0x55 18bit=0x66
LCD_ILI9486_CMD(0xE0);
LCD_ILI9486_INDEX(0x00);
LCD_ILI9486_INDEX(0x2C);
LCD_ILI9486_INDEX(0x2C);
LCD_ILI9486_INDEX(0x0B);
LCD_ILI9486_INDEX(0x0C);
LCD_ILI9486_INDEX(0x04);
LCD_ILI9486_INDEX(0x4C);
LCD_ILI9486_INDEX(0x64);
LCD_ILI9486_INDEX(0x36);
LCD_ILI9486_INDEX(0x03);
LCD_ILI9486_INDEX(0x0E);
LCD_ILI9486_INDEX(0x01);
LCD_ILI9486_INDEX(0x10);
LCD_ILI9486_INDEX(0x01);
LCD_ILI9486_INDEX(0x00);
LCD_ILI9486_CMD(0XE1);
LCD_ILI9486_INDEX(0x0f);
LCD_ILI9486_INDEX(0x37);
LCD_ILI9486_INDEX(0x37);
LCD_ILI9486_INDEX(0x0C);
LCD_ILI9486_INDEX(0x0F);
LCD_ILI9486_INDEX(0x05);
LCD_ILI9486_INDEX(0x50);
LCD_ILI9486_INDEX(0x32);
LCD_ILI9486_INDEX(0x36);
LCD_ILI9486_INDEX(0x04);
LCD_ILI9486_INDEX(0x0B);
LCD_ILI9486_INDEX(0x00);
LCD_ILI9486_INDEX(0x19);
LCD_ILI9486_INDEX(0x14);
LCD_ILI9486_INDEX(0x0F);
LCD_ILI9486_CMD(0x21);
LCD_ILI9486_CMD(0x11);
DelayLoop_1ms(200);
LCD_ILI9486_CMD(0x29);
}
static void DelayLoop_1ms(int msec)
{
volatile int j;
for(j = 0; j < LCD_DELAY_1MS*msec; j++) ;
}
static void DelayLoop(int delay)
{
volatile int j;
for(j = 0; j < delay; j++) ;
}
重新编译生成nk但是屏幕显示模糊,经过各参数修改发现将
#define LCD_VCLK_POLARITY IVCLK_FALL_EDGE
改成
#define LCD_VCLK_POLARITY IVCLK_RISE_EDGE
问题解决