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

📄 tft_s6d0164.c

📁 LCD驱动代码
💻 C
📖 第 1 页 / 共 3 页
字号:
 /********************************************************************************
**********************************************************************************
 ** Copyright:     上海闻泰电子第一产品部
 ** All Rights     Reserved.                                      
 
 ** Project Name:  T658	
 ** File Name:     tft_S6D0164.c                                              
 ** Description:   This file contains driver for color LCD.
                   LCD type : TFT
 				   Driver IC: S6D0164
 				   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	S6D0164_WIDTH	128//176
#define	S6D0164_HEIGHT	160//220
#define MP4_MAX_WIDTH	176
#define MP4_MAX_HEIGHT	144

#define OFFSET_X	0

//@David.Jia 2005.11.22
#define ADC_S6D0164_LOW    231
#define ADC_S6D0164_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 S6D0164_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 S6D0164_Close(void);

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

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

/******************************************************************************/
//  Description:   invalidate a rectang of in LCD
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E S6D0164_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 S6D0164_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 S6D0164_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 S6D0164_GoSleep(void);
/******************************************************************************/
//  Description:   LCD exit sleep mode
//  Author:         Yingchun.li
//	Note: 
/******************************************************************************/
LOCAL S6D0164_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 S6D0164_SEND_COMMAND( c)   		{*(volatile uint16 *)0x58000000 = c;}
	
#define  S6D0164_SEND_DATA(d) 	{*(volatile uint16 *)0x58020000 = d;}
 
#define S6D0164_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58020000 = data;}


LOCAL void S6D0164_reset(void)
{

    uint16 lcm_nv = REFPARAM_GetLCDType();
	SCI_TRACE_LOW("S6D0164_reset: 7370 GG3728 S6D0164/HYDIS.");

	switch(lcm_nv)

	  {

//	     case TFT_S6D0164_Weijing:
	     
  Delayms(10);
  S6D0164_sendcommand1(0x0080,0x008D);    
  S6D0164_sendcommand1(0x0092,0x0010);

  //================= Power Supply setting ===================//
  S6D0164_sendcommand1(0x0011,0x0000);
  S6D0164_sendcommand1(0x0012,0x0000);    
  S6D0164_sendcommand1(0x0013,0x0000);    
  S6D0164_sendcommand1(0x0014,0x0000);
  Delayms(20);
  S6D0164_sendcommand1(0x0011,0x0018);
  S6D0164_sendcommand1(0x0012,0x3121);   
  S6D0164_sendcommand1(0x0013,0x006B);   
  S6D0164_sendcommand1(0x0014,0x3361);   //3761 3361
  S6D0164_sendcommand1(0x0010,0x0800);
  Delayms(10);
  S6D0164_sendcommand1(0x0011,0x0118);  
  Delayms(10);
  S6D0164_sendcommand1(0x0011,0x0318); 
  Delayms(10);
  S6D0164_sendcommand1(0x0011,0x0718);
  Delayms(10);
  S6D0164_sendcommand1(0x0011,0x0F18);
  Delayms(20);
  S6D0164_sendcommand1(0x0011,0x0F37);   //0F3C   vci1
  Delayms(30); 
//************* Start Initial Sequence **********//

  S6D0164_sendcommand1(0x0001,0x011C);    // set SS and SM bit
  S6D0164_sendcommand1(0x0002,0x0100);    // set 1 line inversion
  S6D0164_sendcommand1(0x0003,0x1030);    // set GRAM write direction an
  S6D0164_sendcommand1(0x0007,0x0000);    
  S6D0164_sendcommand1(0x0008,0x0808);    // set the back porch and front porch
  S6D0164_sendcommand1(0x000B,0x1100);  
  S6D0164_sendcommand1(0x000C,0x0000);    
  S6D0164_sendcommand1(0x000F,0x0501);    
  S6D0164_sendcommand1(0x0015,0x0000);    
//  S6D0164_sendcommand1(0x0020,0x0000);    
//  S6D0164_sendcommand1(0x0021,0x0000);    
  S6D0164_sendcommand1(0x0030,0x0000);  
  S6D0164_sendcommand1(0x0031,0x00DB);    
  S6D0164_sendcommand1(0x0032,0x0000);    
  S6D0164_sendcommand1(0x0033,0x0000);    
  S6D0164_sendcommand1(0x0034,0x00DB);    
  S6D0164_sendcommand1(0x0035,0x0000); 
  S6D0164_sendcommand1(0x0036,0x00AF);
  S6D0164_sendcommand1(0x0037,0x0000);
  S6D0164_sendcommand1(0x0038,0x00DB);
  S6D0164_sendcommand1(0x0039,0x0000);


//gamma function  NEW

  S6D0164_sendcommand1(0x0050,0x0F09);//
  S6D0164_sendcommand1(0x0051,0x060F);//
  S6D0164_sendcommand1(0x0052,0x0D0C);//
  S6D0164_sendcommand1(0x0053,0x0201);//
  S6D0164_sendcommand1(0x0054,0x040A);//
  S6D0164_sendcommand1(0x0055,0x0C02);//
  S6D0164_sendcommand1(0x0056,0x0404);//
  S6D0164_sendcommand1(0x0057,0x0000);//
  S6D0164_sendcommand1(0x0058,0x0B00);//
  S6D0164_sendcommand1(0x0059,0x0017);//

//********** display on function **************//
  S6D0164_sendcommand1(0x000F,0x0A01);
  S6D0164_sendcommand1(0x0007,0x0012);
  Delayms(50);

  S6D0164_sendcommand1(0x0007,0x0017);

//************* write to GRAM *****************//
  S6D0164_sendcommand1(0x0020,0x0000);
  S6D0164_sendcommand1(0x0021,0x0000);


break;
	     
	  }
	
}

/******************************************************************************/
//  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 S6D0164_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<(S6D0164_HEIGHT ); i++)
	{

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

	S6D0164_Invalidate();
}

/******************************************************************************/
//  Description:   Set the windows address to display, in this windows
//                 color is  refreshed.
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
__inline void S6D0164_set_display_window(
	uint8 left, 	// start Horizon address
	uint8 top, 		// start Vertical address
	uint8 right, 	// end Horizon address
	uint8 bottom	// end Vertical address
	)
{
	

⌨️ 快捷键说明

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