?? cstn_nt7526.c
字號:
/********************************************************************************
** File Name: cstn_nt7526.c *
** Description: *
** This file contains driver for NT7526(cstn). *
** Author: David.Jia *
** DATE: 09/02/2005 *
** Copyright: 2005 Spreatrum, Incoporated. All Rights Reserved. *
** Description: *
** Copy from oled_NT7526.c. * *
********************************************************************************
********************************************************************************
** Edit History *
** ----------------------------------------------------------------------------*
** DATE NAME DESCRIPTION *
** 09/02/2005 David.Jia Create. *
********************************************************************************/
#include "os_api.h"
#include "sci_types.h"
//#include "lcd_api.h"
#include "gpio_api.h"
#include "lcd.h"
#include "sc6600d_reg.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**---------------------------------------------------------------------------*
** Macro Define
**---------------------------------------------------------------------------*/
#define NT7526_WIDTH 96
#define NT7526_HEIGHT 96
__inline static void Delayms(uint32 ms)
{
uint32 tick_old, tick_new;
tick_old = tick_new = SYSTEM_CURRENT_CLOCK;
while((tick_new-tick_old) < ms )
{
tick_new = SYSTEM_CURRENT_CLOCK;
}
}
//macro to read GRAM
//Read/Write NT7526
__inline void NT7526_Command(uint16 c)
{
*(volatile uint16 *)0x58010000 = c;
}
__inline void NT7526_Data(uint16 d)
{
*(volatile uint16 *)0x58018000 = d;
}
/**---------------------------------------------------------------------------*
** Function Definitions
**---------------------------------------------------------------------------*/
LOCAL ERR_LCD_E NT7526_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
);
void NT7526_Reset(void);
LOCAL ERR_LCD_E NT7526_Invalidate(void);
void NT7526_Close(void);
LOCAL ERR_LCD_E NT7526_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
);
void NT7526_Reset(void)
{
SCI_TRACE_LOW("NT7526_Reset");
NT7526_Command(0x0040);//ENTRY_MODE_SET
NT7526_Command(0x0080);//16B=1,MDI=0,MX=0,MY=0,XY=0,RMW=0
NT7526_Command(0x002C);//STANDBY_MODE_OFF
Delayms(20);//20ms
NT7526_Command(0x0002);//OSC_MODE_SET
NT7526_Command(0x0001);//Internal OSC ON
Delayms(20);//20ms
NT7526_Command(0x0020);//DC_DC_SELECT
NT7526_Command(0x0033);//2.0x
NT7526_Command(0x0022);//BIAS_SET
NT7526_Command(0x0033);//TFT_writec(0x02); //All Display Mode=1/6 Bias, -4x
NT7526_Command(0x0024);//DC_DC_CLK_DIV_SET
NT7526_Command(0x0004);//fOSC/16
//TFT_writec(0x24);//DC_DC_CLK_DIV_SET
//TFT_writec(0x00);//fOSC/8
NT7526_Command(0x0026);//DC_DC_AMP_SET
NT7526_Command(0x0001);//BT1 ON
Delayms(100);//20ms
NT7526_Command(0x0026);//DC_DC_AMP_SET
NT7526_Command(0x0009);//BT1,AMP ON
Delayms(100);//20ms
NT7526_Command(0x0026);//DC_DC_AMP_SET
NT7526_Command(0x000B);//BT1,BT2,AMP ON
Delayms(100);//100ms
NT7526_Command(0x0026);//DC_DC_AMP_SET
NT7526_Command(0x000F);//BT1,BT2,BT3,AMP ON
Delayms(100);
NT7526_Command(0x0028);//Temperature Compensation Set
NT7526_Command(0x0000);
NT7526_Command(0x0053);//Display Pattern Set
NT7526_Command(0x0000);//Normal Display
NT7526_Command(0x0010);//DRIVER_OUT_SET
NT7526_Command(0x0000);//SWP=0,CDR=0;
NT7526_Command(0x0030);//Row Vector Mode Set
NT7526_Command(0x000a);//INC=1, Every subframe
NT7526_Command(0x0032);//N_LINEE_INVERSION
NT7526_Command(0x0002);//FIM=1, N-block=13
//NT7526_Command(0x0040);//ADDR_MODE_SET
//NT7526_Command(0x0088);//No dummy subgroup
NT7526_Command(0x0043);//X_ADDR_AREA_SET
NT7526_Command(0x0000);
NT7526_Command(0x005F);
NT7526_Command(0x0042);//Y_ADDR_AREA_SET
NT7526_Command(0x0000);
NT7526_Command(0x005F);
NT7526_Command(0x0034);//N-block Inversion Set
NT7526_Command(0x008f);//Every 15 block and every frame
NT7526_Command(0x002A);//CONTRAST_CONTROL
NT7526_Command(0x0082);//TFT_writec(0x20);
NT7526_Command(0x002B);//CONTRAST_CONTROL2
NT7526_Command(0x0010);
NT7526_Command(0x0055);//Partial Display Mode Set
NT7526_Command(0x0000);//Normal Mode Display Duty Ratio 1/96
NT7526_Command(0x0018);//Monitor Signal Control
NT7526_Command(0x000f);//FR, CL, PM, SYNC head of 1st subframe
Delayms(100);
NT7526_Command(0x0051);//DISPLAY_ON
Delayms(100);
}
LOCAL void NT7526_Clear(
uint32 color //color to fill the whole lcd.
)
{
int i, j;
SCI_TRACE_LOW("NT7526_Clear");
NT7526_SetDisplayWindow(0, 0, NT7526_WIDTH-1, NT7526_HEIGHT-1);
for (i = 0; i < NT7526_HEIGHT; i++)
{
for (j = 0; j < NT7526_WIDTH; j++)
{
NT7526_Data(color);
}
}
}
LOCAL ERR_LCD_E NT7526_Invalidate(void)
{
int16 x = 0, y = 0;
const uint16 *buf = NULL;
uint8 lcd_mode = 0;
SCI_TRACE_LOW("NT7526_Invalidate.");
if (LCD_GetRefreshFlag() != TRUE )
{
return ERR_LCD_OPERATE_FAIL ;
}
lcd_mode = w99685CMD_GetLCMControlMode();
if( 1 == lcd_mode )
{
//W99685CMD_SetLCMControlMode(0);
return ERR_LCD_NONE;
}
buf = (uint16 *)LCD_GetSubLCDBuffer();
NT7526_SetDisplayWindow(0, 0, NT7526_WIDTH-1, NT7526_HEIGHT-1);
for (y = 0; y < NT7526_HEIGHT ; y++)
{
for (x = 0; x < NT7526_WIDTH; x++)
{
NT7526_Data(buf[y*NT7526_WIDTH + x]);
}
}
if( 1 == lcd_mode )
{
W99685CMD_SetLCMControlMode(0);
}
return ERR_LCD_NONE;
}
void NT7526_Close(void)
{
SCI_TRACE_LOW("NT7526_Close");
NT7526_Command(0x2D); //Standby ON
NT7526_Command(0x50); //Display OFF
NT7526_Command(0x26); //DCDC3 OFF
NT7526_Command(0x0B);
NT7526_Command(0x26); //DCDC2 OFF
NT7526_Command(0x09);
NT7526_Command(0x26); //AMP OFF
NT7526_Command(0x01);
NT7526_Command(0x26); //DCDC1 OFF
NT7526_Command(0x00);
Delayms(300);
}
LOCAL ERR_LCD_E NT7526_EnterSleep(
BOOLEAN is_sleep //SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode.
)
{
SCI_TRACE_LOW("NT7526_EnterSleep,%d", is_sleep);
if (is_sleep) //enter sleep mode
{
NT7526_Command(0x2D); //Standby Mode ON
}
else //sleep mode release
{
NT7526_Command(0x2C); //Standby Mode OFF
Delayms(100);
NT7526_Command(0x51); //Display ON
}
return ERR_LCD_NONE;
}
/*****************************************************************************/
// Description: Enable lcd to partial display mode, so can save power.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -