6572 MCU接口 8位 ssd1297灰色 点不亮,求大家看看
时间:10-02
整理:3721RD
点击:
下面是初始化代码
#ifndef BUILD_LK
#include <linux/string.h>
#endif
#ifdef BUILD_LK
#include <platform/mt_GPIO.h>
#include <platform/mt_pMIC.h>
#elif (defined BUILD_UBOOT)
#include <asm/arch/MT6577_gpio.h>
#else
#include <mach/mt_gpio.h>
#include <mach/mt_pm_ldo.h>
#endif
#include "LCM_drv.h"
#define FRAME_WIDTH (240)
#define FRAME_HEIGHT (320)
static LCM_UTIL_FUNCS lcm_util = {0};
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
#if 1
static __inline unsigned int LOW_BYTE(unsigned int x)
{
return (x & 0xFF);
}
static __inline unsigned int HIGH_BYTE(unsigned int x)
{
return ((x >> 8) & 0xFF);
}
#endif
static __inline void send_ctrl_cmd(unsigned int cmd)
{
lcm_util.send_cmd(cmd);
}
static __inline void send_data_cmd(unsigned int data)
{
lcm_util.send_data(data);
}
static __inline unsigned int read_data_cmd(void)
{
return lcm_util.read_data();
}
static __inline void TFT_WriteReg(unsigned int regIndex,
unsigned int regData)
{
send_ctrl_cmd(regIndex);
send_data_cmd(regData);
}
static void init_lcm_registers(void)
{
TFT_WriteReg(0xE5, 0x8000);
TFT_WriteReg(0x28, 0x0006); // enable test command
TFT_WriteReg(0x07, 0x0021);
TFT_WriteReg(0x00, 0x0001); // Start internal OSC
MDELAY(3);
TFT_WriteReg(0x07, 0x0023);
TFT_WriteReg(0x10, 0x0000); // Sleep mode off
MDELAY(3);
TFT_WriteReg(0x07, 0x0033); // Display on
TFT_WriteReg(0x01, 0x2b3f); // Driver output control
TFT_WriteReg(0x02, 0x0600); // Set to line inversion
TFT_WriteReg(0x11, 0x6030); // Entry mode setup
TFT_WriteReg(0x03, 0xa6a8); // Step-up factor/cycle setting
TFT_WriteReg(0x0f, 0x0000); // Gate scan position start at G0
TFT_WriteReg(0x0e, 0x3100); // Set aLTErnating amplitude of VCOM
TFT_WriteReg(0x1e, 0x009f); // Set VcomH voltage
TFT_WriteReg(0x0C, 0x0005); // Adjust VCIX2 output voltage
TFT_WriteReg(0x0D, 0x0005); // Set amplitude magnification of VLCD63
TFT_WriteReg(0x0b, 0x5308); // Frame cycle control
// ----------- Special command ----------
TFT_WriteReg(0x25, 0xe000); // Frame freq control
TFT_WriteReg(0x3f, 0xbb84); // System setting
TFT_WriteReg(0x27, 0x0567); // Internal Vcomh/Vcoml timing
TFT_WriteReg(0X20, 0x316c); // Internal VCOM strength
// ----------- Adjust the Gamma Curve ----------
TFT_WriteReg(0x3a, 0x1000);
TFT_WriteReg(0x3b, 0x0008);
TFT_WriteReg(0X30, 0x0007);
TFT_WriteReg(0x31, 0x0003);
TFT_WriteReg(0x32, 0x0300);
TFT_WriteReg(0x33, 0x0101);
TFT_WriteReg(0x34, 0x0707);
TFT_WriteReg(0x35, 0x0002);
TFT_WriteReg(0x36, 0x0503);
TFT_WriteReg(0x37, 0x0202);
TFT_WriteReg(0x3a, 0x1000);
TFT_WriteReg(0x3b, 0x0008);
//------------------ Set GRAM area ---------------
TFT_WriteReg(0x44, 0xef00); // Horizontal RAM Address
TFT_WriteReg(0x45, 0x0000); // Vertical RAM Start Address
TFT_WriteReg(0x46, 0x013f); // Vertical GRAM end Address
TFT_WriteReg(0x4e, 0x0000);
TFT_WriteReg(0x4f, 0x0000);
TFT_WriteReg(0x48, 0x0000);
TFT_WriteReg(0x49, 0x013f);
TFT_WriteReg(0x4a, 0xef00);
TFT_WriteReg(0x4b, 0x013f);
TFT_WriteReg(0x44, 0xef00); // Horizontal RAM Address
TFT_WriteReg(0x45, 0x0000); // Vertical RAM Start Address
TFT_WriteReg(0x46, 0x013f); // Vertical GRAM end Address
TFT_WriteReg(0x4e, 0x0000); //X GDDRAM
TFT_WriteReg(0x4f, 0x0000); //Y GDDRAM
send_ctrl_cmd(0x0022); //Write RAM data
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
meMCPy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
mEMSet(params, 0, sizeof(LCM_PARAMS));
params->type = LCM_TYPE_DBI;
params->ctrl = LCM_CTRL_PARALLEL_DBI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->io_select_mode= 1;
params->dbi.port = 0;
// params->dbi.clock_freq = LCM_DBI_CLOCK_FREQ_7M;
params->dbi.data_width = LCM_DBI_DATA_WIDTH_8BITS;
params->dbi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dbi.data_format.trans_seq = LCM_DBI_TRANS_SEQ_LSB_FIRST;
params->dbi.data_format.padding = LCM_DBI_PADDING_ON_MSB;
params->dbi.data_format.format = LCM_DBI_FORMAT_RGB565;
params->dbi.data_format.width = LCM_DBI_DATA_WIDTH_16BITS;
params->dbi.cpu_write_bits = LCM_DBI_CPU_WRITE_32_BITS;
// params->dbi.io_driving_current = LCM_DRIVING_CURRENT_4MA;
#if 0
params->dbi.parallel.write_setup = 1;
params->dbi.parallel.write_hold = 1;
params->dbi.parallel.write_wait = 13;
params->dbi.parallel.read_setup = 7;
params->dbi.parallel.read_hold = 1;
params->dbi.parallel.read_latency = 130;
params->dbi.parallel.wait_period = 1;
#endif
params->dbi.parallel.write_setup = 2;
params->dbi.parallel.write_hold = 2;
params->dbi.parallel.write_wait = 6;
params->dbi.parallel.read_setup = 8;
params->dbi.parallel.read_hold = 0;
params->dbi.parallel.read_latency = 36;
params->dbi.parallel.wait_period = 1;
params->dbi.te_mode = 0;
}
static unsigned int lcm_id(void)
{
send_ctrl_cmd(0x00);
#ifdef BUILD_LK
printf("[ssd1297_mcu] id0=0x%02X\n",read_data_cmd());
printf("[ssd1297_mcu] id1=0x%02X\n",read_data_cmd());
printf("[ssd1297_mcu] id2=0x%02X\n",read_data_cmd());
printf("[ssd1297_mcu] id3=0x%02X\n",read_data_cmd());
#else
printk("[ssd1297_mcu] id0=0x%02X\n",read_data_cmd());
printk("[ssd1297_mcu] id1=0x%02X\n",read_data_cmd());
printk("[ssd1297_mcu] id2=0x%02X\n",read_data_cmd());
printk("[ssd1297_mcu] id3=0x%02X\n",read_data_cmd());
#endif
return 1;
}
static void lcm_init(void)
{
lcm_util.set_gpio_mode(GPIO59, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO59, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(10);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ZERO);
MDELAY(50);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(100);
lcm_id();
#ifdef BUILD_LK
printf("[ssd1297_mcu] lcm_init\n");
#else
printk("[ssd1297_mcu] lcm_init\n");
#endif
init_lcm_registers();
}
static void lcm_suspend(void)
{
}
static void lcm_resume(void)
{
lcm_init();
}
static void lcm_update(unsigned int x, unsigned int y,
unsigned int width, unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
#ifdef BUILD_LK
printf("[ssd1297_mcu] lcm_update\n");
#else
printk("[ssd1297_mcu] lcm_update\n");
#endif
}
static unsigned int lcm_compare_id(void)
{
return 1;
}
LCM_DRIVER ssd1297_mcu_drv =
{
.name = "ssd1297_mcu",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.update = lcm_update,
.compare_id = lcm_compare_id
};
求帮忙看看
#ifndef BUILD_LK
#include <linux/string.h>
#endif
#ifdef BUILD_LK
#include <platform/mt_GPIO.h>
#include <platform/mt_pMIC.h>
#elif (defined BUILD_UBOOT)
#include <asm/arch/MT6577_gpio.h>
#else
#include <mach/mt_gpio.h>
#include <mach/mt_pm_ldo.h>
#endif
#include "LCM_drv.h"
#define FRAME_WIDTH (240)
#define FRAME_HEIGHT (320)
static LCM_UTIL_FUNCS lcm_util = {0};
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
#if 1
static __inline unsigned int LOW_BYTE(unsigned int x)
{
return (x & 0xFF);
}
static __inline unsigned int HIGH_BYTE(unsigned int x)
{
return ((x >> 8) & 0xFF);
}
#endif
static __inline void send_ctrl_cmd(unsigned int cmd)
{
lcm_util.send_cmd(cmd);
}
static __inline void send_data_cmd(unsigned int data)
{
lcm_util.send_data(data);
}
static __inline unsigned int read_data_cmd(void)
{
return lcm_util.read_data();
}
static __inline void TFT_WriteReg(unsigned int regIndex,
unsigned int regData)
{
send_ctrl_cmd(regIndex);
send_data_cmd(regData);
}
static void init_lcm_registers(void)
{
TFT_WriteReg(0xE5, 0x8000);
TFT_WriteReg(0x28, 0x0006); // enable test command
TFT_WriteReg(0x07, 0x0021);
TFT_WriteReg(0x00, 0x0001); // Start internal OSC
MDELAY(3);
TFT_WriteReg(0x07, 0x0023);
TFT_WriteReg(0x10, 0x0000); // Sleep mode off
MDELAY(3);
TFT_WriteReg(0x07, 0x0033); // Display on
TFT_WriteReg(0x01, 0x2b3f); // Driver output control
TFT_WriteReg(0x02, 0x0600); // Set to line inversion
TFT_WriteReg(0x11, 0x6030); // Entry mode setup
TFT_WriteReg(0x03, 0xa6a8); // Step-up factor/cycle setting
TFT_WriteReg(0x0f, 0x0000); // Gate scan position start at G0
TFT_WriteReg(0x0e, 0x3100); // Set aLTErnating amplitude of VCOM
TFT_WriteReg(0x1e, 0x009f); // Set VcomH voltage
TFT_WriteReg(0x0C, 0x0005); // Adjust VCIX2 output voltage
TFT_WriteReg(0x0D, 0x0005); // Set amplitude magnification of VLCD63
TFT_WriteReg(0x0b, 0x5308); // Frame cycle control
// ----------- Special command ----------
TFT_WriteReg(0x25, 0xe000); // Frame freq control
TFT_WriteReg(0x3f, 0xbb84); // System setting
TFT_WriteReg(0x27, 0x0567); // Internal Vcomh/Vcoml timing
TFT_WriteReg(0X20, 0x316c); // Internal VCOM strength
// ----------- Adjust the Gamma Curve ----------
TFT_WriteReg(0x3a, 0x1000);
TFT_WriteReg(0x3b, 0x0008);
TFT_WriteReg(0X30, 0x0007);
TFT_WriteReg(0x31, 0x0003);
TFT_WriteReg(0x32, 0x0300);
TFT_WriteReg(0x33, 0x0101);
TFT_WriteReg(0x34, 0x0707);
TFT_WriteReg(0x35, 0x0002);
TFT_WriteReg(0x36, 0x0503);
TFT_WriteReg(0x37, 0x0202);
TFT_WriteReg(0x3a, 0x1000);
TFT_WriteReg(0x3b, 0x0008);
//------------------ Set GRAM area ---------------
TFT_WriteReg(0x44, 0xef00); // Horizontal RAM Address
TFT_WriteReg(0x45, 0x0000); // Vertical RAM Start Address
TFT_WriteReg(0x46, 0x013f); // Vertical GRAM end Address
TFT_WriteReg(0x4e, 0x0000);
TFT_WriteReg(0x4f, 0x0000);
TFT_WriteReg(0x48, 0x0000);
TFT_WriteReg(0x49, 0x013f);
TFT_WriteReg(0x4a, 0xef00);
TFT_WriteReg(0x4b, 0x013f);
TFT_WriteReg(0x44, 0xef00); // Horizontal RAM Address
TFT_WriteReg(0x45, 0x0000); // Vertical RAM Start Address
TFT_WriteReg(0x46, 0x013f); // Vertical GRAM end Address
TFT_WriteReg(0x4e, 0x0000); //X GDDRAM
TFT_WriteReg(0x4f, 0x0000); //Y GDDRAM
send_ctrl_cmd(0x0022); //Write RAM data
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
meMCPy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static void lcm_get_params(LCM_PARAMS *params)
{
mEMSet(params, 0, sizeof(LCM_PARAMS));
params->type = LCM_TYPE_DBI;
params->ctrl = LCM_CTRL_PARALLEL_DBI;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->io_select_mode= 1;
params->dbi.port = 0;
// params->dbi.clock_freq = LCM_DBI_CLOCK_FREQ_7M;
params->dbi.data_width = LCM_DBI_DATA_WIDTH_8BITS;
params->dbi.data_format.color_order = LCM_COLOR_ORDER_RGB;
params->dbi.data_format.trans_seq = LCM_DBI_TRANS_SEQ_LSB_FIRST;
params->dbi.data_format.padding = LCM_DBI_PADDING_ON_MSB;
params->dbi.data_format.format = LCM_DBI_FORMAT_RGB565;
params->dbi.data_format.width = LCM_DBI_DATA_WIDTH_16BITS;
params->dbi.cpu_write_bits = LCM_DBI_CPU_WRITE_32_BITS;
// params->dbi.io_driving_current = LCM_DRIVING_CURRENT_4MA;
#if 0
params->dbi.parallel.write_setup = 1;
params->dbi.parallel.write_hold = 1;
params->dbi.parallel.write_wait = 13;
params->dbi.parallel.read_setup = 7;
params->dbi.parallel.read_hold = 1;
params->dbi.parallel.read_latency = 130;
params->dbi.parallel.wait_period = 1;
#endif
params->dbi.parallel.write_setup = 2;
params->dbi.parallel.write_hold = 2;
params->dbi.parallel.write_wait = 6;
params->dbi.parallel.read_setup = 8;
params->dbi.parallel.read_hold = 0;
params->dbi.parallel.read_latency = 36;
params->dbi.parallel.wait_period = 1;
params->dbi.te_mode = 0;
}
static unsigned int lcm_id(void)
{
send_ctrl_cmd(0x00);
#ifdef BUILD_LK
printf("[ssd1297_mcu] id0=0x%02X\n",read_data_cmd());
printf("[ssd1297_mcu] id1=0x%02X\n",read_data_cmd());
printf("[ssd1297_mcu] id2=0x%02X\n",read_data_cmd());
printf("[ssd1297_mcu] id3=0x%02X\n",read_data_cmd());
#else
printk("[ssd1297_mcu] id0=0x%02X\n",read_data_cmd());
printk("[ssd1297_mcu] id1=0x%02X\n",read_data_cmd());
printk("[ssd1297_mcu] id2=0x%02X\n",read_data_cmd());
printk("[ssd1297_mcu] id3=0x%02X\n",read_data_cmd());
#endif
return 1;
}
static void lcm_init(void)
{
lcm_util.set_gpio_mode(GPIO59, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO59, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(10);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ZERO);
MDELAY(50);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(100);
lcm_id();
#ifdef BUILD_LK
printf("[ssd1297_mcu] lcm_init\n");
#else
printk("[ssd1297_mcu] lcm_init\n");
#endif
init_lcm_registers();
}
static void lcm_suspend(void)
{
}
static void lcm_resume(void)
{
lcm_init();
}
static void lcm_update(unsigned int x, unsigned int y,
unsigned int width, unsigned int height)
{
unsigned int x0 = x;
unsigned int y0 = y;
unsigned int x1 = x0 + width - 1;
unsigned int y1 = y0 + height - 1;
#ifdef BUILD_LK
printf("[ssd1297_mcu] lcm_update\n");
#else
printk("[ssd1297_mcu] lcm_update\n");
#endif
}
static unsigned int lcm_compare_id(void)
{
return 1;
}
LCM_DRIVER ssd1297_mcu_drv =
{
.name = "ssd1297_mcu",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
.update = lcm_update,
.compare_id = lcm_compare_id
};
求帮忙看看
有没有人帮忙看看
谢谢分享,支持!
八位数据线都没有波形
是哪里配置的不对呢
已经点亮了,OK
啥原因呢?
我们第一次没经验也是,走了很多弯路。没波形是因为,dws配置错了。后来是一个参数配置错了 params->dbi.data_format.format = LCM_DBI_FORMAT_RGB66;