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

📄 tft_nt39102.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.
 ******************************************************************************/

#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	NT39102_WIDTH	       128
#define	NT39102_HEIGHT	160
#define   MP4_MAX_WIDTH	176
#define   MP4_MAX_HEIGHT	144
#define OFFSET_X	0


extern void *LCD_GetLCDBuffer(void);

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

/******************************************************************************/
//  Description:  Set start RAM address which is write to AC(Address
//                Counter) register.
//  Input:
//      left: start Horizon address of AC
//      top: start Vertical address of AC.
//  Return:
//      None.
//	Note:           
/******************************************************************************/
LOCAL void NT39102_set_start_address(
	uint8 left, 
	uint8 top
	);

  /******************************************************************************/
//  Description:   Clear color LCD with one color
//	Global resource dependence: 
//  Author:         louis.wei
//	Note:
/******************************************************************************/

LOCAL void NT39102_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 NT39102_Close();

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

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

/******************************************************************************/
//  Description:   invalidate a rectang of in LCD
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E NT39102_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 NT39102_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
	);

/**---------------------------------------------------------------------------*
 **                      Function  Definitions
 **---------------------------------------------------------------------------*/

#define NT39102_SEND_COMMAND( c)   		{*(volatile uint16 *)0x58000000 = c;}
	
#define  NT39102_SEND_DATA(d) 	{*(volatile uint16 *)0x58020000 = d;}
 
#define NT39102_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58020000 = data;}

void NT39102_reset(void)
{

    uint16 lcm_nv=0;
	lcm_nv = REFPARAM_GetLCDType();

	

	switch(lcm_nv)
	{

//	case TFT_NT39102:

	{

    SCI_TRACE_LOW("NT39102_reset: 7370 GG3728 NT39102/HYDIS.");
	NT39102_SEND_COMMAND(0x01); // software reset
       NT39102_SEND_COMMAND(0x11); //sleep out
       Delayms(150);//加延时,稳定,以防万一
       NT39102_SEND_COMMAND(0x20); //display inversion off
       NT39102_SEND_COMMAND(0x38); //ide mode off
       NT39102_SEND_COMMAND(0x13); //normal dispaly mode on
       NT39102_SEND_COMMAND(0x3a); //interface pixel formart
       NT39102_SEND_DATA(0x05);  
	//===================== vcom set ================//
       NT39102_SEND_COMMAND(0xc5);
       NT39102_SEND_DATA(0x4f);  
       NT39102_SEND_DATA(0x4d);  
       NT39102_SEND_COMMAND(0xc7);
       NT39102_SEND_DATA(0xc0);//06 
       Delayms(10);
	//=================== display set ===============//
       NT39102_SEND_COMMAND(0x36); //Memory Data Access Control
       NT39102_SEND_DATA(0x00); //00
        //================ Gamma curve 2.2==========
       NT39102_SEND_COMMAND(0xe0);
       NT39102_SEND_DATA(0x20);//
       NT39102_SEND_DATA(0x61);//
       NT39102_SEND_DATA(0x01);//
       NT39102_SEND_DATA(0x00);//
       NT39102_SEND_DATA(0x46);//
       NT39102_SEND_DATA(0x0b);//
       NT39102_SEND_DATA(0x0b);//
       NT39102_SEND_DATA(0xc0);//
       NT39102_SEND_COMMAND(0xe1);
       NT39102_SEND_DATA(0x77);//
       NT39102_SEND_DATA(0x03);//
       NT39102_SEND_DATA(0x72);//
       NT39102_SEND_DATA(0x0b);//
       NT39102_SEND_DATA(0xfe);//
       NT39102_SEND_DATA(0x01);//
       NT39102_SEND_DATA(0x07);//
       NT39102_SEND_DATA(0x5a);//
	//==================== address set=============//
       NT39102_SEND_COMMAND(0x2a);
       NT39102_SEND_DATA(0x00);
       NT39102_SEND_DATA(0x00);
       NT39102_SEND_DATA(0x00);
       NT39102_SEND_DATA(0x7f);
       NT39102_SEND_DATA(0x84);
       NT39102_SEND_COMMAND(0x2b);
       NT39102_SEND_DATA(0x00);
       NT39102_SEND_DATA(0x00);
       NT39102_SEND_DATA(0x00);
       NT39102_SEND_DATA(0x9f);
       NT39102_SEND_DATA(0xa2);
       //=============== display on ==================//
       NT39102_SEND_COMMAND(0x29); //display on
       NT39102_SEND_COMMAND(0x2c); //writer data to ram
       Delayms(10);

	   break;
		}
//	case TFT_NT39102_dijing:
	{


     SCI_TRACE_LOW("NT39102_dijing_reset: 7370 GG3728 NT39102/HYDIS.");
	 
	 NT39102_SEND_COMMAND(0x01);
	 Delayms(50);
     NT39102_SEND_COMMAND(0x38);
	 NT39102_SEND_COMMAND(0x11);
	 Delayms(100);

	 NT39102_SEND_COMMAND(0x3a);NT39102_SEND_DATA(0x55);


	   NT39102_SEND_COMMAND(0xc7);
	   NT39102_SEND_DATA(0xbf);    //bf
	   NT39102_SEND_COMMAND(0xc0);
	   NT39102_SEND_DATA(0x07);
	   NT39102_SEND_DATA(0x03);      //0205
       NT39102_SEND_COMMAND(0xc1);
	   NT39102_SEND_DATA(0x07);
       NT39102_SEND_COMMAND(0xc2);
	   NT39102_SEND_DATA(0x04);
	   NT39102_SEND_DATA(0x06);       //0406    0303
       NT39102_SEND_COMMAND(0xc3);
	   NT39102_SEND_DATA(0x02);
	   NT39102_SEND_DATA(0x07);       //0207
       NT39102_SEND_COMMAND(0xc4);
	   NT39102_SEND_DATA(0x05);
	   NT39102_SEND_DATA(0x00);      //0307      0500
 	   NT39102_SEND_COMMAND(0xc5); 
	   NT39102_SEND_DATA(0x4d); 
	   NT39102_SEND_DATA(0x4d);    //584d
	   NT39102_SEND_COMMAND(0xc6);
	   NT39102_SEND_DATA(0x05);         //07    06

        NT39102_SEND_COMMAND(0xb4);
		NT39102_SEND_DATA(0x02);    //02
        NT39102_SEND_COMMAND(0xb1);
        NT39102_SEND_DATA(0x11);  //11      //0A
        NT39102_SEND_DATA(0x14);  //16     //13

        NT39102_SEND_COMMAND(0xb7);
		NT39102_SEND_DATA(0x00);
        NT39102_SEND_COMMAND(0xb8);
		NT39102_SEND_DATA(0x00);
        NT39102_SEND_COMMAND(0x36);
		NT39102_SEND_DATA(0x08);

        NT39102_SEND_COMMAND(0x26);
        NT39102_SEND_DATA(0x02);


        NT39102_SEND_COMMAND(0xe1);
        NT39102_SEND_DATA(0x77);
        NT39102_SEND_DATA(0x62);
        NT39102_SEND_DATA(0x72);
        NT39102_SEND_DATA(0x0b);
        NT39102_SEND_DATA(0x59);
        NT39102_SEND_DATA(0x07);
        NT39102_SEND_DATA(0x07);
        NT39102_SEND_DATA(0x6a);

 
	   NT39102_SEND_COMMAND(0x29);
	   NT39102_SEND_COMMAND(0x2c);

	  break;
	  }
	default:
	  break;
	
   }

	
	
 }

  /******************************************************************************/
//  Description:   Clear color LCD with one color
//	Global resource dependence: 
//  Author:         louis.wei
//	Note:
/******************************************************************************/
LOCAL void NT39102_Clear(
						uint32 color	//color to fill the whole lcd.
						)
{
	uint32 i;
	uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();
	
	for( i=0; i<(NT39102_HEIGHT * NT39102_WIDTH); i++)
	{
		*buf_ptr++ = color;
	}		

	NT39102_Invalidate();
}

/******************************************************************************/
//  Description:   invalidate a rectang of in LCD
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E NT39102_Invalidate(void)
{
	uint16 i,j, k,tmp;
	uint16 address = 0;
	uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();
	
#if 1	
	uint32  dummy_before,dummy_after;

	//Column ADDRESS SET FROM 00 TO 128	
	//SCI_TRACE_LOW("*******************NT39102_Invalidate**************************");
/*	
	address = (uint16) ( (((NT39102_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X));
	NT39102_sendcommand1(0x2a, address);		// set horizon address

⌨️ 快捷键说明

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