📄 tft_hx8310.c
字号:
/******************************************************************************
** File Name: cstn_pcf8833.c *
** Description: *
** This file contains driver for color LCD.(CSTN) *
** Author: Jim zhang *
** DATE: 03/01/2004 *
** Copyright: 2004 Spreatrum, Incoporated. All Rights Reserved. *
** Description: *
******************************************************************************
******************************************************************************
** Edit History *
** ------------------------------------------------------------------------- *
** DATE NAME DESCRIPTION *
** 02/04/2004 louis.wei Create.
** 11/15/2005 David.Jia Modify for GG3728 (HX8310/HYDIS). *
** 11/22/2005 David.Jia Modify ADC value in Probe; Entersleep code*
** 12/09/2005 David.Jia Implemetation SetDisplayWindow function. *
** 12/26/2005 David.Jia Deal can't DC preview on HX8310 LCD. *
** 03/03/2006 David.Jia cr42033, LCD ADC range changed: HX8309, *
** 200-230; HX8310, 231-249; S1D19105, 250-280. *
******************************************************************************/
#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 HX8310_WIDTH 128//176
#define HX8310_HEIGHT 160//220
#define MP4_MAX_WIDTH 176
#define MP4_MAX_HEIGHT 144
#define OFFSET_X 0
//@David.Jia 2005.11.22
#define ADC_HX8310_LOW 231
#define ADC_HX8310_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 HX8310_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 HX8310_Close(void);
/******************************************************************************/
// Description: Enter/Exit sleep mode .
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E HX8310_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 HX8310_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 HX8310_GetMainLcdSpec(
LCD_SPEC_T *spec_ptr //spec struct pointer
);
/*********************************************************************/
// Description: Initialize color LCD : HX8310
// Input:
// None.
// Return:
// None.
// Note:
/*********************************************************************/
LOCAL ERR_LCD_E HX8310_Init(void);
/******************************************************************************/
// Description: invalidate a rectang of in LCD
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E HX8310_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 HX8310_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 HX8310_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 HX8310_GoSleep(void);
/******************************************************************************/
// Description: LCD exit sleep mode
// Author: Yingchun.li
// Note:
/******************************************************************************/
LOCAL HX8310_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 HX8310_SEND_COMMAND( c) {*(volatile uint16 *)0x58000000 = c;}
#define HX8310_SEND_DATA(d) {*(volatile uint16 *)0x58020000 = d;}
#define HX8310_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58020000 = data;}
//LOCAL void HX8310_HW_reset(void)
//{
// GPIO_SetLcdReset(0);
// Delayms(10);
// GPIO_SetLcdReset(1);
// Delayms(10);
//}
LOCAL void HX8310_reset(void)
{
SCI_TRACE_LOW("HX8310_reset: 7370 GG3728 HX8310/HYDIS.");
HX8310_sendcommand1(0x0057, 0x0200);
HX8310_sendcommand1(0x0000, 0x0001); // Start internal OSC.
HX8310_sendcommand1(0x0001, 0x0113); // set the display line number and display direction
HX8310_sendcommand1(0x0002, 0x0400); // set 1 line inversion
HX8310_sendcommand1(0x0005, 0x1030); // set GRAM write direction and BGR=1
HX8310_sendcommand1(0x0025, 0x0000); // set 18-bit mask register
HX8310_sendcommand1(0x0026, 0x0000); // set 18-bit mask register
HX8310_sendcommand1(0x0008, 0x0202); // set the back/front porch number
HX8310_sendcommand1(0x000A, 0x0000); // set the transfer interface and transfer number
HX8310_sendcommand1(0x000B, 0x0000); // set the equalized and delay period to save power
HX8310_sendcommand1(0x000C, 0x0000); // set internal reference voltage REGP=VCI=2.8V
HX8310_sendcommand1(0x000F, 0x0000); // Set Gate scan start address
HX8310_sendcommand1(0x0021, 0x0000); // set the writing start address of AC counter
HX8310_sendcommand1(0x0014, 0x9F00); // set the display area
HX8310_sendcommand1(0x0016, 0x7F00); // set the GRAM access area
HX8310_sendcommand1(0x0017, 0x9F00); // set the GRAM access area
Delayms (50);
HX8310_sendcommand1 (0x0003,0x0000);
Delayms (10);
HX8310_sendcommand1 (0x0009,0x0000);
Delayms (10);
HX8310_sendcommand1 (0x000D,0x0000);
Delayms (10);
HX8310_sendcommand1 (0x000E,0x0000);
Delayms (10);
//Please follow this power on sequence
HX8310_sendcommand1(0x0003, 0x0110); // enable charge-pump1 and VGH/VGL voltage
HX8310_sendcommand1(0x0009, 0x0006); // enable set the driving capability of source driver
Delayms(10); // Delay 10 ms
HX8310_sendcommand1(0x000D, 0x0013); // set voltage VGAM1OUT=VCI*1.65
Delayms(40);
HX8310_sendcommand1(0x000E, 0x301C); // set VCOMH and VCOM amplitude voltage
// ---------- Adjust the Gamma 2.2 Curve -------------------
HX8310_sendcommand1(0x0030, 0x0000);
HX8310_sendcommand1(0x0031, 0x0707);
HX8310_sendcommand1(0x0032, 0x0707);
HX8310_sendcommand1(0x0033, 0x0305);
HX8310_sendcommand1(0x0034, 0x0007);
HX8310_sendcommand1(0x0035, 0x0000);
HX8310_sendcommand1(0x0036, 0x0007);
HX8310_sendcommand1(0x0037, 0x0502);
HX8310_sendcommand1(0x003A, 0x1F00);
HX8310_sendcommand1(0x003B, 0x040F);
//Display ON
HX8310_sendcommand1 (0x0007,0x0005);
Delayms (30);
HX8310_sendcommand1 (0x0007,0x0025);
HX8310_sendcommand1 (0x0007,0x0027);
Delayms(30);
HX8310_sendcommand1 (0x0007,0x0037);
HX8310_sendcommand1 (0x0021,0x0000);
}
/******************************************************************************/
// 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 HX8310_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<(HX8310_HEIGHT ); i++)
{
dma_request(0, (uint32)&fill_color, (uint32)(buf_ptr + i * HX8310_WIDTH), HX8310_WIDTH,
1, 1);
}
HX8310_Invalidate();
}
/******************************************************************************/
// Description: invalidate a rectang of in LCD
// Global resource dependence:
// Author: Jim.zhang
// Note:
// modify: jim.cui 2005.0728 use dma to transport data
/******************************************************************************/
LOCAL ERR_LCD_E HX8310_Invalidate(void)
{
uint16 i,j;
uint16 address = 0;
uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();
#ifdef LCD_USE_DMA
uint32 dummy_before,dummy_after;
address = (uint16) ( (((HX8310_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X));
HX8310_sendcommand1(0x16, address); // set horizon address
address = (uint16) ( ((HX8310_HEIGHT-1) & 0xFF) << 8 );
HX8310_sendcommand1(0x17, address); // set vertical address
HX8310_sendcommand1(0x0021, OFFSET_X);
HX8310_SEND_COMMAND(0x0022); // send data.
dummy_before = 1 % 4; // Inserted numbers befor every arrow.
dummy_after = 3 - (HX8310_WIDTH % 4); // Inserted numbers after every arrow.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -