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

📄 lcd_cfg.c

📁 液晶驱动 液晶驱动 液晶驱动 液晶驱动
💻 C
字号:


#include "sci_types.h"
#include "lcd.h"
#include "make.h"//LW060228

/**---------------------------------------------------------------------------*
 **                         Compiler Flag                                     
 **---------------------------------------------------------------------------*/
#ifdef   __cplusplus
    extern   "C" 
    {
#endif

/**---------------------------------------------------------------------------*
 **                         Macro defines                                     
 **---------------------------------------------------------------------------*/

//max number of main lcd support in this project.

               
#define MAX_SUB_LCD_SUPPORT     1                 


#define	LCD_BUF_SIZE	 		(240*320)		//main lcd buffer size.
#define	SUBLCD_BUF_SIZE			(96*96)			//sub lcd buffer size.

#ifdef	TWO_LCD
#define	MAX_MAIN_LCD_SUPPORT 	4  
uint8	g_LCD_param = 0;
#ifdef  W622
#define BYD_CSTN				1
#define BYD_TFT					2
#define Truly_TFT				3
#define Truly_CSTN				4
#endif
#else
#define	MAX_MAIN_LCD_SUPPORT 	1
#endif


/**--------------------------------------------------------------------------*
 **                         Constant DEFINITION                                *
 **--------------------------------------------------------------------------*/ 
//Constant parameter for MAIN LCD.

const uint16 lcd_width  		= 240;			// width of main lcd.
const uint16 lcd_height 		= 320;			// height of main lcd.
//const uint32 lcd_command_adr	= 0x0c000000;	//address of command for main lcd.  
//const uint32 lcd_data_adr   	= 0x0c000002;	//address of data for main lcd. 
const uint8  lcd_contrast_v		= 0xB8;			//contrast value for main lcd.(0--255)

//Constant parameter for SUB LCD.

const uint16 sublcd_width  		= 96;			// width of sub lcd
const uint16 sublcd_height 		= 96;			// height of sub lcd.
//const uint32 sublcd_command_adr	= 0x0c180000;	//address of command for sub lcd.	 
//const uint32 sublcd_data_adr	= 0x0c380000;	//address of data for sub lcd.  
const uint8 sublcd_contrast_v	= 0x8;			//contras value of sub lcd.(0xE8--0xEB) 
												//In fact, 0xe8 and 0xeb are too bad contrast value.

/**--------------------------------------------------------------------------*
 **                         STATIC DEFINITION                                *
 **--------------------------------------------------------------------------*/
uint8	g_LCD_param = 0;
typedef uint16 LCD_COLOR_T;		//main lcd color type (bits-per-pixel)
typedef uint16 SubLCD_COLOR_T;	//sub lcd color type (bits-per-pixel)


LOCAL LCD_COLOR_T 		g_lcd_buffer[LCD_BUF_SIZE];			//lcd buffer

LOCAL SubLCD_COLOR_T 	g_sublcd_buffer[SUBLCD_BUF_SIZE];	//sub lcd buffer

LOCAL int Refreshflag = TRUE ;
/**--------------------------------------------------------------------------*
 **                         EXTERNAL DEFINITION                              *
 **--------------------------------------------------------------------------*/
extern const uint32    g_mem_limit;
extern LCD_OPERATIONS_T * LCD_GetLCDPointer(LCD_ID_E lcd_id);
extern void LCD_SetLCDPointer(LCD_ID_E lcd_id, LCD_OPERATIONS_T* lcdpointer_ptr);

extern void GPIO_SetCameraByPassMode(BOOLEAN bByPass);
extern void GPIO_SetLcdBackLight(BOOLEAN b_on);

/**--------------------------------------------------------------------------*
 **                         CUSTOMERIZE DEFINITION                           *
 **--------------------------------------------------------------------------*/
//struct for probe function

typedef struct lcd_probe_tag
{
	BOOLEAN (*probe)(void);
	LCD_OPERATIONS_T* (*get_operations)(void);
} LCD_PROBE_T;


extern BOOLEAN S1D19501_Probe(void);
extern LCD_OPERATIONS_T* S1D19501_GetOperations(void); 

//probe function for sub lcd supported.
extern BOOLEAN S1D15G24_Probe(void);
extern LCD_OPERATIONS_T* S1D15G24_GetOperations(void); 


//probe function table for main lcd supported.
const LCD_PROBE_T lcd_probe[MAX_MAIN_LCD_SUPPORT] = 
{
  
	
      {HX8312A_Probe,HX8312A_GetOperations}
	
};
const LCD_PROBE_T sublcd_probe[MAX_SUB_LCD_SUPPORT] =
{
    {S1D15G24_Probe, S1D15G24_GetOperations}
};
/**---------------------------------------------------------------------------*
 **                         Functions                                      
 **---------------------------------------------------------------------------*/
PUBLIC void LCD_PointerSaveInAssertResetMode(void)
{

	*(volatile uint32 *)(g_mem_limit - 8 ) = (uint32)LCD_GetLCDPointer(MAIN_LCD_ID);
	*(volatile uint32 *)(g_mem_limit - 4 ) = (uint32)LCD_GetLCDPointer(SUB_LCD_ID);
}


PUBLIC void LCD_InitInAssertRestMode(void)
{
	LCD_SetLCDPointer(MAIN_LCD_ID, (LCD_OPERATIONS_T *)(*(volatile uint32 *)(g_mem_limit - 8)));
	LCD_SetLCDPointer(SUB_LCD_ID,  (LCD_OPERATIONS_T *)(*(volatile uint32 *)(g_mem_limit - 4)));
}


BOOLEAN LCD_IsLCDPointerValid(LCD_ID_E lcd_id, LCD_OPERATIONS_T* lcdpointer_ptr)
{
	if (MAIN_LCD_ID == lcd_id)
	{
		
		
		   if(lcdpointer_ptr == HX8312A_GetOperations())
		   	{
                return SCI_TRUE;
		    }
			else
			{
				return SCI_FALSE;
			}	
	}
	else //sub lcd 
	{
		if (lcdpointer_ptr == S1D15G24_GetOperations())
		{
			return SCI_TRUE;
		}
		else
		{
			return SCI_FALSE;
		}
	}	
}


PUBLIC void LCD_DisplayOn(void)
{
	// exit sleep mode
	LCD_EnterSleep(MAIN_LCD_ID, SCI_FALSE);

	// enter by pass mode if have digital cammera
	GPIO_SetCameraByPassMode(SCI_TRUE);

	// open back light.
    GPIO_SetLcdBackLight(SCI_TRUE);
}

/******************************************************************************/
//  Description:  return the main lcd buffer  pointer
//	Global resource dependence:
//  Author: Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC void *LCD_GetLCDBuffer(void)
{
	return g_lcd_buffer;		
}

/******************************************************************************/
//  Description:  return the sub lcd buffer pointer
//	Global resource dependence:
//  Author: Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC void *LCD_GetSubLCDBuffer(void)
{
	return g_sublcd_buffer;
}


/******************************************************************************/
//  Description:  return the main lcd driver funtion pointer
//	Global resource dependence:
//  Author: Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC LCD_OPERATIONS_T *LCD_GetOperations(void)
{
#ifdef TWO_LCD

	#ifdef W622
	uint16 i;
	SCI_TRACE_LOW("LCD_Init g_LCD_param = %i",g_LCD_param);//osow
	switch(g_LCD_param)
	{
		case BYD_CSTN:
			i = 0;
			break;
		case BYD_TFT:
			i = 0;
			break;
		case Truly_TFT:
			i = 1;
			break;
		case Truly_CSTN:
			i = 1;
			break;
		default:
			i = 1;
			break;
	}
	SCI_TRACE_LOW("LCD_Init i = %i",i);//osow
	return ( lcd_probe[i].get_operations() );
	#endif
	
	#ifdef W623
	SCI_TRACE_LOW("LCD_Init roger g_LCD_param = %i",g_LCD_param);
    return ( lcd_probe[g_LCD_param-1].get_operations() );
	#endif

#else

	uint16 i;
	
	for(i=0; i<MAX_MAIN_LCD_SUPPORT; i++)
	{
		if( lcd_probe[i].probe() )
		{
			return( lcd_probe[i].get_operations() );
		}
	}
	
	return ( lcd_probe[0].get_operations() );
#endif
}

/******************************************************************************/
//  Description:  return the sub lcd driver funtion pointer
//	Global resource dependence:
//  Author: Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC LCD_OPERATIONS_T *SubLCD_GetOperations(void)
{
    uint16 i;
	
	for(i=0; i<MAX_SUB_LCD_SUPPORT; i++)
	{
		if( sublcd_probe[i].probe() )
		{
			return( sublcd_probe[i].get_operations() );
		}
	}
	
	return ( sublcd_probe[0].get_operations() );

}

/******************************************************************************/
//  Description:  return the sub lcd driver funtion pointer
//	Global resource dependence:
//  Author: Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC int LCD_RefreshControl (int flag)
{
	Refreshflag = flag;
	return Refreshflag;
}
/******************************************************************************/
//  Description:  return the sub lcd driver funtion pointer
//	Global resource dependence:
//  Author: Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC int LCD_GetRefreshFlag ()
{
	return Refreshflag;
}

/**---------------------------------------------------------------------------*
 **                         Compiler Flag                                     *
 **---------------------------------------------------------------------------*/
#ifdef   __cplusplus
    }
#endif 
// end lcd_cfg.c

⌨️ 快捷键说明

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