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

📄 cstn_s1d15g24.c

📁 展讯平台多款LCD驱动:cstn_nt7526/cstn_S1D15G24/cstn_S6B33B5A
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
 ** 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"

 #ifdef   __cplusplus
    extern   "C" 
    {
#endif

/**---------------------------------------------------------------------------*
 **                            Macro Define
 **---------------------------------------------------------------------------*/

#define S1D15G24_WIDTH	96
#define S1D15G24_HEIGHT	96


LOCAL ERR_LCD_E S1D15G24_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
	);
	
void S1D15G24_Reset(void);

LOCAL ERR_LCD_E S1D15G24_Invalidate(void);
 void S1D15G24_Close(void);


#define S1D15G24_Command( cmd )		{*(volatile uint16 *)0x58010000 = cmd;}
#define S1D15G24_Data( dat )		{*(volatile uint16 *)0x58018000 = dat;}
#define Delayms( ms)\
{\
	int i;\
	for (i=0; i< 100 * ms; i++) ;\
}

void S1D15G24_Reset(void)	
{
 /*------enable interal oscillator--------*/
	S1D15G24_Command(0x00);	
	S1D15G24_Command(0x01);	
	Delayms(200);   
        S1D15G24_Command(0xBE);	
        S1D15G24_Data(0x3A); //3A		/*bias set :1/7*/
	Delayms(200);  
/*------set power control register-------*/
	S1D15G24_Command(0xB6);	
	S1D15G24_Data(0x80); //0X6A    
        S1D15G24_Data(0x0B);	//0X09	
	S1D15G24_Data(0x06);//0X02
        S1D15G24_Data(0x68);		
	S1D15G24_Data(0x00);
        S1D15G24_Data(0x00);
        Delayms(200);           
	S1D15G24_Command(0xBA);	
	S1D15G24_Data(0x6F);//0X5A 
	S1D15G24_Data(0x00); //0X5A
/*----set contrast level & interal regulator----*/	
	S1D15G24_Command(0xBB);	
	S1D15G24_Data(0x03);//0X03		/*contrast : 0x00~0x3f */
	   

	
/*-----set com output scan direction-------*/
	S1D15G24_Command(0x25);	
	S1D15G24_Data(0x4a); //
	S1D15G24_Command(0x13);	
	S1D15G24_Command(0x36);	
	S1D15G24_Data(0x90);	
/*--------set data out direction-----------*/
	S1D15G24_Command(0x2B);	
	S1D15G24_Data(0x00); 
	S1D15G24_Data(0x5F);	
	
	
/*-----------set display control-------------*/
	S1D15G24_Command(0x2A);	
	S1D15G24_Data(0x00); 
	S1D15G24_Data(0x5f);	
	S1D15G24_Data(0x00);	
	S1D15G24_Data(0x00);
/*----------set frame frequency-------------*/
	
	S1D15G24_Command(0x11);	
	S1D15G24_Command(0x29);	
	S1D15G24_Command(0xB7);	
	S1D15G24_Data(0x00); 		/*frame frequency*/
	S1D15G24_Command(0x2C);			/*N_Line inversion : 0x01~0x1f*/

   
    }


 LOCAL void  S1D15G24_Clear(
						uint32 color		//color to fill the whole lcd.
						)
{
	uint32 i;
	uint16 *buf_ptr = (uint16 *)LCD_GetSubLCDBuffer();
	
	for( i=0; i<(S1D15G24_HEIGHT * S1D15G24_WIDTH); i++)
	{
		*buf_ptr++ = color;
	}	
}


 LOCAL ERR_LCD_E S1D15G24_Invalidate(void)
{
	uint32 i,k;
	uint16 *buf_ptr = (uint16 *)LCD_GetSubLCDBuffer();
	uint16	color = 0x00;
	uint8	lcd_mode = 0;
	//SCI_TRACE_LOW("#####################S1D15G24_InvalidateRect#############################");

	if (LCD_GetRefreshFlag() != TRUE )
	{
		return ERR_LCD_OPERATE_FAIL ;
	}

	lcd_mode = w99685CMD_GetLCMControlMode();
		if( 1 == lcd_mode )
		{
			//W99685CMD_SetLCMControlMode(0);
			return ERR_LCD_NONE;
		}

	/*-------set display area-----------*/
	S1D15G24_Command(0x2A);			//coladd : 0x02~0x31
	S1D15G24_Data(0x00);	
	S1D15G24_Data(0x5f);	

	S1D15G24_Command(0x2B);			//pagadd : 0x00~0x3f
	S1D15G24_Data(0x00);	
	S1D15G24_Data(0x5f);	

	//command of write display data to sub lcd
	S1D15G24_Command(0x2c);	
	
	for(i=0;i<S1D15G24_WIDTH*S1D15G24_HEIGHT;i++)
	{
	 color = *buf_ptr++;
	 
	 S1D15G24_Data((uint8)color>>8);	
	 S1D15G24_Data((uint8)(color & 0x00FF));	
	}
		if( 1 == lcd_mode )
		{
			W99685CMD_SetLCMControlMode(0);
		}

	return ERR_LCD_NONE;
}


 void S1D15G24_Close(void)
{
    S1D15G24_Command(0x28);
    S1D15G24_Command(0x10);
    Delayms(100);
}


LOCAL ERR_LCD_E  S1D15G24_EnterSleep(
	BOOLEAN is_sleep 	//SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode.
	)
{
	SCI_TRACE_LOW("S1D15G24_EnterSleep,%d", is_sleep);
	
	
	if ( is_sleep ) // enter sleep mode.
	{

		S1D15G24_Command(0x28);
		//Delayms(100);
		S1D15G24_Command(0x10);
		
        	//Delayms(100);
		
	}
	else 			// out sleep mode 
	{
		S1D15G24_Command(0x29);
		//Delayms(100);
		S1D15G24_Command(0x11);
		//S1D15G24_Reset();		
		//S1D15G24_Invalidate();
	}
	
	
	return ERR_LCD_NONE;
}

/*****************************************************************************/
//  Description:    Enable lcd to partial display mode, so can save power.
//	Global resource dependence: 
//  Author:         Jim.zhang
//  Return:         SCI_TRUE:SUCCESS ,SCI_FALSE:failed.
//	Note:           If all input parameters are 0, exit partial display mode.
/*****************************************************************************/
LOCAL ERR_LCD_E S1D15G24_SetDisplayWindow(
	uint16 left, 		//left of the window
	uint16 top,			//top of the window
	uint16 right,		//right of the window
	uint16 bottom		//bottom of the window
	)
{
	//@Zhemin.lin, CR 25198, implementation
	
	SCI_TRACE_LOW("S1D15G24_SetDisplayWindow:%d,%d,%d,%d",left,top,right,bottom);
  	left 	= (left >= S1D15G24_WIDTH)    ? S1D15G24_WIDTH-1 : left;
	right 	= (right >= S1D15G24_WIDTH)   ? S1D15G24_WIDTH-1 : right;
	top 	= (top >= S1D15G24_HEIGHT)    ? S1D15G24_HEIGHT-1 : top;
	bottom 	= (bottom >= S1D15G24_HEIGHT) ? S1D15G24_HEIGHT-1 : bottom;

	if ( ( right < left ) || ( bottom < top ) )
	{
		SCI_TRACE_LOW(" S1D15G24_SetDisplayWindow wrong: right > left or bottom > top");
		return ERR_LCD_PARAMETER_WRONG;
	}
 

	S1D15G24_Command(0x2A);			//coladd : 0x02~0x31
	S1D15G24_Data(left);	
	S1D15G24_Data(right);	

	S1D15G24_Command(0x2B);			//pagadd : 0x00~0x3f
	S1D15G24_Data(top);	
	S1D15G24_Data(bottom);	

	//command of write display data to sub lcd
	S1D15G24_Command(0x2c);	

	return ERR_LCD_NONE;
}

/******************************************************************************/
//  Description:  set the contrast value 
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E   S1D15G24_SetContrast(
	uint16  contrast	//contrast value to set
	)
{
	return ERR_LCD_FUNC_NOT_SUPPORT;
} 

/*****************************************************************************/
//  Description:    Get the lcd base information..
//	Global resource dependence: 
//  Author:         louis.wei
//	Note:
/*****************************************************************************/
LOCAL  ERR_LCD_E   S1D15G24_GetInfo(
								   LCD_INFO_T *lcd_info_ptr	//lcd information struct pointer
								   )
{
	if ( PNULL == lcd_info_ptr )
	{
		return ERR_LCD_POINTER_NULL;	
	}
	
	lcd_info_ptr->r_bitmask			= 0xf800;
	lcd_info_ptr->g_bitmask			= 0x07e0;
	lcd_info_ptr->b_bitmask			= 0x001f;
	lcd_info_ptr->bits_per_pixel	= 16;
	lcd_info_ptr->contrast_min		= 0x00;
	lcd_info_ptr->contrast_max   	= 63;
	lcd_info_ptr->contrast_defaut	= 0x0A;
	
	lcd_info_ptr->lcd_width		= S1D15G24_WIDTH;
	lcd_info_ptr->lcd_height	= S1D15G24_HEIGHT;
	lcd_info_ptr->lcdbuff_ptr	= (void *)LCD_GetSubLCDBuffer();
		
	return ERR_LCD_NONE;
}


LOCAL ERR_LCD_E S1D15G24_Init(void)

⌨️ 快捷键说明

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