📄 cstn_s1d15g24.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.
******************************************************************************/
#include "os_api.h"
#include "sci_types.h"
//#include "lcd_api.h"
#include "gpio_api.h"
#include "lcd.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**---------------------------------------------------------------------------*
** Macro Define
**---------------------------------------------------------------------------*/
#define S1D15G24_WIDTH 96
#define S1D15G24_HEIGHT 96
LOCAL ERR_LCD_E S1D15G24_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
);
LOCAL ERR_LCD_E S1D15G24_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 *lcd_buf,
uint8 is_invert
);
void S1D15G24_Reset(void);
LOCAL ERR_LCD_E S1D15G24_Invalidate(void);
void S1D15G24_Close(void);
#define S1D15G24_Command( cmd ) {*(volatile uint16 *)0x58010000 = cmd;}
#define S1D15G24_Data( dat ) {*(volatile uint16 *)0x58018000 = dat;}
void S1D15G24_Reset(void)
{
/*------enable interal oscillator--------*/
S1D15G24_Command(0x00);
S1D15G24_Command(0x01);
Delayms(200);
S1D15G24_Command(0xBE);
S1D15G24_Data(0x3A); //3A /*bias set :1/7*/
Delayms(200);
/*------set power control register-------*/
S1D15G24_Command(0xB6);
S1D15G24_Data(0x80); //0X6A
S1D15G24_Data(0x0B); //0X09
S1D15G24_Data(0x06);//0X02
S1D15G24_Data(0x68);
S1D15G24_Data(0x00);
S1D15G24_Data(0x00);
Delayms(200);
S1D15G24_Command(0xBA);
S1D15G24_Data(0x6F);//0X5A
S1D15G24_Data(0x00); //0X5A
/*----set contrast level & interal regulator----*/
S1D15G24_Command(0xBB);
S1D15G24_Data(0x03);//0X03 /*contrast : 0x00~0x3f */
/*-----set com output scan direction-------*/
S1D15G24_Command(0x25);
S1D15G24_Data(0x4a); //
S1D15G24_Command(0x13);
S1D15G24_Command(0x36);
S1D15G24_Data(0x90);
/*--------set data out direction-----------*/
S1D15G24_Command(0x2B);
S1D15G24_Data(0x00);
S1D15G24_Data(0x5F);
/*-----------set display control-------------*/
S1D15G24_Command(0x2A);
S1D15G24_Data(0x00);
S1D15G24_Data(0x5f);
S1D15G24_Data(0x00);
S1D15G24_Data(0x00);
/*----------set frame frequency-------------*/
S1D15G24_Command(0x11);
S1D15G24_Command(0x29);
S1D15G24_Command(0xB7);
S1D15G24_Data(0x00); /*frame frequency*/
S1D15G24_Command(0x2C); /*N_Line inversion : 0x01~0x1f*/
}
LOCAL void S1D15G24_Clear(
uint32 color //color to fill the whole lcd.
)
{
uint32 i;
uint16 *buf_ptr = (uint16 *)LCD_GetSubLCDBuffer();
for( i=0; i<(S1D15G24_HEIGHT * S1D15G24_WIDTH); i++)
{
*buf_ptr++ = color;
}
}
LOCAL ERR_LCD_E S1D15G24_Invalidate(void)
{
uint32 i,k;
uint16 *buf_ptr = (uint16 *)LCD_GetSubLCDBuffer();
uint16 color = 0x00;
//SCI_TRACE_LOW("#####################S1D15G24_InvalidateRect#############################");
/*-------set display area-----------*/
S1D15G24_Command(0x2A); //coladd : 0x02~0x31
S1D15G24_Data(0x00);
S1D15G24_Data(0x5f);
S1D15G24_Command(0x2B); //pagadd : 0x00~0x3f
S1D15G24_Data(0x00);
S1D15G24_Data(0x5f);
//command of write display data to sub lcd
S1D15G24_Command(0x2c);
for(i=0;i<S1D15G24_WIDTH*S1D15G24_HEIGHT;i++)
{
color = *buf_ptr++;
S1D15G24_Data((uint8)color>>8);
S1D15G24_Data((uint8)(color & 0x00FF));
}
return ERR_LCD_NONE;
}
void S1D15G24_Close(void)
{
S1D15G24_Command(0x28);
S1D15G24_Command(0x10);
Delayms(100);
}
LOCAL ERR_LCD_E S1D15G24_EnterSleep(
BOOLEAN is_sleep //SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode.
)
{
SCI_TRACE_LOW("S1D15G24_EnterSleep,%d", is_sleep);
if ( is_sleep ) // enter sleep mode.
{
S1D15G24_Command(0x28);
//Delayms(100);
S1D15G24_Command(0x10);
//Delayms(100);
}
else // out sleep mode
{
S1D15G24_Command(0x29);
//Delayms(100);
S1D15G24_Command(0x11);
//S1D15G24_Reset();
//S1D15G24_Invalidate();
}
return ERR_LCD_NONE;
}
/*****************************************************************************/
// Description: Enable lcd to partial display mode, so can save power.
// Global resource dependence:
// Author: Jim.zhang
// Return: SCI_TRUE:SUCCESS ,SCI_FALSE:failed.
// Note: If all input parameters are 0, exit partial display mode.
/*****************************************************************************/
LOCAL ERR_LCD_E S1D15G24_SetDisplayWindow(
uint16 left, //left of the window
uint16 top, //top of the window
uint16 right, //right of the window
uint16 bottom //bottom of the window
)
{
return ERR_LCD_FUNC_NOT_SUPPORT;
}
/******************************************************************************/
// Description: set the contrast value
// Global resource dependence:
// Author: Jim.zhang
// Note:
/******************************************************************************/
LOCAL ERR_LCD_E S1D15G24_SetContrast(
uint16 contrast //contrast value to set
)
{
return ERR_LCD_FUNC_NOT_SUPPORT;
}
/*****************************************************************************/
// Description: Get the lcd base information..
// Global resource dependence:
// Author: louis.wei
// Note:
/*****************************************************************************/
LOCAL ERR_LCD_E S1D15G24_GetInfo(
LCD_INFO_T *lcd_info_ptr //lcd information struct pointer
)
{
if ( PNULL == lcd_info_ptr )
{
return ERR_LCD_POINTER_NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -