📄 cstn_ssd1784.c
字号:
/********************************************************************************
**********************************************************************************
** Copyright: 上海闻泰电子第一产品部
** All Rights Reserved.
** Project Name: W180
** File Name: cstn_ssd1784.c
** Description: This file contains driver for color LCD.
LCD type : CSTN
Driver IC: ssd1784
Dot pixcel:128*160
Menufacture: 力科达有限公司
** Current Ver: 1.0
** Author: Huangfusheng
** DATE: 09/11/2007
** Modify: ***
** Note: Mp4 is not OK
** Displace Ver: ***
** 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 SSD1784_WIDTH 128//176
#define SSD1784_HEIGHT 160//220
#define MP4_MAX_WIDTH 176
#define MP4_MAX_HEIGHT 144
#define OFFSET_X 0
//@David.Jia 2005.11.22
#define ADC_SSD1784_LOW 231
#define ADC_SSD1784_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 SSD1784_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 SSD1784_Close(void);
/******************************************************************************/
// Description: Enter/Exit sleep mode .
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E SSD1784_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 SSD1784_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 SSD1784_GetMainLcdSpec(
LCD_SPEC_T *spec_ptr //spec struct pointer
);
/*********************************************************************/
// Description: Initialize color LCD : SSD1784
// Input:
// None.
// Return:
// None.
// Note:
/*********************************************************************/
LOCAL ERR_LCD_E SSD1784_Init(void);
/******************************************************************************/
// Description: invalidate a rectang of in LCD
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E SSD1784_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 SSD1784_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 SSD1784_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 SSD1784_GoSleep(void);
/******************************************************************************/
// Description: LCD exit sleep mode
// Author: Yingchun.li
// Note:
/******************************************************************************/
LOCAL SSD1784_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 SSD1784_SEND_COMMAND( c) {*(volatile uint16 *)0x58000000 = c;}
#define SSD1784_SEND_DATA(d) {*(volatile uint16 *)0x58020000 = d;}
#define SSD1784_sendcommand1(command, data) {*(volatile uint16 *)0x58000000 = command;*(volatile uint16 *)0x58020000 = data;}
//LOCAL void SSD1784_HW_reset(void)
//{
// GPIO_SetLcdReset(0);
// Delayms(10);
// GPIO_SetLcdReset(1);
// Delayms(10);
//}
LOCAL void SSD1784_reset(void)
{
uint16 lcm_nv = REFPARAM_GetLCDType();
SCI_TRACE_LOW("SSD1784_reset: 7370 GG3728 SSD1784/HYDIS.");
switch(lcm_nv)
{
case CSTN_ssd1784:
{
SSD1784_SEND_COMMAND(0x94);
SSD1784_SEND_COMMAND(0xd1); // internal oscillator
SSD1784_sendcommand1(0xbb,0x01);
// set com direction
SSD1784_SEND_COMMAND(0xbc); /* set data out */
SSD1784_SEND_DATA(0x03); /* set x,y drection */
SSD1784_SEND_DATA(0x01); /* set RGB direction */
SSD1784_SEND_DATA(0x00); /* set 65K color */
SSD1784_SEND_COMMAND(0xf1); // set data out
SSD1784_SEND_DATA(0xe0); /* set seg drection */
SSD1784_SEND_DATA(0x00); /* set RGB direction */
SSD1784_SEND_DATA(0x00); /* set 65K color */
SSD1784_sendcommand1(0xca,0xff); /* display control / Set 160 Duty */
SSD1784_sendcommand1(0x27,0x00); //17
SSD1784_sendcommand1(0xab,0x00); /* set scroll start */
SSD1784_sendcommand1(0x20,0x0f); /* booster x7 */
SSD1784_SEND_COMMAND(0x81); /* set Vop */
SSD1784_SEND_DATA(0x20); /* set EVR VOP=16.5V */
SSD1784_SEND_DATA(0x05); /* set gain */
SSD1784_SEND_COMMAND(0xf4); /* set temperture */
SSD1784_SEND_DATA(0x08); /* TC=-0.03 */
SSD1784_SEND_DATA(0x00);
SSD1784_SEND_DATA(0x58);
SSD1784_SEND_DATA(0x03);
SSD1784_SEND_COMMAND(0xa7); /* normal display */
SSD1784_sendcommand1(0xfb,0x04);
SSD1784_SEND_COMMAND(0xf2); /* set frame frequency */
SSD1784_SEND_DATA(0x08); /* set 75 HZ */
SSD1784_SEND_DATA(0x4b); /* no Reset and 17-line counter per frame */
SSD1784_sendcommand1(0xf7,0x00); /* set PWM FRC */
SSD1784_sendcommand1(0x0e,0x05); /* Set 5 bits PWM + 1 bit FRC */
SSD1784_SEND_COMMAND(0xaf); /* display ON */
SSD1784_SEND_COMMAND(0x5c);
}
break;
default:
break;
}
}
/******************************************************************************/
// 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 SSD1784_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<(SSD1784_HEIGHT ); i++)
{
dma_request(0, (uint32)&fill_color, (uint32)(buf_ptr + i * SSD1784_WIDTH), SSD1784_WIDTH,
1, 1);
}
SSD1784_Invalidate();
}
/******************************************************************************/
// Description: Set the windows address to display, in this windows
// color is refreshed.
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
__inline void SSD1784_set_display_window(
uint8 left, // start Horizon address
uint8 top, // start Vertical address
uint8 right, // end Horizon address
uint8 bottom // end Vertical address
)
{
//Set column address(left - right)
SSD1784_SEND_COMMAND(0x15);
SSD1784_SEND_DATA(left+4);
SSD1784_SEND_DATA(right+4);
//Set page address(top - bottom)
SSD1784_SEND_COMMAND(0x75);
SSD1784_SEND_DATA(top);
SSD1784_SEND_DATA(bottom);
//Write display data
SSD1784_SEND_COMMAND(0x5C);
}
/******************************************************************************/
// Description: Set start RAM address which is write to AC(Address
// Counter) register.
// Input:
// left: start Horizon address of AC
// top: start Vertical address of AC.
// Return:
// None.
// Note:
/******************************************************************************/
__inline void SSD1784_set_start_address(
uint8 left,
uint8 top
)
{
//SSD1784_sendcommand1(0x15, left);
//SSD1784_sendcommand1(0x75, top);
}
/******************************************************************************/
// 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 SSD1784_Invalidate(void)
{
uint16 i,j;
//uint16 address = 0;
uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();
#ifdef LCD_USE_DMA
//uint32 dummy_before,dummy_after;
SSD1784_set_display_window(0, 0, SSD1784_WIDTH-1, SSD1784_HEIGHT-1);
// SSD1784_set_start_address(0, 0);
/*
address = (uint16) ( (((SSD1784_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X));
SSD1784_sendcommand1(0x44, address); // set horizon address
address = (uint16) ( ((SSD1784_HEIGHT-1) & 0xFF) << 8 );
SSD1784_sendcommand1(0x45, address); // set vertical address
SSD1784_sendcommand1(0x0021, OFFSET_X);
*/
//SSD1784_SEND_COMMAND(0x0017); // send data.
//dummy_before = 1 % 4; // Inserted numbers befor every arrow.
//dummy_after = 3 - (SSD1784_WIDTH % 4); // Inserted numbers after every arrow.
for(j=0; j<(SSD1784_HEIGHT ); j++)
{
dma_request(0, (uint32)(buf_ptr + j * SSD1784_WIDTH), 0x58020000, SSD1784_WIDTH,
1, 0);
}
#else
SCI_TRACE_LOW("tft_SSD1784.c SSD1784_Invalidate line%d", __LINE__);
SSD1784_set_display_window(0, 0, SSD1784_WIDTH-1, SSD1784_HEIGHT-1);
//SSD1784_set_start_address(0, 0);
/*
address = (uint16) ( (((SSD1784_WIDTH - 1 + OFFSET_X) & 0xFF ) << 8 ) | (OFFSET_X));
SSD1784_sendcommand1(0x44, address); // set horizon address
address = (uint16) ( ((SSD1784_HEIGHT-1) & 0xFF) << 8 );
SSD1784_sendcommand1(0x45, address); // set vertical address
SSD1784_sendcommand1(0x0021, OFFSET_X);
*/
//SSD1784_SEND_COMMAND(0x0017); // send data.
for(i=0; i<(SSD1784_WIDTH * SSD1784_HEIGHT); i++)
SSD1784_SEND_DATA( *buf_ptr++ );
#endif
return ERR_LCD_NONE;
}
/*****************************************************************************/
// Description: Get the lcd base information..
// Global resource dependence:
// Author: louis.wei
// Note:
/*****************************************************************************/
LOCAL ERR_LCD_E SSD1784_GetInfo(
LCD_INFO_T *lcd_info_ptr //lcd information struct pointer
)
{
if ( PNULL == lcd_info_ptr )
{
return ERR_LCD_POINTER_NULL;
}
lcd_info_ptr->r_bitmask = 0xf800;
lcd_info_ptr->g_bitmask = 0x07e0;
lcd_info_ptr->b_bitmask = 0x001f;
lcd_info_ptr->bits_per_pixel = 16;
lcd_info_ptr->contrast_min = 0x00;
lcd_info_ptr->contrast_max = 63;
lcd_info_ptr->contrast_defaut = 0x0A;
lcd_info_ptr->lcd_width = SSD1784_WIDTH;
lcd_info_ptr->lcd_height = SSD1784_HEIGHT;
lcd_info_ptr->lcdbuff_ptr = (void *)LCD_GetLCDBuffer();
return ERR_LCD_NONE;
}
/******************************************************************************/
// 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.
// modify: jim.cui 2005.0728 use dma to transport data
/******************************************************************************/
LOCAL ERR_LCD_E SSD1784_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
)
{
uint32 i, j;
uint32 dummy_before, dummy_after;
uint32 row, column,rect_width;
uint16 *buf_ptr = (uint16 *)LCD_GetLCDBuffer();
//****************************************************
//**********解决进入摄像模式的问题*******************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -