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

📄 tft_bf6812a.c

📁 ARMSTM32 lcd驱动程序集锦
💻 C
📖 第 1 页 / 共 3 页
字号:
/********************************************************************************
**********************************************************************************
 ** Copyright:     上海闻泰电子第一产品部
 ** All Rights     Reserved.                                      
 
 ** Project Name:  T658+M50
 ** File Name:     tft_BF6812A.c                                              
 ** Description:   This file contains driver for color LCD.
                   LCD type : TFT
 				   Driver IC: BF6812A
 				   Dot pixcel:128*160
 				   Manufacture: Both Truly and LiJi

 **Current Ver:    1.2
 **Author:         Huangfusheng
 **Data  :         10/10/2007
 **Modify:
                   解决工程模式下测试画面乱的问题
                   修改了Invalidate ()函数
                   原因没有设置起始地址
 									 			                                
 ** Displace Ver:   1.1				                 
 ** Author:        Huangfusheng                                              
 ** DATE:          09/25/2007 
 ** Modify:        解决宏尚鹰的退出休眠白屏的问题
                   在退出休眠后重新reset一下.
 
 ** Displace Ver:  1.0 	
 ** Author :       Huangfusheng   
 ** Data   :       08/13/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	BF6812A_WIDTH	128//176
#define	BF6812A_HEIGHT	160//220
#define MP4_MAX_WIDTH	176
#define MP4_MAX_HEIGHT	144

#define OFFSET_X	0

//@David.Jia 2005.11.22
#define ADC_BF6812A_LOW    231
#define ADC_BF6812A_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 BF6812A_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 BF6812A_Close(void);

  /******************************************************************************/
//  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.
	);

/*****************************************************************************/
//  Description:    Get the lcd base information..
//	Global resource dependence: 
//  Author:         louis.wei
//	Note:
/*****************************************************************************/
LOCAL  ERR_LCD_E   BF6812A_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  BF6812A_GetMainLcdSpec(
	LCD_SPEC_T *spec_ptr 	//spec struct pointer
	);

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

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


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

LOCAL void BF6812A_reset(void)
{
	SCI_TRACE_LOW("BF6812A_reset: 7370 GG3728 BF6812A/HYDIS.");


   	//*****Power setting************
    
	BF6812A_SEND_COMMAND(0x0000); 
	BF6812A_SEND_DATA(0x0001);
	Delayms(100);                    
	BF6812A_SEND_COMMAND(0x0003);  
	BF6812A_SEND_DATA(0x0510);
	          
	BF6812A_SEND_COMMAND(0x0009);                
	BF6812A_SEND_DATA(0x0008);            
	
	BF6812A_SEND_COMMAND(0x000c);
	BF6812A_SEND_DATA(0x0000);            
	      
	BF6812A_SEND_COMMAND(0x000d);      
	BF6812A_SEND_DATA(0x0000);         
	
    BF6812A_SEND_COMMAND(0x000e);              
	BF6812A_SEND_DATA(0x0000);            
	
	BF6812A_SEND_COMMAND(0x005b);                        
	BF6812A_SEND_DATA(0x0004); 
	Delayms(100);

	BF6812A_SEND_COMMAND(0x000d);                        
	BF6812A_SEND_DATA(0x0010); 
	Delayms(100);

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

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

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

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

	//*************SRAM and Display Control Setting************
	BF6812A_SEND_COMMAND(0x0001);                        
	BF6812A_SEND_DATA(0x011f);    //001f
	Delayms(100);

	BF6812A_SEND_COMMAND(0x0005);                        
	BF6812A_SEND_DATA(0x0030); 

	BF6812A_SEND_COMMAND(0x0006);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0008);                        
	BF6812A_SEND_DATA(0x0202); 
	Delayms(100);

	BF6812A_SEND_COMMAND(0x000a);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x000b);                        
	BF6812A_SEND_DATA(0x0000); 
	Delayms(100);

    BF6812A_SEND_COMMAND(0x000f);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0010);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0011);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0014);                        
	BF6812A_SEND_DATA(0x9f00); 

	BF6812A_SEND_COMMAND(0x0015);                        
	BF6812A_SEND_DATA(0x9f00); 

	BF6812A_SEND_COMMAND(0x0016);                        
	BF6812A_SEND_DATA(0x7f00); 

	BF6812A_SEND_COMMAND(0x0017);                        
	BF6812A_SEND_DATA(0x9f00); 

	BF6812A_SEND_COMMAND(0x0020);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0021);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0023);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0024);                        
	BF6812A_SEND_DATA(0x0000); 

	BF6812A_SEND_COMMAND(0x0025);                        
	BF6812A_SEND_DATA(0x0000);

	BF6812A_SEND_COMMAND(0x0026);                        
	BF6812A_SEND_DATA(0x0000);

	//**********gamma*****************
	BF6812A_SEND_COMMAND(0x0030);                        
	BF6812A_SEND_DATA(0x0001);

	BF6812A_SEND_COMMAND(0x0031);                        
	BF6812A_SEND_DATA(0x0403);

	BF6812A_SEND_COMMAND(0x0032);                        
	BF6812A_SEND_DATA(0x0607);

	BF6812A_SEND_COMMAND(0x0033);                        
	BF6812A_SEND_DATA(0x0000);

	BF6812A_SEND_COMMAND(0x0034);                        
	BF6812A_SEND_DATA(0x0001);

	BF6812A_SEND_COMMAND(0x0035);                        
	BF6812A_SEND_DATA(0x0403);

	BF6812A_SEND_COMMAND(0x0036);                        
	BF6812A_SEND_DATA(0x0607);

	BF6812A_SEND_COMMAND(0x0037);                        
	BF6812A_SEND_DATA(0x0000);

	BF6812A_SEND_COMMAND(0x003a);                        
	BF6812A_SEND_DATA(0x0004);

	BF6812A_SEND_COMMAND(0x003b);                        
	BF6812A_SEND_DATA(0x0004);

	//********display on************

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

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

	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_SEND_COMMAND(0x0022);
	Delayms(50);
	
}

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

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

	BF6812A_Invalidate();
}

/******************************************************************************/
//  Description:   Set the windows address to display, in this windows
//                 color is  refreshed.
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
__inline void BF6812A_set_display_window(
	uint8 left, 	// start Horizon address
	uint8 top, 		// start Vertical address
	uint8 right, 	// end Horizon address
	uint8 bottom	// end Vertical address
	)
{
	uint16 addr1,addr2;
	addr1 = (((right&0xff)<<8)|(left&0xff));
	addr2 = (((bottom&0xff)<<8)|(top&0xff));
	
	BF6812A_SEND_COMMAND(0x0016);
	BF6812A_SEND_DATA(addr1);

	BF6812A_SEND_COMMAND(0x0017);
	BF6812A_SEND_DATA(addr2);

	
}

⌨️ 快捷键说明

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