Chinaunix首页 | 论坛 | 博客
  • 博客访问: 236459
  • 博文数量: 63
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 16
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-29 21:37
文章分类

全部博文(63)

文章存档

2017年(3)

2016年(3)

2014年(57)

我的朋友

分类:

2014-06-22 19:11:43

原文地址:ILI9326初始化代码 作者:gubo178

#include "system.h"
#include "altera_avalon_pio_regs.h"
#include "alt_types.h"
 
    int ILI9326_init(void){
       
    //Start Initial Sequence
    LCD_CtrlWrite_ILI9326(0x0702, 0x3008);
    LCD_CtrlWrite_ILI9326(0x0705, 0x0036); 
    LCD_CtrlWrite_ILI9326(0x070B, 0x1213); 
 
    LCD_CtrlWrite_ILI9326(0x0001, 0x0100); // set SS and SM bit
    LCD_CtrlWrite_ILI9326(0x0002, 0x0100); // set 1 line inversion
    LCD_CtrlWrite_ILI9326(0x0003, 0x1030); // set GRAM write direction and BGR=1.

   
    LCD_CtrlWrite_ILI9326(0x0008, 0x0202); // set the back porch and front porch
    LCD_CtrlWrite_ILI9326(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
    LCD_CtrlWrite_ILI9326(0x000A, 0x0000); // FMARK function
    LCD_CtrlWrite_ILI9326(0x000C, 0x0000); // RGB interface setting
    LCD_CtrlWrite_ILI9326(0x000D, 0x0000); // Frame marker Position
    LCD_CtrlWrite_ILI9326(0x000F, 0x0000); // RGB interface polarity
    //Power On sequence
   
    LCD_CtrlWrite_ILI9326(0x0100, 0x0000); // // SAP, BT[3:0], AP, DSTB, SLP, STB
    LCD_CtrlWrite_ILI9326(0x0102, 0x0000); // VREG1OUT voltage
    LCD_CtrlWrite_ILI9326(0x0103, 0x0000); // VDV[4:0] for VCOM amplitude
    Delayms(200); // Delay 50ms
    LCD_CtrlWrite_ILI9326(0x0100, 0x1190); // // SAP, BT[3:0], AP, DSTB, SLP, STB,0x1190
    LCD_CtrlWrite_ILI9326(0x0101, 0x0005); // DC1[2:0], DC0[2:0], VC[2:0]//0x0227
    Delayms(60);
    LCD_CtrlWrite_ILI9326(0x0102, 0x01b8); // VREG1OUT voltage
    Delayms(60);
    LCD_CtrlWrite_ILI9326(0x0103, 0x3600); //DV[4:0] for VCOM amplitude
    LCD_CtrlWrite_ILI9326(0x0281, 0x0001); // VCM[5:0] for VCOMH
    Delayms(50);
    LCD_CtrlWrite_ILI9326(0x0200, 0x0000); // GRAM horizontal Address
    
    LCD_CtrlWrite_ILI9326(0x0201, 0x0000); //GRAM horizontal Address
    //Adjust the Gamma Curve
   
    LCD_CtrlWrite_ILI9326(0x0300, 0x0101);//
    LCD_CtrlWrite_ILI9326(0x0301, 0x0506);//
    LCD_CtrlWrite_ILI9326(0x0302, 0x0405);//
   
    LCD_CtrlWrite_ILI9326(0x0305, 0x0007);//
   
    LCD_CtrlWrite_ILI9326(0x0306, 0x0008);//
   
    LCD_CtrlWrite_ILI9326(0x0307, 0x0203);//
    LCD_CtrlWrite_ILI9326(0x0308, 0x0102);//
    LCD_CtrlWrite_ILI9326(0x0309, 0x0706);//
   
    LCD_CtrlWrite_ILI9326(0x030C, 0x0700);//
   
    LCD_CtrlWrite_ILI9326(0x030D, 0x0008);//
   
     
    //Set GRAM area
    LCD_CtrlWrite_ILI9326(0x0210, 0x0000); // Horizontal GRAM Start Address
    LCD_CtrlWrite_ILI9326(0x0211, 0x00EF); // Horizontal GRAM End Address
    LCD_CtrlWrite_ILI9326(0x0212, 0x0000); // Vertical GRAM Start Address
    LCD_CtrlWrite_ILI9326(0x0213, 0x018F); // Vertical GRAM Start Address
    LCD_CtrlWrite_ILI9326(0x0400, 0x3100); // Gate Scan Line
    LCD_CtrlWrite_ILI9326(0x0401, 0x0001); // NDL,VLE, REV
    LCD_CtrlWrite_ILI9326(0x0404, 0x0000); // set scrolling line
    //Partial Display Control
    LCD_CtrlWrite_ILI9326(0x0500, 0x0000);
    LCD_CtrlWrite_ILI9326(0x0501, 0x0000);
    LCD_CtrlWrite_ILI9326(0x0502, 0x0000);
    LCD_CtrlWrite_ILI9326(0x0503, 0x0000);
    LCD_CtrlWrite_ILI9326(0x0504, 0x0000);
    LCD_CtrlWrite_ILI9326(0x0505, 0x0000);
    //Panel Control
    LCD_CtrlWrite_ILI9326(0x0010, 0x0010);
    LCD_CtrlWrite_ILI9326(0x0011, 0x0600);
    LCD_CtrlWrite_ILI9326(0x0020, 0x0002);
    
    LCD_CtrlWrite_ILI9326(0x0007, 0x0173); // 262K color and display ON
    LCD_WRITE_CMD(0x0202);
    }
/********************************************************************************
  DESCRIPTION:
 LCM display window setting.
  PARAMETERS:
 xs: Horizontal Address Start Position
 xe: Horizontal Address End Position
 ys: Vertical Address Start Position
 ye: Vertical Address End Position
  RETURNS:
  REMARKS:
*********************************************************************************/
void LCD_set_Window_ILI9326(int xs,int xe,int ys,int ye)
{
 LCD_CtrlWrite_ILI9326(0x0210,xs);
 LCD_CtrlWrite_ILI9326(0x0211,xe);
 LCD_CtrlWrite_ILI9326(0x0212,ys);
 LCD_CtrlWrite_ILI9326(0x0213,ye); 
 LCD_CtrlWrite_ILI9326(0x0200,xs);
 LCD_CtrlWrite_ILI9326(0x0201,ys); 
 LCD_WRITE_CMD(0x0202); 
}
 
/********************************************************************************
  DESCRIPTION:
 LCM enter_sleep_mode sequence.
  PARAMETERS:
  RETURNS:
  REMARKS:
*********************************************************************************/  
void LCD_EnterSleep_lil9326(void)
{
 LCD_CtrlWrite_ILI9326(0x0007,0x0132);//set GON=1,DTE=1,D[1:0]=10
 delayms(20);
 LCD_CtrlWrite_ILI9326(0x0007,0x0122);//set GON=1,DTE=0,D1=1,D0=0
 delayms(20);
 LCD_CtrlWrite_ILI9326(0x0007,0x0000);//displayoff 
 //power off sequence
 LCD_CtrlWrite_ILI9326(0x0100,0x0000);//SAP,BT[3:0],AP,DSTB,SLP,STB
 LCD_CtrlWrite_ILI9326(0x0101,0x0000);//DC1[2:0],DC0[2:0],VC[2:0]
 LCD_CtrlWrite_ILI9326(0x0102,0x0000);//VREG1OUTvoltage
 LCD_CtrlWrite_ILI9326(0x0103,0x0000);//VDV[4:0]forVCOMamplitude
 delayms(200);//dis-chargecapacitorpowervoltage
 LCD_CtrlWrite_ILI9326(0x0100,0x0002);//SAP,BT[3:0],APE,AP,DSTB,SLP
}
 
/********************************************************************************
  DESCRIPTION:
 LCM exit_sleep_mode sequence.
  PARAMETERS:
  RETURNS:
  REMARKS:
*********************************************************************************/
void LCD_ExitSleep_ILI9326(void)
{
 //Power On sequence
 LCD_CtrlWrite_ILI9326(0x0100,0x0000);  // SAP, BT[3:0], AP, DSTB, SLP, STB
 LCD_CtrlWrite_ILI9326(0x0101,0x0007);  //DC1[2:0], DC0[2:0], VC[2:0]
 LCD_CtrlWrite_ILI9326(0x0102,0x0000);  //VREG1OUT voltage
 LCD_CtrlWrite_ILI9326(0x0103,0x0000);   //VDV[4:0] for VCOM amplitude
 delayms(200);
 LCD_CtrlWrite_ILI9326(0x0100,0x1190);  //SAP, BT[3:0], AP, DSTB, SLP, STB
 LCD_CtrlWrite_ILI9326(0x0101,0x0005);  //DC1[2:0], DC0[2:0], VC[2:0]
  delayms(50);
 LCD_CtrlWrite_ILI9326(0x0102,0x01b8);  //External reference voltage=Vci
 delayms(50);
 LCD_CtrlWrite_ILI9326(0x0103,0x3600);  //VDV[4:0] for VCOM amplitude
 LCD_CtrlWrite_ILI9326(0x0281,0x0016);  //VCM[4:0] for VCOMH     19 
 delayms(50);
 LCD_CtrlWrite_ILI9326(0x0007,0x0173);// 
}
阅读(2695) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~