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

📄 tft_bf6812a.c

📁 ARMSTM32 lcd驱动程序集锦
💻 C
📖 第 1 页 / 共 3 页
字号:
										/*0: X first*/
										/*1: Y first*/
	1,		//uint8	is_dummy_read;		/*deciding first read data when reading GRAM*/
										/*0: acknowledge first data as valid data*/
										/*1: acknowledge first data as dummy data*/
	3,		//uint8	cyclenum_read;		/*total cycle numbers needed to access GRAM read/write*/
	0x16,	//uint8	win_setstartx_cmd;	/*window x start address set command*/
	0x16,	//uint8	win_setendx_cmd;	/*window x end address set command*/
	0x17,	//uint8	win_setstarty_cmd;	/*window y start address set command*/
	0x17,	//uint8	win_setendy_cmd;	/*window y end address set command*/
	0x21,	//uint8	gram_setx_cmd;		/*gram x address set command*/
	0x00,	//uint8	gram_sety_cmd;		/*gram y address set command*/
	0x22,	//uint8	gram_read_cmd;		/*gram read command*/
	0x22,	//uint8	gram_write_cmd;		/*gram write command*/
	//@zhemin.lin, add 1 line, CR9590
	0x00,	//uint8	line_offset;		/*line offset for display on lcd*/
	0x00	//uint8 colum_offset        /*columoffset for display on lcd*/
};


/******************************************************************************/
//  Description:    get the important parameter for digital camera
//	Global resource dependence: 
//  Author:         Zhemin.lin
//	Note:           
/******************************************************************************/
LOCAL ERR_LCD_E  BF6812A_GetMainLcdSpec(
	LCD_SPEC_T *spec_ptr 	//spec struct pointer
	)
{
	if (spec_ptr == PNULL)
	{
		return 1;
	}
	
	memcpy(spec_ptr, &g_BF6812A_spec, sizeof(LCD_SPEC_T));
	
	return ERR_LCD_NONE;
}

/******************************************************************************/
//  Description:   Enter/Exit sleep mode .
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E  BF6812A_EnterSleep(
	BOOLEAN is_sleep 	//SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode.
	)
{
	SCI_TRACE_LOW("BF6812A_EnterSleep,%d", is_sleep);

	if ( is_sleep ) // enter sleep mode.
	{
		BF6812A_GoSleep(); 
	}
	else 			// out sleep mode 
	{
		//BF6812A_reset();
		BF6812A_ExitSleep();
	}

	/*
	if( !GetUdiskState())
	DC_EnterSleep(is_sleep);
	*/
	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 BF6812A_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
	)
{
	BF6812A_set_display_window(left, top, right, bottom);

	BF6812A_set_start_address(left, top);		//@David.Jia 2005.12.26

	BF6812A_SEND_COMMAND(0x0022); 				//@David.Jia 2005.12.26

	return ERR_LCD_NONE;
}

/*********************************************************************/
//  Description:   Initialize color LCD : BF6812A
//  Input:
//      None.
//  Author:         yinchun.li
//  Return:
//      None.
//	Note:
//  modify:  jim.cui  2005.0728 add dma init  
/*********************************************************************/
LOCAL ERR_LCD_E BF6812A_Init(void)
{
	
	//dma init
	dma_init ();
	
	//BF6812A_HW_reset();
	BF6812A_reset();
	
	BF6812A_Clear( 0xf25f );
	
	return ERR_LCD_NONE;
}


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


/*****************************************************************************/
//  Description:    Set the brightness of LCD.
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/*****************************************************************************/
LOCAL ERR_LCD_E   BF6812A_SetBrightness(
	uint16 brightness	//birghtness to set
	)
{
	return ERR_LCD_FUNC_NOT_SUPPORT;
}

/******************************************************************************/
//  Description:   Close the lcd.(include sub lcd.)
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL void BF6812A_Close()
{
    GPIO_SetLcdBackLight( SCI_FALSE );
    BF6812A_EnterSleep( SCI_TRUE );	
}


LOCAL LCD_OPERATIONS_T BF6812A_operations = 
{
	BF6812A_Init,
	BF6812A_EnterSleep,
	BF6812A_SetContrast,
	BF6812A_SetBrightness,
	BF6812A_SetDisplayWindow,
	BF6812A_GetInfo,
	BF6812A_InvalidateRect,
	BF6812A_InvalidateRectImage,
	BF6812A_Invalidate,
	BF6812A_Clear,
	BF6812A_Close,
	BF6812A_GetMainLcdSpec
};

/******************************************************************************/
//  Description:  return the BF6812A lcd driver funtion pointer
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC LCD_OPERATIONS_T* BF6812A_GetOperations()
{
	return &BF6812A_operations;
}

#define ADC_NUM 10
PUBLIC BOOLEAN BF6812A_Probe(void)
{
	return SCI_TRUE;
}


LOCAL BF6812A_GoSleep(void)
{

    #if 0
    
	BF6812A_SEND_COMMAND(0x000b);
	BF6812A_SEND_DATA(0x0000);
	
	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0036);
	
	Delayms(40);      
	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0026);                
	Delayms(40); 

	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0004);

	BF6812A_SEND_COMMAND(0x0009);
	BF6812A_SEND_DATA(0x0008); 

	BF6812A_SEND_COMMAND(0x0003);
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x000d);
	BF6812A_SEND_DATA(0x0000);

	BF6812A_SEND_COMMAND(0x000e);
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0003);
	BF6812A_SEND_DATA(0x0002); 

	#else

	//--------Modify 20070926------------

	BF6812A_SEND_COMMAND(0x000b);
	BF6812A_SEND_DATA(0x0000);
	
	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0036);
	Delayms(50); 
	     
	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0026);                
	Delayms(50); 

	BF6812A_SEND_COMMAND(0x005b);///add
	BF6812A_SEND_DATA(0x0004);
	
	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0004); 	

	BF6812A_SEND_COMMAND(0x0009);
	BF6812A_SEND_DATA(0x0000);///change 0008 
 
	BF6812A_SEND_COMMAND(0x000d);
	BF6812A_SEND_DATA(0x0000);

	BF6812A_SEND_COMMAND(0x000e);
	BF6812A_SEND_DATA(0x0000); 
	
	BF6812A_SEND_COMMAND(0x0003);
	BF6812A_SEND_DATA(0x0000);
	Delayms(10);

	BF6812A_SEND_COMMAND(0x0003);
	BF6812A_SEND_DATA(0x0002); 
	Delayms(10);
   
	#endif
   
   
}

LOCAL BF6812A_ExitSleep(void)
{


    /*
	BF6812A_SEND_COMMAND(0x0003);
	BF6812A_SEND_DATA(0x0000); 
	Delayms(20);

	BF6812A_SEND_COMMAND(0x000d);
	BF6812A_SEND_DATA(0x0000); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x000e);
	BF6812A_SEND_DATA(0x0000); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0000); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x000c);
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0009);
	BF6812A_SEND_DATA(0x0008); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x000d);
	BF6812A_SEND_DATA(0x0003); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x000e);
	BF6812A_SEND_DATA(0x1017); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x000d);
	BF6812A_SEND_DATA(0x0013); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x0003);
	BF6812A_SEND_DATA(0x0010); 
	Delayms(50);

	BF6812A_SEND_COMMAND(0x0009);
	BF6812A_SEND_DATA(0x0000); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x0003);
	BF6812A_SEND_DATA(0x0410); 
	Delayms(15);

	BF6812A_SEND_COMMAND(0x000e);
	BF6812A_SEND_DATA(0x3016); 
	Delayms(150);

	BF6812A_SEND_COMMAND(0x0009);
	BF6812A_SEND_DATA(0x0004); 
	Delayms(50);

	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0005); 
	Delayms(40);

	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0025); 

	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0027); 


	BF6812A_SEND_COMMAND(0x005b);
	BF6812A_SEND_DATA(0x0000); 
	Delayms(50);

	BF6812A_SEND_COMMAND(0x0007);
	BF6812A_SEND_DATA(0x0037); 
	Delayms(10);
	*/

	
	 BF6812A_reset();   //  解决白屏,重新走一遍初始化.



	
   
   

}

/**********************************************************************************************
#if 1
LOCAL void main_lcd_fill_rect(uint16 left, uint16 top,uint16 right,  uint16 bottom,uint16 color)
{
	uint16 i,j;
	uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();
	for(i = top; i < bottom;i++)
	{
		for(j = left; j < right; j++)
		{                 
			*(buf_ptr+i*BF6812A_WIDTH+j)=color;
		}
	}

}


void main_lcd_test()
 {
	unsigned long i;


	//GPIO_SetLcdReset( 0 );	//lcd hardware reset.
	//for(i=0; i<3500; i++);		
	//GPIO_SetLcdReset( 1 );

	GPIO_SetLcdBackLight( SCI_TRUE );//set backlight 

	BF6812A_reset();// lcd init 

	for(i=0; i<3500; i++);
	main_lcd_fill_rect(0,0,BF6812A_WIDTH,BF6812A_HEIGHT/3,0xf800);//r
	main_lcd_fill_rect(0,BF6812A_HEIGHT/3,BF6812A_WIDTH,(2*BF6812A_HEIGHT)/3,0x07e0);//g	
	main_lcd_fill_rect(0,(2*BF6812A_HEIGHT)/3,BF6812A_WIDTH,BF6812A_HEIGHT,0x001f);//g	
	BF6812A_Invalidate();
	for(i=0; i<3500; i++);
	main_lcd_fill_rect(0,0,BF6812A_WIDTH,BF6812A_HEIGHT,0x5171);//r	

	BF6812A_InvalidateRect(0,0,20,30);
	//for(i=0; i<3500; i++); 
	//while(1);
}
#endif
*******************************************/

/**---------------------------------------------------------------------------*
 **                         Compiler Flag                                     *
 **---------------------------------------------------------------------------*/
#ifdef   __cplusplus
    }
#endif 

⌨️ 快捷键说明

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