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

📄 cstn_s6b33bf.c

📁 LCD驱动代码
💻 C
📖 第 1 页 / 共 3 页
字号:
 /********************************************************************************
**********************************************************************************
 ** Copyright:     上海闻泰电子第一产品部
 ** All Rights     Reserved.                                      
 
 ** Project Name:  T658	
 ** File Name:     tft_CIL5.c                                              
 ** Description:   This file contains driver for color LCD.
                   LCD type : LTPS TFT
 				   Driver IC: CIL5-06
 				   Dot pixcel:128*160	
 				   Menufacture: HuaLiWei and TianMa
 				   
 									 			                                
 ** Current Ver:   1.1 				                 
 ** Author:        Huangfusheng                                              
 ** DATE:          08/15/2007 
 ** Modify:        Add the innitial Code for Tianma
 
 ** Displace Ver:  1.0    
 ** Author :       Huangfusheng  
 ** Data   :       07/26/2007   
 ********************************************************************************
 ********************************************************************************/

#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	S6B33BF_WIDTH	128//176
#define	S6B33BF_HEIGHT	160//220
#define MP4_MAX_WIDTH	176
#define MP4_MAX_HEIGHT	144

#define OFFSET_X	0

//@David.Jia 2005.11.22
#define ADC_S6B33BF_LOW    231
#define ADC_S6B33BF_HIGH   249           //@David.Jia 2006.3.3 cr42033

#define LCD_USE_DMA
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 S6B33BF_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 S6B33BF_Close(void);

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

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

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


//LOCAL void S6B33BF_HW_reset(void)
//{
//	GPIO_SetLcdReset(0);
//	Delayms(10);
//	GPIO_SetLcdReset(1);
//	Delayms(10);
//}

LOCAL void S6B33BF_reset(void)
{

 
 SCI_TRACE_LOW("S6B33BF_reset: 7370 GG3728 S6B33BF/HYDIS.");
	  //*********StandBy  Mode Off**********
  S6B33BF_SEND_COMMAND(0x2c);
  Delayms(20);
  //**********OTP MODE ON****************
  S6B33BF_SEND_COMMAND(0xeb);
  //**********Set Internal OCS ON********
  S6B33BF_SEND_COMMAND(0x02);
  S6B33BF_SEND_COMMAND(0x01);
  Delayms(20);
  //***1'ST DC/DC SET TO 2X TIME BOOSTER***
  S6B33BF_SEND_COMMAND(0x20);
  S6B33BF_SEND_COMMAND(0x0a);
  Delayms(20);
  //*****BOOSTER1 ON************************ 
  S6B33BF_SEND_COMMAND(0x26);
  S6B33BF_SEND_COMMAND(0x01);
  Delayms(20); 
  //******** BOOSTER1 ON AND AMP ON ********
  S6B33BF_SEND_COMMAND(0x26);
  S6B33BF_SEND_COMMAND(0x09);
  Delayms(20);  
  //****************************************
  S6B33BF_SEND_COMMAND(0x26);
  S6B33BF_SEND_COMMAND(0x0b);
  Delayms(20); 
  //****************************************
  S6B33BF_SEND_COMMAND(0x26);
  S6B33BF_SEND_COMMAND(0x0f);
  Delayms(20); 
  //***** 0x00TEMP COMPENSATION RATIO 0.00% ***
  S6B33BF_SEND_COMMAND(0x28);
  S6B33BF_SEND_COMMAND(0x01);
  Delayms(5); 
  //*****BURST MODE OFF  8 BIT******************
  //S6B33BF_SEND_COMMAND(0x2e);
  //******RAM SKIP AREA SET NO SKIP*************
   S6B33BF_SEND_COMMAND(0x45);
   S6B33BF_SEND_COMMAND(0x00);
   //*************NORMAL DISPLAY****************
   S6B33BF_SEND_COMMAND(0x53);
   S6B33BF_SEND_COMMAND(0x00);
   //******0x12 drive mode   SET SDIR=0,DUTY=1/162,SWAP=0 ***
   S6B33BF_SEND_COMMAND(0x10);
   S6B33BF_SEND_COMMAND(0x25); 
   //******0X11     SET CLOCK DIV FPCK=FOSE/16 *******
   S6B33BF_SEND_COMMAND(0x24);
   S6B33BF_SEND_COMMAND(0x11); 
   //**********0x0d ADDRESSING MODE SET TO DEFAULT,  GSM,DSG,SGF,SGP,SGM***
   S6B33BF_SEND_COMMAND(0x30);
   S6B33BF_SEND_COMMAND(0x02); 
   //***********ROW VECTOR TYPE=DIAGONAL,INCREMENT TYPE=Y****
   S6B33BF_SEND_COMMAND(0x32);
   S6B33BF_SEND_COMMAND(0x0e);
   //***********ENTRY MODE SET:Y ADDRESS INCRECE,READ MODIFY WRITE OFF***
   S6B33BF_SEND_COMMAND(0x40);
   S6B33BF_SEND_COMMAND(0x00);
   //************X ADDRESS SET FROM 0 TO 159*********
   S6B33BF_SEND_COMMAND(0x42);
   S6B33BF_SEND_COMMAND(0x00);
   S6B33BF_SEND_COMMAND(0x9f);
   //************Y ADDRESS SET FROM 0 TO 127**********
   S6B33BF_SEND_COMMAND(0x43);
   S6B33BF_SEND_COMMAND(0x00);
   S6B33BF_SEND_COMMAND(0x7f);
   //************0x88    d9 FRAME SET FIM=ON,FIP=AFRAME,N-BLK=16***
   S6B33BF_SEND_COMMAND(0x34);
   S6B33BF_SEND_COMMAND(0x92);
   //*************对比度1, CONTRAST SET V1 TO 3.0V  MAX=4V VCC=V1+V1*3/4*5=14.25***
   S6B33BF_SEND_COMMAND(0x2a);
   S6B33BF_SEND_COMMAND(0xbf);
   Delayms(20);  
   //****** 0x54   对比度2 ************
   S6B33BF_SEND_COMMAND(0x2b);
   S6B33BF_SEND_COMMAND(0x54);
   Delayms(20);  
   //********BIAS SET TO 1/5 AND -4X TIME 2'ND BOOSTER*****
   S6B33BF_SEND_COMMAND(0x22);
   S6B33BF_SEND_COMMAND(0x11);
   //*********ENTER PARTIAL DISPLAY MODE******
   S6B33BF_SEND_COMMAND(0x55);
   S6B33BF_SEND_COMMAND(0x01);
   //*********Frame Frequency Control*********
   S6B33BF_SEND_COMMAND(0x36);
   S6B33BF_SEND_COMMAND(0x00);
   S6B33BF_SEND_COMMAND(0x5a);
   S6B33BF_SEND_COMMAND(0x00);
   //*********DISPLAY ON***********************
   S6B33BF_SEND_COMMAND(0x51);
	
}

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

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

	S6B33BF_Invalidate();
}

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

⌨️ 快捷键说明

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