⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tft_s1d19105.c

📁 LCD驱动代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************
 ** 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 GG3727 (S1D19105/LG),          * 
 **     copy from tft_R61500.c.                                               *
 ** 11/18/2005     David.Jia        Remove function Delayms, for already      *
 **     defined in tft_r61500.c.                                              *
 ** 11/22/2005     David.Jia        Change ADC value for 3727, modify         *
 **     EnterSleep code.                                                      *
 ** 11/29/2005     David.Jia        No using DMA for data transfer.           *
 ** 11/30/2005     David.Jia        Reduce wait time in set_display_window.   *
 ** 12/09/2005     David.Jia        Implemetation SetDisplayWindow function.  *
 ** 03/01/2006     David.Jia        CR42033, change ADC identify range from   *
 **     251-265 to 251-280.                                                   *
 ** 03/03/2006     David.Jia        cr42033, LCD ADC range changed: HX8309,   *
 **     200-230; R61500, 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	S1D19105_WIDTH	176
#define	S1D19105_HEIGHT	220

#define MP4_MAX_WIDTH	176
#define MP4_MAX_HEIGHT	144
#define OFFSET_X	0

//@David.Jia 2005.11.22
#define ADC_S1D19105_LOW    250     //@David.Jia 2006.3.3   cr42033
#define ADC_S1D19105_HIGH   280     //@David.Jia 2006.3.1   cr42033

//#define LCD_USE_DMA       //@David.Jia    2005.11.29
//#define LCDS1D19105_USE_DMA       //added by lipengyu for s1d19105 lcm.
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 S1D19105_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 S1D19105_Close(void);

  /******************************************************************************/
//  Description:   Enter/Exit sleep mode .
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E  S1D19105_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   S1D19105_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  S1D19105_GetMainLcdSpec(
	LCD_SPEC_T *spec_ptr 	//spec struct pointer
	);

/*********************************************************************/
//  Description:   Initialize color LCD : S1D19105
//  Input:
//      None.
//  Return:
//      None.
//	Note:           
/*********************************************************************/
LOCAL ERR_LCD_E S1D19105_Init(void);

/******************************************************************************/
//  Description:   invalidate a rectang of in LCD
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E S1D19105_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 S1D19105_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
//	Note:       
/******************************************************************************/
LOCAL ERR_LCD_E S1D19105_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 void S1D19105_GoSleep(void);
/******************************************************************************/
//  Description:   LCD exit sleep mode
//  Author:         Yingchun.li
//	Note: 
/******************************************************************************/
LOCAL void S1D19105_ExitSleep(void);

__inline void S1D19105_set_display_window(
	uint8 left, 	// start Horizon address
	uint8 top, 		// start Vertical address
	uint8 right, 	// end Horizon address	
	uint8 bottom	// end Vertical address
	);
	
__inline void S1D19105_set_start_address(
	uint8 left, 
	uint8 top
	);
	
/**---------------------------------------------------------------------------*
 **                      Function  Definitions
 **---------------------------------------------------------------------------*/
extern uint32 dma_request(uint32 chid, uint32 saddr, uint32 daddr, uint32 size, uint32 transfer_mode, uint32 size_mode);

#define S1D19105_SEND_COMMAND( c)   		{*(volatile uint16 *)0x58000000 = c;}
	
#define  S1D19105_SEND_DATA(d) 	{*(volatile uint16 *)0x58008000 = d;}
 
#define S1D19105_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58008000 = data;}

#define S1D19105_SEND_COMMAND_8( c)   		{*(volatile uint16 *)0x58000000 = ((c & 0xff) << 8);}

#define S1D19105_SEND_PARAMETER_8( p)   		{*(volatile uint16 *)0x58008000 = ((p & 0xff) << 8);}

#if 0
#define Delayms( ms)\
{\
	int i;\
	for (i=0; i< 100 * ms; i++) ;\
}
#else
//@David.Jia    2005.11.18  begin
//void Delayms (uint32 ms)	
//{
//	uint32 t1, t2;
//	
//	t1 = t2 = SCI_GetTickCount ();
//	
//	do{
//		t2 = SCI_GetTickCount ();
//	}while ((t2-t1) < ms);
//}
//@David.Jia    2005.11.18  end	
#endif
//LOCAL void S1D19105_HW_reset(void)
//{
//	GPIO_SetLcdReset(0);
//	Delayms(10);
//	GPIO_SetLcdReset(1);
//	Delayms(10);
//}

 /******************************************************************************/
//  Description:  delay us time.
//	Global resource dependence: 
//  Author:         pengyuli.
//	Note:  
/******************************************************************************/
void Delayus(uint16 us)
{
	uint16 i=0;
	for(i=0; i < us; i++);
}

LOCAL void S1D19105_reset(void)
{
    SCI_TRACE_LOW("S1D19105_reset: 7370 GG3727 S1D19105/LG.");
    
     S1D19105_SEND_COMMAND_8(0x99); 
     Delayms(40);	// Delayms(100);
     S1D19105_SEND_COMMAND_8(0x96);
     Delayms(40);  //Delayms(100);
     S1D19105_SEND_COMMAND_8(0xCA);  //sets display
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x49);
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x44);
     S1D19105_SEND_PARAMETER_8(0xDB);
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x02);
     S1D19105_SEND_PARAMETER_8(0x01);
     S1D19105_SEND_PARAMETER_8(0x00);
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0xA1);   //set display timing
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x46);
     S1D19105_SEND_PARAMETER_8(0x04);
     S1D19105_SEND_PARAMETER_8(0x44);
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x13);
     S1D19105_SEND_PARAMETER_8(0x09);
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0xBC);   //set data, RGB, BGR set
     S1D19105_SEND_PARAMETER_8(0x00);  //65K color
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0xAB);     //set display start line
     S1D19105_SEND_PARAMETER_8(0x00);
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0x31);    //display data interface
     S1D19105_SEND_PARAMETER_8(0x10);
     S1D19105_SEND_PARAMETER_8(0x00);
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0x8B);   //set display color mode
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x44);
     S1D19105_SEND_PARAMETER_8(0x77);
     S1D19105_SEND_PARAMETER_8(0x74);
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0x6F); //Gate Line Scan Mode
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0xDB);
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0x8C);   // set AC operation  Driver
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x00);
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0x20);    //set electronic control
     S1D19105_SEND_PARAMETER_8(12);  //VDDHS
     S1D19105_SEND_PARAMETER_8(13);  //VCOMH
     S1D19105_SEND_PARAMETER_8(12);  //VCA, VCOMW
     S1D19105_SEND_PARAMETER_8(14);  //VONREG
     S1D19105_SEND_PARAMETER_8(18);  //VOFREG
     S1D19105_SEND_PARAMETER_8(12);  //VDDRH
     S1D19105_SEND_PARAMETER_8(8);  //VDDRL 
     S1D19105_SEND_PARAMETER_8(3);  //VLDO
     Delayms(100); //Delayms(200);
     S1D19105_SEND_COMMAND_8(0x22);   //set gamma correction characteristics
     S1D19105_SEND_PARAMETER_8(0x32);
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x44);
     S1D19105_SEND_PARAMETER_8(0x44);
     S1D19105_SEND_PARAMETER_8(0x44);
     S1D19105_SEND_PARAMETER_8(0x44);
     Delayms(100); //Delayms(200);
     S1D19105_SEND_COMMAND_8(0x21);   //set power control
     S1D19105_SEND_PARAMETER_8(0x10);
     S1D19105_SEND_PARAMETER_8(0x11);
     S1D19105_SEND_PARAMETER_8(0x0F);
     S1D19105_SEND_PARAMETER_8(0x1F);
     S1D19105_SEND_PARAMETER_8(0xAD);
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x44);
     S1D19105_SEND_PARAMETER_8(0xFF);
     S1D19105_SEND_PARAMETER_8(0x03);
     S1D19105_SEND_PARAMETER_8(0xFF);
     S1D19105_SEND_PARAMETER_8(0x03);
     S1D19105_SEND_PARAMETER_8(0x11);
     S1D19105_SEND_PARAMETER_8(0x44);
     Delayms(40); //Delayms(100);
     S1D19105_SEND_COMMAND_8(0x23);  //set partial power control
     S1D19105_SEND_PARAMETER_8(0x01);
     S1D19105_SEND_PARAMETER_8(0x44);
     S1D19105_SEND_PARAMETER_8(0x1F);
     S1D19105_SEND_PARAMETER_8(0xAD);
     S1D19105_SEND_PARAMETER_8(0xA0);
     S1D19105_SEND_PARAMETER_8(0x11);
     S1D19105_SEND_PARAMETER_8(0x44);
     Delayms(40); //Delayms(100);
     S1D19105_SEND_COMMAND_8(0x94);
     Delayms(100);  //Delayms(200);
     S1D19105_SEND_COMMAND_8(0x92);
     Delayms(20);
     S1D19105_SEND_COMMAND_8(0x15);   //set start address
     S1D19105_SEND_PARAMETER_8(0x00);
     S1D19105_SEND_PARAMETER_8(0x00);
     Delayms(1);
     S1D19105_SEND_COMMAND_8(0x75);  //set end address
     S1D19105_SEND_PARAMETER_8(0xAF);
     S1D19105_SEND_PARAMETER_8(0xDB);
     Delayms(1);
     S1D19105_SEND_COMMAND_8(0xAF);   //set display on
     //Delayms(50);      
}

  /******************************************************************************/
//  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 S1D19105_Clear(
						uint32 color	//color to fill the whole lcd.
						)
{
	uint32 i;
	uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();

	uint16  fill_color = color;	
	for(i=0; i<(S1D19105_HEIGHT ); i++)
	{

        dma_request(0, (uint32)&fill_color, (uint32)(buf_ptr + i * S1D19105_WIDTH), S1D19105_WIDTH, 
                                     1, 1);	
	}
	S1D19105_Invalidate();
}


/******************************************************************************/
//  Description:   invalidate a rectang of in LCD
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
//  modify:  jim.cui  2005.0728  use  dma to transport data  
/******************************************************************************/
LOCAL ERR_LCD_E S1D19105_Invalidate(void)
{
	uint16 i,j;
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -