声明:资料为公司同事整理和提供
一:LCD
文件位于custom/drv/LCD
以华立维的一款240X320的屏为例介绍如何添加LCD驱动
gprs.mak
LCD_MODULE = HUALIWEI_SSD1289_LCM
MAIN_LCD_SIZE = 240X320
Option
COM_DEFS_FOR_HUALIWEI_SSD1289_LCM = HUALIWEI_SSD1289_LCM SSD1289 COLOR_LCD TFT_MAINLCD QVGA_MAINLCD
在custom/drv/LCD添加HUALIWEI_SSD1289_LCM文件夹,下面有5个文件。文件名同MTK系统自带的(lcd.c lcd_hw.h lcd_sw.h lcd_sw_inc.h lcd_sw_rnd.h)。
HUALIWEI--------------屏的厂家
SSD1289-----------------屏的驱动芯片
LCM----------------------屏
240X320-----------------屏的分辨率
COLOR_LCD----------彩色
TFT_MAINLCD-------屏的类型,对应的还有CSTN,OLED。目前主要是TFT
QVGA_MAINLCD----屏的分辨率
做了上述修改以后,编译时,lcd驱动就对应HUALIWEI_SSD1289_LCM文件夹里的驱动。文件夹里的5个文件,通常lcd_hw.h, lcd_sw_rnd不需要修改。lcd_sw_inc.h只是定义屏的分辨率。如下:
#ifdef __MMI_MAINLCD_128X128__
#define LCD_WIDTH 128
#define LCD_HEIGHT 128
#elif (defined(__MMI_MAINLCD_128X160__))
#define LCD_WIDTH 128
#define LCD_HEIGHT 160
#elif (defined(__MMI_MAINLCD_176X220__))
#define LCD_WIDTH 176
#define LCD_HEIGHT 220
#elif (defined(__MMI_MAINLCD_240X320__))
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#endif
#define UI_DEVICE_WIDTH LCD_WIDTH
#define UI_DEVICE_HEIGHT LCD_HEIGHT
修改比较多的是lcd.c和lcd_sw.h。
Lcd_sw.h
#define LCD_CMD_DMA_MODE---------是否使用DMA方式?(DMA简单,速度快,通过MTK的寄存器进行操作,但灵活性差。非DMA方式,直接对地址操作,灵活性好,但速度会有影响。目前,一般都是用DMA方式)
#define LCD_16BIT_MODE-----------------lcd使用16位总线?(由硬件决定)
#define LCD_SSD1289_CTRL_ADDR LCD_PARALLEL0_A0_LOW_ADDR
#define LCD_SSD1289_DATA_ADDR LCD_PARALLEL0_A0_HIGH_ADDR
#define MAIN_LCD_CMD_ADDR LCD_SSD1289_CTRL_ADDR
#define MAIN_LCD_DATA_ADDR LCD_SSD1289_DATA_ADDR
#define MAIN_LCD_OUTPUT_FORMAT LCM_16BIT_16_BPP_RGB565_1
#define LCD_delay_SSD1289() /
{/
volatile kal_uint16 iI; /
for (iI = 0; iI < 0x20; iI++);/
}
#ifdef LCD_CMD_DMA_MODE-------------DMA方式
#define LCD_SEND_DMA_CMD(n) /
{/
while (LCD_IS_RUNNING);/
DISABLE_LCD_TRANSFER_COMPLETE_INT;/
DISABLE_ALL_LCD_LAYER_WINDOW;/
SET_LCD_ROI_CTRL_NUMBER_OF_CMD(n);/
ENABLE_LCD_ROI_CTRL_CMD_FIRST;/
SET_LCD_ROI_WINDOW_SIZE(0, 0);/
START_LCD_TRANSFER;/
while (LCD_IS_RUNNING);/
}
#define LCD_CtrlWrite_SSD1289(_data) /
{/
SET_LCD_CMD_PARAMETER(0, LCD_CMD, _data);/ --------写的是命令
LCD_SEND_DMA_CMD(1);/
}
#define LCD_DataWrite_SSD1289(_data) /
{/
SET_LCD_CMD_PARAMETER(0, LCD_DATA, _data);/ --------写的是数据
LCD_SEND_DMA_CMD(1);/
}
#else ----------非DMA方式
#define LCD_CtrlWrite_SSD1289(_data) /
{/
*(volatile kal_uint32 *) LCD_SSD1289_CTRL_ADDR = _data;/ --------写的是命令
LCD_delay_SSD1289();/
}
#define LCD_DataWrite_SSD1289(_data) /
{/
*(volatile kal_uint32 *) LCD_SSD1289_DATA_ADDR = _data;/------------写的是数据
LCD_delay_SSD1289();/
}
#endif
#define LCD_DataRead_SSD1289 (*(volatile kal_uint16 *)LCD_SSD1289_DATA_ADDR);
------用于读LCD id,兼容lcd用。(这个需要硬件上接读lcd的信号)
Lcd.c
LCD_Funcs LCD_func_SSD1289 = {
LCD_Init_SSD1289,
LCD_PWRON_SSD1289,
LCD_SetContrast_SSD1289,
LCD_ON_SSD1289,
LCD_BlockWrite_SSD1289,
LCD_Size_SSD1289,
LCD_EnterSleep_SSD1289,
LCD_ExitSleep_SSD1289,