📄 hw_ili9320.c
字号:
/******************************************************************/
/* Copyright (C) 2007 ROCK-CHIPS FUZHOU . All Rights Reserved. */
/*******************************************************************
File : hw_Ili9320.c
Desc : Mcupanel型号的Mcu驱动
Author : nzy
Date :
Notes :
$Log :
*********************************************************************/
#include "hw_include.h"
#include "hwapi_Mcupanel.h"
#if((LCDPANEL == MCUIF_ILI9320_16B)||(LCDPANEL == MCUIF_ILI9320_18B))
/*---------------------------------------------------------
Name : Ili9320_PowerOnInit
Desc : Mcupanel上电初始化
Params:
Return:
Author: nzy
Date :
-----------------------------------------------------------*/
void Ili9320_PowerOnInit(void)
{
UINT32 i, j;
delay_nops(10);
// ---------- Start Initial Sequence ----------//
Mcupanel_RegSet(0x00, 0x0001); // Start internal OSC.
Mcupanel_RegSet(0x01, 0x0000); // set SS and SM bit
Mcupanel_RegSet(0x02, 0x0400); // set 1 line inversion
//竖屏
//Mcupanel_RegSet(0x01, 0x0100);
//Mcupanel_RegSet(0x03, 0x10B0);
//Mcupanel_RegSet(0x60, 0xA700);
Mcupanel_RegSet(0x03, 0x1098); // set GRAM write direction and BGR=1.
Mcupanel_RegSet(0x04, 0x0000); // Resize register
Mcupanel_RegSet(0x08, 0x0202); // set the back porch and front porch
Mcupanel_RegSet(0x09, 0x0000); // set non-display area refresh cycle ISC[3:0]
Mcupanel_RegSet(0x0A, 0x0000); // FMARK function
Mcupanel_RegSet(0x0C, 0x0000); // RGB interface setting
Mcupanel_RegSet(0x0D, 0x0000); // Frame marker Position
Mcupanel_RegSet(0x0F, 0x0000); // RGB interface polarity
// ---------- Power On Sequence ----------//
Mcupanel_RegSet(0x10, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
Mcupanel_RegSet(0x11, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
Mcupanel_RegSet(0x12, 0x0000); // VREG1OUT voltage
Mcupanel_RegSet(0x13, 0x0000); // VDV[4:0] for VCOM amplitude
delay_nops(50);
Mcupanel_RegSet(0x10, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
Mcupanel_RegSet(0x11, 0x0001); // DC1[2:0], DC0[2:0], VC[2:0]
delay_nops(50);
Mcupanel_RegSet(0x12, 0x013C); // VREG1OUT voltage
delay_nops(50);
Mcupanel_RegSet(0x13, 0x1600); // VDV[4:0] for VCOM amplitude
Mcupanel_RegSet(0x29, 0x0012); // VCM[4:0] for VCOMH
delay_nops(50);
Mcupanel_RegSet(0x20, 0x0000); // GRAM horizontal Address
Mcupanel_RegSet(0x21, 0x0000); // GRAM Vertical Address
Mcupanel_RegSet(0x2B, 0x0020); // Frame Rate and Color Control-----16M_EN, Dither, FR_SEL[1:0]
// ---------- Gamma Control ---------- //
Mcupanel_RegSet(0x30, 0x0000);
Mcupanel_RegSet(0x31, 0x0306);
Mcupanel_RegSet(0x32, 0x0200);
Mcupanel_RegSet(0x35, 0x0107);
Mcupanel_RegSet(0x36, 0x0404);
Mcupanel_RegSet(0x37, 0x0606);
Mcupanel_RegSet(0x38, 0x0105);
Mcupanel_RegSet(0x39, 0x0707);
Mcupanel_RegSet(0x3C, 0x0600);
Mcupanel_RegSet(0x3D, 0x0807);
// ---------- Window Address Area ---------- //
Mcupanel_RegSet(0x50, 0x0000); // Horizontal GRAM Start Address-----HSA[7:0]
Mcupanel_RegSet(0x51, 0x00EF); // Horizontal GRAM End Address-----HEA[7:0]
Mcupanel_RegSet(0x52, 0x0000); // Vertical GRAM Start Address-----VSA[8:0]
Mcupanel_RegSet(0x53, 0x013F); // Vertical GRAM Start Address-----VEA[8:0]
// ---------- Gate Scan Control ---------- //
Mcupanel_RegSet(0x60, 0xA700); // GS, NL[5:0], SCN[5:0]
Mcupanel_RegSet(0x61, 0x0001); // NDL,VLE, REV
Mcupanel_RegSet(0x6A, 0x0000); // VL[8:0]
// ---------- Partial Display Control ---------- //
Mcupanel_RegSet(0x80, 0x0000); // Partial Image 1 Display Position-----PTDP0[8:0]
Mcupanel_RegSet(0x81, 0x0000); // Partial Image 1 Start Address-----PTSA0[8:0]
Mcupanel_RegSet(0x82, 0x0000); // Partial Image 1 End Address-----PTEA0[8:0]
Mcupanel_RegSet(0x83, 0x0000); // Partial Image 2 Display Position-----PTDP1[8:0]
Mcupanel_RegSet(0x84, 0x0000); // Partial Image 2 Start Address-----PTSA1[8:0]
Mcupanel_RegSet(0x85, 0x0000); // Partial Image 2 Start Address-----PTEA1[8:0]
// ---------- Panel Interface Control ---------- //
Mcupanel_RegSet(0x90, 0x0013); // Panel Interface Control 1-----DIVI[1:0], RTNI[4:0]
Mcupanel_RegSet(0x92, 0x0000); // Panel Interface Control 2-----NOWI[2:0]
Mcupanel_RegSet(0x93, 0x0003); // Panel Interface Control 3-----MCPI[2:0]
Mcupanel_RegSet(0x95, 0x0110); // Panel Interface Control 4-----DIVE[1:0], RTNE[5:0]
Mcupanel_RegSet(0x97, 0x0000); // Panel Interface Control 5-----NOWE[3:0]
Mcupanel_RegSet(0x98, 0x0000); // Panel Interface Control 6-----MCPE[2:0]
Mcupanel_RegSet(0x07, 0x0001); // Display Control 1
delay_nops(50);
Mcupanel_RegSet(0x07, 0x0021); // Display Control 1
Mcupanel_RegSet(0x07, 0x0023); // Display Control 1
delay_nops(50);
Mcupanel_RegSet(0x07, 0x0173); // Display Control 1-----262K color and display on
Mcupanel_RegSet(0x20, 0) ;
Mcupanel_RegSet(0x21, 0) ;
Mcupanel_Command(0x22);
// ---------- Tested throught displaying black ---------- //
#if 1
for (j = 0;j < 240;j++)
for (i = 0;i < 320;i++)
Mcupanel_Data(0x000000);
#endif
}
/*---------------------------------------------------------
Name : Ili9320_Standby
Desc : Mcupanel的StandBy模式设置
Params: NORMAL -> 恢复正常模式
STANDBY -> 设置为StandBy模式
Return:
Author: nzy
Date :
-----------------------------------------------------------*/
void Ili9320_Standby(MCULCDSTATUS Enable)
{
if (Enable == MCU_STANDBY)//Standby mode
{
Mcupanel_RegSet(0x07, 0x0032);
delay_nops(6);
Mcupanel_RegSet(0x07, 0x0000);
delay_nops(6);
Mcupanel_RegSet(0x10, 0x0000);
Mcupanel_RegSet(0x12, 0x0000);
Mcupanel_RegSet(0x10, 0x0002);
}
else//Return normal
{
Mcupanel_RegSet(0x10, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
Mcupanel_RegSet(0x11, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
Mcupanel_RegSet(0x12, 0x0000); // VREG1OUT voltage
Mcupanel_RegSet(0x13, 0x0000); // VDV[4:0] for VCOM amplitude
delay_nops(50);
Mcupanel_RegSet(0x10, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
Mcupanel_RegSet(0x11, 0x0001); // DC1[2:0], DC0[2:0], VC[2:0]
delay_nops(50);
Mcupanel_RegSet(0x12, 0x013C); // VREG1OUT voltage
delay_nops(50);
Mcupanel_RegSet(0x13, 0x1600); // VDV[4:0] for VCOM amplitude
Mcupanel_RegSet(0x29, 0x0012); // VCM[4:0] for VCOMH
delay_nops(50);
Mcupanel_RegSet(0x20, 0x0000); // GRAM horizontal Address
Mcupanel_RegSet(0x21, 0x0000); // GRAM Vertical Address
Mcupanel_RegSet(0x2B, 0x0020); // Frame Rate and Color Control-----16M_EN, Dither, FR_SEL[1:0]
Mcupanel_RegSet(0x07, 0x0001); // Display Control 1
delay_nops(50);
Mcupanel_RegSet(0x07, 0x0021); // Display Control 1
Mcupanel_RegSet(0x07, 0x0023); // Display Control 1
delay_nops(50);
Mcupanel_RegSet(0x07, 0x0173); // Display Control 1-----262K color and display on
Mcupanel_RegSet(0x20, 0) ;
Mcupanel_RegSet(0x21, 0) ;
Mcupanel_Command(0x22);
}
}
/*---------------------------------------------------------
Name : Ili9320_ScanDirSet
Desc : Mcupanel扫描方向设置
Params: XSize -> X方向的宽度
YSize -> Y方向的高度
Return:
Author: nzy
Date :
-----------------------------------------------------------*/
void Ili9320_ScanDirSet(UINT16 XSize, UINT16 YSize)
{
if (XSize > YSize)
{
Mcupanel_RegSet(0x03, 0x1098);
delay_nops(50);
Mcupanel_RegSet(0x60, 0xA700);
}
else
{
Mcupanel_RegSet(0x03, 0x10A0);
delay_nops(50);
Mcupanel_RegSet(0x60, 0x2700);
}
Mcupanel_RegSet(0x20, 0) ;
Mcupanel_RegSet(0x21, 0) ;
Mcupanel_Command(0x22);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -