📄 tft_s6d0151.c
字号:
/********************************************************************************
**********************************************************************************
** Copyright: 上海闻泰电子第一产品部
** All Rights Reserved.
** Project Name: T658
** File Name: tft_S6D0151.c
** Description: This file contains driver for color LCD.
LCD type : TFT
Driver IC: S6D0151
Dot pixcel:128*160
Menufacture: Truly
** Current Ver: 1.0
** Author: Huangfusheng
** DATE: 10/08/2007
** Displace Ver: ***
** Author : ***
** Data : ***
********************************************************************************
********************************************************************************/
#include "os_api.h"
#include "sci_types.h"
//#include "lcd_api.h"
#include "gpio_api.h"
#include "lcd.h"
// #include "mv3lib.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**---------------------------------------------------------------------------*
** Macro Define
**---------------------------------------------------------------------------*/
#define S6D0151_WIDTH 128//176
#define S6D0151_HEIGHT 160//220
#define MP4_MAX_WIDTH 176
#define MP4_MAX_HEIGHT 144
#define OFFSET_X 0
//@David.Jia 2005.11.22
#define ADC_S6D0151_LOW 231
#define ADC_S6D0151_HIGH 249 //@David.Jia 2006.3.3 cr42033
#define LCD_USE_DMA
#define WR_GRAM_COMMAND 0x0022
extern void dma_init(void);
extern void *LCD_GetLCDBuffer(void);
/******************************************************************************/
// Description: Clear color LCD with one color
// Global resource dependence:
// Author: louis.wei
// Note:
/******************************************************************************/
LOCAL void S6D0151_Clear(
uint32 color //color to fill the whole lcd.
);
/******************************************************************************/
// Description: Close the lcd.(include sub lcd.)
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL void S6D0151_Close(void);
/******************************************************************************/
// Description: Enter/Exit sleep mode .
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E S6D0151_EnterSleep(
BOOLEAN is_sleep //SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode.
);
/*****************************************************************************/
// Description: Get the lcd base information..
// Global resource dependence:
// Author: louis.wei
// Note:
/*****************************************************************************/
LOCAL ERR_LCD_E S6D0151_GetInfo(
LCD_INFO_T *lcd_info_ptr //lcd information struct pointer
);
/******************************************************************************/
// Description: get the important parameter for digital camera
// Global resource dependence:
// Author: Zhemin.lin
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E S6D0151_GetMainLcdSpec(
LCD_SPEC_T *spec_ptr //spec struct pointer
);
/*********************************************************************/
// Description: Initialize color LCD : S6D0151
// Input:
// None.
// Return:
// None.
// Note:
/*********************************************************************/
LOCAL ERR_LCD_E S6D0151_Init(void);
/******************************************************************************/
// Description: invalidate a rectang of in LCD
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E S6D0151_Invalidate(void);
/******************************************************************************/
// Description: Copy a retangle data from clcd_buffer to display RAM.
// then the rectangle display is to be refreshed
// Global resource dependence:
// Author: Jim.zhang
// Note:
// To improve speed, lcd is operate in HIGH SPEED RAM WRITE MODE(4
// uint16 are write continuously always.) So, some dummy uint16
// should be inserted to satisfy this mode. Please refer to spec.
/******************************************************************************/
LOCAL ERR_LCD_E S6D0151_InvalidateRect(
uint16 left, //the left value of the rectangel
uint16 top, //top of the rectangle
uint16 right, //right of the rectangle
uint16 bottom //bottom of the rectangle
);
/******************************************************************************/
// Description: for mp4 display
// Global resource dependence:
// Author: juan.zhang
/******************************************************************************/
LOCAL ERR_LCD_E S6D0151_InvalidateRectImage(
uint16 left, //the left value of the rectangel
uint16 top, //top of the rectangle
uint16 right, //right of the rectangle
uint16 bottom, //bottom of the rectangle
uint16 *buf_ptr,
uint8 is_invert//ignore
);
/******************************************************************************/
// Description: LCD go to sleep mode
// Author: Yingchun.li
// Note:
/******************************************************************************/
LOCAL S6D0151_GoSleep(void);
/******************************************************************************/
// Description: LCD exit sleep mode
// Author: Yingchun.li
// Note:
/******************************************************************************/
LOCAL S6D0151_ExitSleep(void);
LOCAL void main_lcd_fill_rect(uint16 left, uint16 top,uint16 right, uint16 bottom,uint16 color);
/**---------------------------------------------------------------------------*
** Function Definitions
**---------------------------------------------------------------------------*/
extern uint32 dma_request(uint32 chid, uint32 saddr, uint32 daddr, uint32 size, uint32 transfer_mode, uint32 size_mode);
#define S6D0151_SEND_COMMAND( c) {*(volatile uint16 *)0x58000000 = c;}
#define S6D0151_SEND_DATA(d) {*(volatile uint16 *)0x58020000 = d;}
#define S6D0151_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58020000 = data;}
LOCAL void S6D0151_reset(void)
{
uint16 lcm_nv = REFPARAM_GetLCDType();
SCI_TRACE_LOW("S6D0151_reset: 7370 GG3728 S6D0151/HYDIS.");
switch(lcm_nv)
{
// case TFT_S6D0151_Truly:
//for S6D0151
S6D0151_SEND_COMMAND(0x0007);
S6D0151_SEND_DATA(0x0020);
S6D0151_SEND_COMMAND(0x00b6);
S6D0151_SEND_DATA(0x013f);
S6D0151_SEND_COMMAND(0x00B4);
S6D0151_SEND_DATA(0x0010);
S6D0151_SEND_COMMAND(0x0012);
S6D0151_SEND_DATA(0x00b2);
S6D0151_SEND_COMMAND(0x0013);
S6D0151_SEND_DATA(0x080e);
S6D0151_SEND_COMMAND(0x0014);
S6D0151_SEND_DATA(0x5BCA);
S6D0151_SEND_COMMAND(0x0061);
S6D0151_SEND_DATA(0x0018);
S6D0151_SEND_COMMAND(0x0010);
S6D0151_SEND_DATA(0x190C);
Delayms(80);
S6D0151_SEND_COMMAND(0x0013);
S6D0151_SEND_DATA(0x081e);
Delayms(20);
S6D0151_SEND_COMMAND(0x0001);
S6D0151_SEND_DATA(0x0114);
S6D0151_SEND_COMMAND(0x0002);
S6D0151_SEND_DATA(0x0100);
S6D0151_SEND_COMMAND(0x0003);
S6D0151_SEND_DATA(0x0030);
S6D0151_SEND_COMMAND(0x0008);
S6D0151_SEND_DATA(0x0202);
S6D0151_SEND_COMMAND(0x000b);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x000C);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0061);
S6D0151_SEND_DATA(0x0018);
S6D0151_SEND_COMMAND(0x0069);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0070);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0071);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0011);
S6D0151_SEND_DATA(0x0000);
///////r CONTROL
S6D0151_SEND_COMMAND(0x0030);
S6D0151_SEND_DATA(0x0303);
S6D0151_SEND_COMMAND(0x0031);
S6D0151_SEND_DATA(0x0303);
S6D0151_SEND_COMMAND(0x0032);
S6D0151_SEND_DATA(0x0303);
S6D0151_SEND_COMMAND(0x0033);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0034);
S6D0151_SEND_DATA(0x0404);
S6D0151_SEND_COMMAND(0x0035);
S6D0151_SEND_DATA(0x0404);
S6D0151_SEND_COMMAND(0x0036);
S6D0151_SEND_DATA(0x0404);
S6D0151_SEND_COMMAND(0x0037);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0038);
S6D0151_SEND_DATA(0x0707);
///////Coordinatioontrol setting
S6D0151_SEND_COMMAND(0x0040);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0042);
S6D0151_SEND_DATA(0x9F00);
S6D0151_SEND_COMMAND(0x0043);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0044);
S6D0151_SEND_DATA(0x7F00);
S6D0151_SEND_COMMAND(0x0045);
S6D0151_SEND_DATA(0x9F00);
S6D0151_SEND_COMMAND(0x0069);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0070);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0071);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0073);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x00B3);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x00BD);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x00BE);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0021);
S6D0151_SEND_DATA(0x0000);
S6D0151_SEND_COMMAND(0x0022);
Delayms(20);
S6D0151_SEND_COMMAND(0x0007);
S6D0151_SEND_DATA(0x0020);
Delayms(5);
S6D0151_SEND_COMMAND(0x0007);
S6D0151_SEND_DATA(0x0021);
S6D0151_SEND_COMMAND(0x0007);
S6D0151_SEND_DATA(0x0027);
Delayms(50);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -