📄 tft_s0144.c
字号:
/******************************************************************************
** File Name: cstn_pcf8833.c *
** Description: *
** This file contains driver for color LCD.(CSTN) *
** Author: Jim zhang *
** DATE: 03/01/2004 *
** Copyright: 2004 Spreatrum, Incoporated. All Rights Reserved. *
** Description: *
******************************************************************************
******************************************************************************
** Edit History *
** ------------------------------------------------------------------------- *
** DATE NAME DESCRIPTION *
** 02/04/2004 louis.wei Create.
** 11/15/2005 David.Jia Modify for GG3728 (S0144/HYDIS). *
** 11/22/2005 David.Jia Modify ADC value in Probe; Entersleep code*
** 12/09/2005 David.Jia Implemetation SetDisplayWindow function. *
** 12/26/2005 David.Jia Deal can't DC preview on S0144 LCD. *
** 03/03/2006 David.Jia cr42033, LCD ADC range changed: HX8309, *
** 200-230; S0144, 231-249; S1D19105, 250-280. *
******************************************************************************/
#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 S0144_WIDTH 128//176
#define S0144_HEIGHT 160//220
#define MP4_MAX_WIDTH 176
#define MP4_MAX_HEIGHT 144
#define OFFSET_X 0
//@David.Jia 2005.11.22
#define ADC_S0144_LOW 231
#define ADC_S0144_HIGH 249 //@David.Jia 2006.3.3 cr42033
#define LCD_USE_DMA
//Qlw 2006/11/21
extern int LCD_GetRefreshFlag (void);
extern uint32 udisk_plugin;
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 S0144_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 S0144_Close(void);
/******************************************************************************/
// Description: Enter/Exit sleep mode .
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E S0144_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 S0144_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 S0144_GetMainLcdSpec(
LCD_SPEC_T *spec_ptr //spec struct pointer
);
/*********************************************************************/
// Description: Initialize color LCD : S0144
// Input:
// None.
// Return:
// None.
// Note:
/*********************************************************************/
LOCAL ERR_LCD_E S0144_Init(void);
/******************************************************************************/
// Description: invalidate a rectang of in LCD
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E S0144_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 S0144_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 S0144_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 S0144_GoSleep(void);
/******************************************************************************/
// Description: LCD exit sleep mode
// Author: Yingchun.li
// Note:
/******************************************************************************/
LOCAL S0144_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 S0144_SEND_COMMAND( c) {*(volatile uint16 *)0x58000000 = c;}
#define S0144_SEND_DATA(d) {*(volatile uint16 *)0x58020000 = d;}
#define S0144_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58020000 = data;}
//Qlw 2006/12/21
//#define DATA_8BIT
//LOCAL void S0144_HW_reset(void)
//{
// GPIO_SetLcdReset(0);
// Delayms(10);
// GPIO_SetLcdReset(1);
// Delayms(10);
//}
LOCAL void S0144_reset(void)
{
SCI_TRACE_LOW("S0144_reset: 7370 GG3728 S0144/HYDIS.");
#ifndef DATA_8BIT //16bit send data
S0144_sendcommand1(0x0000, 0x0001);//Start oscillation
Delayms(200);
S0144_sendcommand1(0x00b4, 0x0000);//MTPSEL OFF(if not use mtp)
S0144_sendcommand1(0x0007, 0x0000);
S0144_sendcommand1(0x0012, 0x00b3);//SVC 11 VC 3 00b3
S0144_sendcommand1(0x0013, 0x080a);//VCOMR ON VRH13 0808//0x080a modify 200706100x0809
S0144_sendcommand1(0x0014, 0x7de5);//7de5
S0144_sendcommand1(0x0010, 0x1a6c);
Delayms(200);
S0144_sendcommand1(0x0013, 0x081e);
Delayms(200);
S0144_sendcommand1(0x0001, 0x0114);
S0144_sendcommand1(0x0002, 0x0100);
S0144_sendcommand1(0x0003, 0x0030); //0x30
S0144_sendcommand1(0x0008, 0x0203); //0503
S0144_sendcommand1(0x000b, 0x0000);
S0144_sendcommand1(0x000c, 0x0001);
S0144_sendcommand1(0x0030, 0x0303);//Gamma control1
S0144_sendcommand1(0x0031, 0x0303);//Gamma control2
S0144_sendcommand1(0x0032, 0x0303);//Gamma control3
S0144_sendcommand1(0x0033, 0x0000);//Gamma control4
S0144_sendcommand1(0x0034, 0x0404);//Gamma control5
S0144_sendcommand1(0x0035, 0x0404);//Gamma control6
S0144_sendcommand1(0x0036, 0x0404);//Gamma control7
S0144_sendcommand1(0x0037, 0x0000);//Gamma control8
S0144_sendcommand1(0x0038, 0x0707);//Gamma control9
S0144_sendcommand1(0x0040, 0x0000);
S0144_sendcommand1(0x0042, 0x9f00);
S0144_sendcommand1(0x0043, 0x7f00); //0000
S0144_sendcommand1(0x0044, 0x7f00);
S0144_sendcommand1(0x0045, 0x9f00);
S0144_sendcommand1(0x0061, 0x001d);//001d
S0144_sendcommand1(0x0069, 0x0000);
S0144_sendcommand1(0x0070, 0x0000);
S0144_sendcommand1(0x0071, 0x0000);
Delayms(200);
//S0144_sendcommand1(0x0007, 0x0005);//Display control
S0144_sendcommand1(0x0007, 0x0021);//Display control
S0144_sendcommand1(0x0007, 0x0023);//Display control
Delayms(200);
S0144_sendcommand1(0x0007, 0x0037);//Display control
S0144_sendcommand1(0x0021, 0x0000); //0000
S0144_SEND_COMMAND(0x0022);
Delayms(30);
#else //8bit send data
S0144_SEND_COMMAND(0x0000);//Start oscillation
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0100);
Delayms(200);
S0144_SEND_COMMAND(0xb400);//MTPSEL OFF(if not use mtp)
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x0700);
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x1200);//SVC 11 VC 3 00b3
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0xb300);
S0144_SEND_COMMAND(0x1300);//VCOMR ON VRH13 0808
S0144_SEND_DATA(0x0800);
S0144_SEND_DATA(0x0900);
S0144_SEND_COMMAND(0x1400);//7de5
S0144_SEND_DATA(0x7d00);
S0144_SEND_DATA(0xe500);
S0144_SEND_COMMAND(0x1000);
S0144_SEND_DATA(0x1a00);
S0144_SEND_DATA(0x6c00);
Delayms(200);
S0144_SEND_COMMAND(0x1300);
S0144_SEND_DATA(0x0800);
S0144_SEND_DATA(0x1e00);
Delayms(200);
S0144_SEND_COMMAND(0x0100);
S0144_SEND_DATA(0x0100);
S0144_SEND_DATA(0x1400);
S0144_SEND_COMMAND(0x0200);
S0144_SEND_DATA(0x0100);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x0300); //0x30
S0144_SEND_DATA(0x0000);//0x0000
S0144_SEND_DATA(0x3000);
S0144_SEND_COMMAND(0x0800); //0503
S0144_SEND_DATA(0x0200);
S0144_SEND_DATA(0x0300);
S0144_SEND_COMMAND(0x0b00);
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x0c00);
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0100);
S0144_SEND_COMMAND(0x3000);//Gamma control1
S0144_SEND_DATA(0x0300);
S0144_SEND_DATA(0x0300);
S0144_SEND_COMMAND(0x3100);//Gamma control2
S0144_SEND_DATA(0x0300);
S0144_SEND_DATA(0x0300);
S0144_SEND_COMMAND(0x3200);//Gamma control3
S0144_SEND_DATA(0x0300);
S0144_SEND_DATA(0x0300);
S0144_SEND_COMMAND(0x3300);//Gamma control4
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x3400);//Gamma control5
S0144_SEND_DATA(0x0400);
S0144_SEND_DATA(0x0400);
S0144_SEND_COMMAND(0x3500);//Gamma control6
S0144_SEND_DATA(0x0400);
S0144_SEND_DATA(0x0400);
S0144_SEND_COMMAND(0x3600);//Gamma control7
S0144_SEND_DATA(0x0400);
S0144_SEND_DATA(0x0400);
S0144_SEND_COMMAND(0x3700);//Gamma control8
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x3800);//Gamma control9
S0144_SEND_DATA(0x0700);
S0144_SEND_DATA(0x0700);
S0144_SEND_COMMAND(0x4000);
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x4200);
S0144_SEND_DATA(0x9f00);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x4300); //0000
S0144_SEND_DATA(0x7f00);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x4400);
S0144_SEND_DATA(0x7f00);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x4500);
S0144_SEND_DATA(0x9f00);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x6100);//001d
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x1d00);
S0144_SEND_COMMAND(0x6900);
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x7000);
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x7100);
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
Delayms(200);
//S0144_SEND_COMMAND(000007, 0x0005);//Display control
S0144_SEND_COMMAND(0x0700);//Display control
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x2100);
S0144_SEND_COMMAND(0x0700);//Display control
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x2300);
Delayms(200);
S0144_SEND_COMMAND(0x0700);//Display control
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x3700);
S0144_SEND_COMMAND(0x2100); //0000
S0144_SEND_DATA(0x0000);
S0144_SEND_DATA(0x0000);
S0144_SEND_COMMAND(0x2200);
Delayms(30);
//GPIO_SetLcdBackLight(1);
//while(1);
#endif
}
/******************************************************************************/
// Description: Clear color LCD with one color
// Global resource dependence:
// Author: louis.wei
// Note:
// modify: jim.cui 2005.0728 use dma to transport data
/******************************************************************************/
LOCAL void S0144_Clear(
uint32 color //color to fill the whole lcd.
)
{
uint32 i;
uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();
uint16 fill_color = color;
#ifndef DATA_8BIT
for(i=0; i<(S0144_HEIGHT ); i++)
{
dma_request(0, (uint32)&fill_color, (uint32)(buf_ptr + i * S0144_WIDTH), S0144_WIDTH,
1, 1);
}
#else
for( i=0; i<(S0144_HEIGHT * S0144_WIDTH); i++)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -