📄 tft_spfd54124b_zhonghang.c
字号:
/********************************************************************************
**********************************************************************************
** Copyright: 上海闻泰电子第一产品部
** All Rights Reserved.
** Project Name: T658+M50
** File Name: tft_SPFD54124A_Zhonghang.c
** Description: This file contains driver for color LCD.
LCD type : TFT
Driver IC: SPFD54124A
Dot pixcel:128*160
Manufacture: 中航华天
Index:HTB180ML-B
** Current Ver: 1.0
** Author: Huangfusheng
** DATE: 10/24/2007
** Note:
** 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 SPFD54124B_ZH_WIDTH 128//176
#define SPFD54124B_ZH_HEIGHT 160//220
#define MP4_MAX_WIDTH 176
#define MP4_MAX_HEIGHT 144
#define OFFSET_X 0
#define LCD_USE_DMA
//Qlw 2006/11/21
extern int LCD_GetRefreshFlag (void);
extern uint32 udisk_plugin;
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 SPFD54124B_ZH_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 SPFD54124B_ZH_Close(void);
/******************************************************************************/
// Description: Enter/Exit sleep mode .
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E SPFD54124B_ZH_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 SPFD54124B_ZH_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 SPFD54124B_ZH_GetMainLcdSpec(
LCD_SPEC_T *spec_ptr //spec struct pointer
);
/*********************************************************************/
// Description: Initialize color LCD : SPFD54124B_ZH
// Input:
// None.
// Return:
// None.
// Note:
/*********************************************************************/
LOCAL ERR_LCD_E SPFD54124B_ZH_Init(void);
/******************************************************************************/
// Description: invalidate a rectang of in LCD
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E SPFD54124B_ZH_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 SPFD54124B_ZH_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 SPFD54124B_ZH_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 SPFD54124B_ZH_GoSleep(void);
/******************************************************************************/
// Description: LCD exit sleep mode
// Author: Yingchun.li
// Note:
/******************************************************************************/
LOCAL SPFD54124B_ZH_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 SPFD54124B_ZH_SEND_COMMAND( c) {*(volatile uint16 *)0x58000000 = c;}
#define SPFD54124B_ZH_SEND_DATA(d) {*(volatile uint16 *)0x58020000 = d;}
//#define SPFD54124B_ZH_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58020000 = data;}
/******************************************************************************/
// Description: Set the windows address to display, in this windows
// color is refreshed.
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
__inline void SPFD54124B_ZH_set_display_window(
uint8 left, // start Horizon address
uint8 top, // start Vertical address
uint8 right, // end Horizon address
uint8 bottom // end Vertical address
)
{
uint16 address = 0;
SPFD54124B_ZH_SEND_COMMAND(0x2A); // set colomn address
address = left >> 8;
SPFD54124B_ZH_SEND_DATA(address);
address = left;
SPFD54124B_ZH_SEND_DATA(address);
address = right >> 8;
SPFD54124B_ZH_SEND_DATA(address);
address = right;
SPFD54124B_ZH_SEND_DATA(address);
SPFD54124B_ZH_SEND_COMMAND(0x2B); // set Row address
address = top >> 8;
SPFD54124B_ZH_SEND_DATA(address);
address = top;
SPFD54124B_ZH_SEND_DATA(address);
address = bottom>>8;
SPFD54124B_ZH_SEND_DATA(address);
address = bottom;
SPFD54124B_ZH_SEND_DATA(address);
SPFD54124B_ZH_SEND_COMMAND(0x2C);
Delayms(1);
}
LOCAL void SPFD54124B_ZH_reset(void)
{
uint16 lcm_nv = REFPARAM_GetLCDType();
switch(lcm_nv)
{
case TFT_SPFD54124B_Zhonghang:
{
#if 0
SCI_TRACE_LOW("SPFD54124B_ZH_reset: 7370 GG3728 SPFD54124B_ZH/HYDIS.");
SPFD54124B_ZH_SEND_COMMAND(0x01); //software reset
Delayms(10); // delay10ms
SPFD54124B_ZH_SEND_COMMAND(0x11); //sleep out/power on(SLPOUT)
Delayms(50); // delay50ms
SPFD54124B_ZH_SEND_COMMAND(0x20);
SPFD54124B_ZH_SEND_COMMAND(0x38);
SPFD54124B_ZH_SEND_COMMAND(0x13);
SPFD54124B_ZH_SEND_COMMAND(0x3a);
SPFD54124B_ZH_SEND_DATA(0x05);
SPFD54124B_ZH_SEND_COMMAND(0xb4);
SPFD54124B_ZH_SEND_DATA(0x02);
SPFD54124B_ZH_SEND_COMMAND(0xc0); //power control 1 (PWCTR1)
SPFD54124B_ZH_SEND_DATA(0x03); //default value LCM=0 set t)e GVDD voltage=4.65
Delayms(10);
SPFD54124B_ZH_SEND_COMMAND(0xc5);
SPFD54124B_ZH_SEND_DATA(0xc8); //VCOM) voltage set 4.300V AGO IS C8H
Delayms(10);
SPFD54124B_ZH_SEND_COMMAND(0xc6);
SPFD54124B_ZH_SEND_DATA(0x1f); //VCOMAC voltage set 5.550V // AGO IS 1FH
Delayms(10);
SPFD54124B_ZH_SEND_COMMAND(0xe0); //Gamma + Polarity correction c)aracteristics set
SPFD54124B_ZH_SEND_DATA(0x00); //Gamma V1= V0=
SPFD54124B_ZH_SEND_DATA(0x10); //Gamma V3= V2=
SPFD54124B_ZH_SEND_DATA(0x52); //Gamma V5= V4=
SPFD54124B_ZH_SEND_DATA(0x53); //Gamma V7= V6=
SPFD54124B_ZH_SEND_DATA(0x55); //Gamma V9= V8=
SPFD54124B_ZH_SEND_DATA(0x55); //Gamma V11= V10=
SPFD54124B_ZH_SEND_DATA(0x37); //Gamma V13= V12=
SPFD54124B_ZH_SEND_COMMAND(0xfe);
SPFD54124B_ZH_SEND_DATA(0x00);
Delayms(10);
SPFD54124B_ZH_SEND_COMMAND(0x36); //memory data access control (MADCTR)
SPFD54124B_ZH_SEND_DATA(0x00); //MY=0// MX=0// MV=0// ML=1// RGB=0
SPFD54124B_ZH_SEND_COMMAND(0x29); //display on
#else
//-------Sleep out-------------------
SPFD54124B_ZH_SEND_COMMAND(0x0011); //sleep out/power on(SLPOUT)
Delayms(50); // delay50ms
//--------Interface pixel format,16bit/pixel----
SPFD54124B_ZH_SEND_COMMAND(0x003a); //power control 1 (PWCTR1)
SPFD54124B_ZH_SEND_DATA(0x0005); //default value LCM=0 set t)e GVDD voltage=4.65
//--------Memory data control-----------
SPFD54124B_ZH_SEND_COMMAND(0x0036);
SPFD54124B_ZH_SEND_DATA(0x00c8);
//---------Power setting-----------------
SPFD54124B_ZH_SEND_COMMAND(0x00c0);
SPFD54124B_ZH_SEND_DATA(0x0003);
SPFD54124B_ZH_SEND_DATA(0x0005);
SPFD54124B_ZH_SEND_COMMAND(0x00c5);
SPFD54124B_ZH_SEND_DATA(0x00c3);
SPFD54124B_ZH_SEND_COMMAND(0x00c6);
SPFD54124B_ZH_SEND_DATA(0x000a);
//----------gamma setting-------------
SPFD54124B_ZH_SEND_COMMAND(0x00e0); //Gamma + Polarity correction c)aracteristics set
SPFD54124B_ZH_SEND_DATA(0x0010); //Gamma V1= V0=
SPFD54124B_ZH_SEND_DATA(0x0011); //Gamma V3= V2=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -