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

📄 cstn_st7669.c

📁 ARMSTM32 lcd驱动程序集锦
💻 C
📖 第 1 页 / 共 3 页
字号:
/********************************************************************************
**********************************************************************************
 ** Copyright:     上海闻泰电子第一产品部
 ** All Rights     Reserved.                                      
 
 ** Project Name:  W180
 ** File Name:     tft_ST7669.c                                              
 ** Description:   This file contains driver for color LCD.
                   LCD type : CSTN
 				           Driver IC: ST7669
 				           Dot pixcel:128*160
 				           Manufacture: BYD
 									 			                                
 ** Current Ver:   1.0 				                 
 ** Author:        Huangfusheng                                              
 ** DATE:          08/14/2007                                               
 
 ** Displace Ver:  None    
 ** Author :       ***
 ** Data   :       ***
 ********************************************************************************
 ********************************************************************************/

#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	ST7669_WIDTH	128//176
#define	ST7669_HEIGHT	160//220
#define MP4_MAX_WIDTH	176
#define MP4_MAX_HEIGHT	144

#define OFFSET_X	0

//@David.Jia 2005.11.22
#define ADC_ST7669_LOW    231
#define ADC_ST7669_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 ST7669_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 ST7669_Close(void);

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

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

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


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

LOCAL void ST7669_reset(void)
{
	SCI_TRACE_LOW("ST7669_reset: 7370 GG3728 ST7669/HYDIS.");
	


    ST7669_SEND_COMMAND(0x0001);    //soft reset
	Delayms(200);                   //at least 100ms delay

	//-------disable autoread + Manual read once--
	ST7669_SEND_COMMAND(0x00D7);
	ST7669_SEND_DATA(0x00BF);

	ST7669_SEND_COMMAND(0x00E0);
	ST7669_SEND_DATA(0x0000);
	Delayms(20);

    ST7669_SEND_COMMAND(0x00E3);
	Delayms(20);

	ST7669_SEND_COMMAND(0x00E1);

	//--------sleep out---------------------
	
	ST7669_SEND_COMMAND(0x0028);
	ST7669_SEND_COMMAND(0x0011);
	Delayms(200);

	//--------vopsetting---------------------
	
	ST7669_SEND_COMMAND(0x00C0);
	ST7669_SEND_DATA(0x0026);
	ST7669_SEND_DATA(0x0001);

	//--------set regedit-------------------

	ST7669_SEND_COMMAND(0x00C3);
	ST7669_SEND_DATA(0x0005);

	ST7669_SEND_COMMAND(0x00C4);
	ST7669_SEND_DATA(0x0006);
	Delayms(100);

	ST7669_SEND_COMMAND(0x00C5);
	ST7669_SEND_DATA(0x0012);

	ST7669_SEND_COMMAND(0x00CB);
	ST7669_SEND_DATA(0x0001);

	ST7669_SEND_COMMAND(0x00B7);
	ST7669_SEND_DATA(0x00C8);//00c8

	ST7669_SEND_COMMAND(0x00D0);
	ST7669_SEND_DATA(0x001D);

	//--------MTP set----------

	ST7669_SEND_COMMAND(0x00D7);
	ST7669_SEND_DATA(0x00BF);

	ST7669_SEND_COMMAND(0x00F0);
	ST7669_SEND_DATA(0x0006);
	ST7669_SEND_DATA(0x000B);
	ST7669_SEND_DATA(0x000D);
	ST7669_SEND_DATA(0x0016);

	ST7669_SEND_COMMAND(0x00B5);
	ST7669_SEND_DATA(0x008A);

	ST7669_SEND_COMMAND(0x00B4);
	ST7669_SEND_DATA(0x0018);

	//--------Command Table 1------
	
    ST7669_SEND_COMMAND(0x0020);
	ST7669_SEND_COMMAND(0x002A);
	ST7669_SEND_DATA(0x0000);
	ST7669_SEND_DATA(0x0002);
	ST7669_SEND_DATA(0x0000);
	ST7669_SEND_DATA(0x0081);

	ST7669_SEND_COMMAND(0x002B);
	ST7669_SEND_DATA(0x0000);
	ST7669_SEND_DATA(0x0002);
	ST7669_SEND_DATA(0x0000);
	ST7669_SEND_DATA(0x00A1);

	ST7669_SEND_COMMAND(0x003A);
	ST7669_SEND_DATA(0x0005);

	ST7669_SEND_COMMAND(0x0036);
	ST7669_SEND_DATA(0x0000);

	ST7669_SEND_COMMAND(0x00B0);
	ST7669_SEND_DATA(0x009F);

	//---------Gamma Table Set------
	
    ST7669_SEND_COMMAND(0x00F9);
	ST7669_SEND_DATA(0x0000);
	ST7669_SEND_DATA(0x0003);
	ST7669_SEND_DATA(0x0005);
	ST7669_SEND_DATA(0x0007);
	ST7669_SEND_DATA(0x0009);
	ST7669_SEND_DATA(0x000B);
	ST7669_SEND_DATA(0x000D);
	ST7669_SEND_DATA(0x000F);
	ST7669_SEND_DATA(0x0011);
	ST7669_SEND_DATA(0x0013);
	ST7669_SEND_DATA(0x0015);
	ST7669_SEND_DATA(0x0017);
	ST7669_SEND_DATA(0x0019);
	ST7669_SEND_DATA(0x001B);
	ST7669_SEND_DATA(0x001D);
	ST7669_SEND_DATA(0x001F);

	ST7669_SEND_COMMAND(0x0029);
    ST7669_SEND_COMMAND(0x002C);
	
	
	
}

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

            dma_request(0, (uint32)&fill_color, (uint32)(buf_ptr + i * ST7669_WIDTH), ST7669_WIDTH, 

⌨️ 快捷键说明

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