ucGUI移植到msp430f149时底层驱动代码

标签: ucGUI移植msp430IAR
3262人阅读 评论(0) 收藏 举报
分类:

说明:所用液晶为2.4寸TFT液晶屏,液晶驱动器为瑞萨公司的R61505U(和ILI9325通用)。

/*
*********************************************************************************************************
*                                                uC/GUI
*                        Universal graphic software for embedded applications
*
*                       (c) Copyright 2002, Micrium Inc., Weston, FL
*                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
*              礐/GUI is protected by international copyright laws. Knowledge of the
*              source code may not be used to write a similar product. This file may
*              only be used in accordance with a license and should not be redistributed
*              in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File        : LCDDummy.C
Purpose     : Empty driver
              This driver does no perform any function, but it can be
              used for 2 purposes:
              a) Satisfy all externals so an application can be
                compiled and linked in target hardware even if the
                driver is not already available
              b) Template for a starting point for a new driver.
----------------------------------------------------------------------   
Adapting to a new system (creating a new driver):
  In this case, the first step is to fill the routines 
  LCD_L0_GetPixelIndex, LCD_L0_SetPixelIndex and LCD_L0_Init with
  functionality, which is sufficient to make the hardware work.
  A second (optional) step would be to optimize higher level routines. 
----------------------------------------------------------------------   
Version-Date---Author-Explanation                                        
----------------------------------------------------------------------   
1.00.00 020417 JE     a) Changed to have only to adapt _GetPixelIndex
                         and _SetPixelIndex
0.90.00 020214 JE     a) First release
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Private.h"      /* private modul definitions & config */
#include "GUI_Private.h"
#include "GUIDebug.h"
#include<msp430f149.h>
#if (LCD_CONTROLLER == -1)// \
//    && (!defined(WIN32) | defined(LCD_SIMCONTROLLER))
/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
void R61505_Initial();
#ifndef LCD_INIT_CONTROLLER
  #define LCD_INIT_CONTROLLER()   R61505_Initial()
#endif
/*
void Delayus(unsigned int n)
{
  unsigned int i;
  i=8*n;
  while(i--);
}
void delayms(unsigned int count)
{
  while(count--)
    Delayus(1000);
}
*/
/*********************************************************************
*
*       Macros for MIRROR_, SWAP_ and LUT_
*/
#if (!defined (LCD_LUT_COM) && !defined(LCD_LUT_SEG))
  #if   (!LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY) 
    #define LOG2PHYS_X(x, y) x
    #define LOG2PHYS_Y(x, y) y
  #elif (!LCD_MIRROR_X && !LCD_MIRROR_Y &&  LCD_SWAP_XY) 
    #define LOG2PHYS_X(x, y) y
    #define LOG2PHYS_Y(x, y) x
  #elif (!LCD_MIRROR_X &&  LCD_MIRROR_Y && !LCD_SWAP_XY) 
    #define LOG2PHYS_X(x, y) x
    #define LOG2PHYS_Y(x, y) LCD_YSIZE - 1 - (y)
  #elif (!LCD_MIRROR_X &&  LCD_MIRROR_Y &&  LCD_SWAP_XY) 
    #define LOG2PHYS_X(x, y) y
    #define LOG2PHYS_Y(x, y) LCD_XSIZE - 1 - (x)
  #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY) 
    #define LOG2PHYS_X(x, y) LCD_XSIZE - 1 - (x)
    #define LOG2PHYS_Y(x, y) y
  #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y &&  LCD_SWAP_XY) 
    #define LOG2PHYS_X(x, y) LCD_YSIZE - 1 - (y)
    #define LOG2PHYS_Y(x, y) x
  #elif ( LCD_MIRROR_X &&  LCD_MIRROR_Y && !LCD_SWAP_XY) 
    #define LOG2PHYS_X(x, y) LCD_XSIZE - 1 - (x)
    #define LOG2PHYS_Y(x, y) LCD_YSIZE - 1 - (y)
  #elif ( LCD_MIRROR_X &&  LCD_MIRROR_Y &&  LCD_SWAP_XY) 
    #define LOG2PHYS_X(x, y) LCD_YSIZE - 1 - (y)
    #define LOG2PHYS_Y(x, y) LCD_XSIZE - 1 - (x)
  #endif
#else
  #if   ( defined (LCD_LUT_COM) && !defined(LCD_LUT_SEG))
    #define LOG2PHYS_X(x, y) x
    #define LOG2PHYS_Y(x, y) LCD__aLine2Com0[y]
  #elif (!defined (LCD_LUT_COM) &&  defined(LCD_LUT_SEG))
    #define LOG2PHYS_X(x, y) LCD__aCol2Seg0[x]
    #define LOG2PHYS_Y(x, y) y
  #elif ( defined (LCD_LUT_COM) &&  defined(LCD_LUT_SEG))
    #define LOG2PHYS_X(x, y) LCD__aCol2Seg0[x]
    #define LOG2PHYS_Y(x, y) LCD__aLine2Com0[y]
  #endif
#endif
/*********************************************************************
*
*       Static functions
*
**********************************************************************
*/
/*********************************************************************
*
*       Draw Bitmap 1 BPP
*/
static void  _DrawBitLine1BPP(int x, int y, U8 const GUI_UNI_PTR *p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) {
  LCD_PIXELINDEX Index0 = *(pTrans+0);
  LCD_PIXELINDEX Index1 = *(pTrans+1);
  x += Diff;
  switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
    case 0:
      do {
        LCD_L0_SetPixelIndex(x++, y, (*p & (0x80 >> Diff)) ? Index1 : Index0);
     if (++Diff == 8) {
          Diff = 0;
      p++;
     }
    } while (--xsize);
      break;
    case LCD_DRAWMODE_TRANS:
      do {
      if (*p & (0x80 >> Diff))
          LCD_L0_SetPixelIndex(x, y, Index1);
        x++;
     if (++Diff == 8) {
          Diff = 0;
      p++;
     }
    } while (--xsize);
      break;
    case LCD_DRAWMODE_XOR:;
      do {
      if (*p & (0x80 >> Diff)) {
          int Pixel = LCD_L0_GetPixelIndex(x, y);
          LCD_L0_SetPixelIndex(x, y, LCD_NUM_COLORS - 1 - Pixel);
        }
        x++;
     if (++Diff == 8) {
          Diff = 0;
      p++;
     }
    } while (--xsize);
      break;
 }
}
/*********************************************************************
*
*       Draw Bitmap 2 BPP
*/
#if (LCD_MAX_LOG_COLORS > 2)
static void  _DrawBitLine2BPP(int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
  LCD_PIXELINDEX Pixels = *p;
  int CurrentPixel = Diff;
  x += Diff;
  switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
    case 0:
      if (pTrans) {
        do {
          int Shift = (3 - CurrentPixel) << 1;
          int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
          LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
          LCD_L0_SetPixelIndex(x++, y, PixelIndex);
          if (++CurrentPixel == 4) {
            CurrentPixel = 0;
            Pixels = *(++p);
          }
      } while (--xsize);
      } else {
        do {
          int Shift = (3 - CurrentPixel) << 1;
          int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
          LCD_L0_SetPixelIndex(x++, y, Index);
          if (++CurrentPixel == 4) {
            CurrentPixel = 0;
            Pixels = *(++p);
          }
      } while (--xsize);
      }
      break;
    case LCD_DRAWMODE_TRANS:
      if (pTrans) {
        do {
          int Shift = (3 - CurrentPixel) << 1;
          int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
          if (Index) {
            LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
            LCD_L0_SetPixelIndex(x, y, PixelIndex);
          }
          x++;
          if (++CurrentPixel == 4) {
            CurrentPixel = 0;
            Pixels = *(++p);
          }
      } while (--xsize);
      } else {
        do {
          int Shift = (3 - CurrentPixel) << 1;
          int Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
          if (Index) {
            LCD_L0_SetPixelIndex(x, y, Index);
          }
          x++;
          if (++CurrentPixel == 4) {
            CurrentPixel = 0;
            Pixels = *(++p);
          }
      } while (--xsize);
      }
      break;
  }
}
#endif
/*********************************************************************
*
*       Draw Bitmap 4 BPP
*/
#if (LCD_MAX_LOG_COLORS > 4)
static void  _DrawBitLine4BPP(int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
  LCD_PIXELINDEX Pixels = *p;
  int CurrentPixel = Diff;
  x += Diff;
  switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
    case 0:
      if (pTrans) {
        do {
          int Shift = (1 - CurrentPixel) << 2;
          int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
          LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
          LCD_L0_SetPixelIndex(x++, y, PixelIndex);
          if (++CurrentPixel == 2) {
            CurrentPixel = 0;
            Pixels = *(++p);
          }
      } while (--xsize);
      } else {
        do {
          int Shift = (1 - CurrentPixel) << 2;
          int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
          LCD_L0_SetPixelIndex(x++, y, Index);
          if (++CurrentPixel == 2) {
            CurrentPixel = 0;
            Pixels = *(++p);
          }
      } while (--xsize);
      }
      break;
    case LCD_DRAWMODE_TRANS:
      if (pTrans) {
        do {
          int Shift = (1 - CurrentPixel) << 2;
          int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
          if (Index) {
            LCD_PIXELINDEX PixelIndex = *(pTrans + Index);
            LCD_L0_SetPixelIndex(x, y, PixelIndex);
          }
          x++;
          if (++CurrentPixel == 2) {
            CurrentPixel = 0;
            Pixels = *(++p);
          }
      } while (--xsize);
      } else {
        do {
          int Shift = (1 - CurrentPixel) << 2;
          int Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
          if (Index) {
            LCD_L0_SetPixelIndex(x, y, Index);
          }
          x++;
          if (++CurrentPixel == 2) {
            CurrentPixel = 0;
            Pixels = *(++p);
          }
      } while (--xsize);
      }
      break;
  }
}
#endif
/*********************************************************************
*
*       Draw Bitmap 8 BPP
*/
#if (LCD_MAX_LOG_COLORS > 16)
static void  _DrawBitLine8BPP(int x, int y, U8 const GUI_UNI_PTR * p, int xsize, const LCD_PIXELINDEX * pTrans) {
  LCD_PIXELINDEX Pixel;
  switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
    case 0:
      if (pTrans) {
        for (; xsize > 0; xsize--, x++, p++) {
          Pixel = *p;
          LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
        }
      } else {
        for (; xsize > 0; xsize--, x++, p++) {
          LCD_L0_SetPixelIndex(x, y, *p);
        }
      }
      break;
    case LCD_DRAWMODE_TRANS:
      if (pTrans) {
        for (; xsize > 0; xsize--, x++, p++) {
          Pixel = *p;
          if (Pixel) {
            LCD_L0_SetPixelIndex(x, y, *(pTrans + Pixel));
          }
        }
      } else {
        for (; xsize > 0; xsize--, x++, p++) {
          Pixel = *p;
          if (Pixel) {
            LCD_L0_SetPixelIndex(x, y, Pixel);
          }
        }
      }
      break;
  }
}
#endif
/*********************************************************************
*
*       Draw Bitmap 16 BPP
*/
#if (LCD_BITSPERPIXEL > 8)
static void  DrawBitLine16BPP(int x, int y, U16 const GUI_UNI_PTR * p, int xsize, const LCD_PIXELINDEX * pTrans) {
  LCD_PIXELINDEX pixel;
  if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) == 0) {
    if (pTrans) {
      for (; xsize > 0; xsize--, x++, p++) {
        pixel = *p;
        LCD_L0_SetPixelIndex(x, y, *(pTrans + pixel));
      }
    } else {
      for (;xsize > 0; xsize--, x++, p++) {
        LCD_L0_SetPixelIndex(x, y, *p);
      }
    }
  } else {
    if (pTrans) {
      for (; xsize > 0; xsize--, x++, p++) {
        pixel = *p;
        if (pixel) {
          LCD_L0_SetPixelIndex(x, y, *(pTrans + pixel));
        }
      }
    } else {
      for (; xsize > 0; xsize--, x++, p++) {
        pixel = *p;
        if (pixel) {
          LCD_L0_SetPixelIndex(x, y, pixel);
        }
      }
    }
  }
}
#endif
/*********************************************************************
*
*       Exported functions
*
**********************************************************************
*/
/*********************************************************************
*
*       LCD_L0_SetPixelIndex
*
* Purpose:
*   Sets the index of the given pixel. The upper layers
*   calling this routine make sure that the coordinates are in range, so
*   that no check on the parameters needs to be performed.
*/

/*----------------------------------------------------------------
                           定义硬件端口
----------------------------------------------------------------*/
//TFT显示模块
#define DataPort P4OUT                //数据口使用DataPort
#define DataPort_out P4DIR=0xff
#define DataPort_in  P4DIR=0x00
#define DataPort_val P4IN
#define LCD_CS_out    P5DIR|=BIT1
  #define LCD_CS1    P5OUT|=BIT1  //片选
#define LCD_CS0    P5OUT&=~BIT1
#define LCD_REST_out    P5DIR|=BIT2
  #define LCD_REST1   P5OUT|=BIT2  //复位
#define LCD_REST0   P5OUT&=~BIT2
#define LCD_RD_out   P5DIR|=BIT3
  #define LCD_RD1    P5OUT|=BIT3               //读数据/命令
#define LCD_RD0    P5OUT&=~BIT3
#define LCD_RS_out    P5DIR|=BIT4
  #define LCD_RS1    P5OUT|=BIT4  //数据/命令选择
#define LCD_RS0    P5OUT&=~BIT4
#define LCD_RW_out    P5DIR|=BIT5
  #define LCD_RW1    P5OUT|=BIT5       //写数据/命令
#define LCD_RW0    P5OUT&=~BIT5
/*----------------------------------------------------------------
                           写命令
----------------------------------------------------------------*/
void Write_Cmd(unsigned char DH,unsigned char DL)
{
        LCD_CS_out;
        LCD_RS_out;
        LCD_RW_out;
        DataPort_out;
 LCD_CS0;
        LCD_RS0;
 DataPort=DH;
        LCD_RW0;
        LCD_RW1;
 DataPort=DL;
 LCD_RW0;
        LCD_RW1;
        LCD_CS1;
}
/*----------------------------------------------------------------
                           写数据 双8位
----------------------------------------------------------------*/
void Write_Data(unsigned char DH,unsigned char DL)
{
        LCD_CS_out;
        LCD_RS_out;
        LCD_RW_out;
        DataPort_out;  
 LCD_CS0;
 LCD_RS1;
 DataPort=DH;
        LCD_RW0;
        LCD_RW1;
 DataPort=DL; 
        LCD_RW0;
        LCD_RW1;
        LCD_CS1;
}
//读数据
unsigned int ReadData()
{
 unsigned int H,L,value;
        unsigned int r,g,b;
  LCD_CS_out;
        LCD_RS_out;
        LCD_RW_out;
 LCD_RD_out;

 LCD_CS0;
 LCD_RS1;
 LCD_RD1;
 LCD_RW1;
 LCD_RD0;
 DataPort_in;
 H=DataPort_val;
 LCD_RD1;
 LCD_RD0;
 L=DataPort_val;
 LCD_RD1;
 DataPort_out; 
 value=(H<<8)+L;
              /*TFT为BGR模式,读出来的数据要做RGB交换  */
               b=(value>>11)&0x001F;
               r=(value<<11)&0xF800;
               g=value&0x07E0;
               value=r|g|b;        

 return value;
}
#define WINDOW_XADDR_START 0x0050 // Horizontal Start Address Set
#define WINDOW_XADDR_END 0x0051 // Horizontal End Address Set
#define WINDOW_YADDR_START 0x0052 // Vertical Start Address Set
#define WINDOW_YADDR_END 0x0053 // Vertical End Address Set
#define GRAM_XADDR      0x0020 // GRAM Horizontal Address Set
#define GRAM_YADDR      0x0021 // GRAM Vertical Address Set
#define GRAMWR        0x0022 // memory write
/*----------------------------------------------------------------
                         写命令、写数据
输入参数:x 需要输入的命令 16位
          y 需要输入的数据 16位
----------------------------------------------------------------*/
void  Write_Cmd_Data(unsigned char x,unsigned int y)
{
 unsigned char m,n;
 m=y>>8;
 n=y;
 Write_Cmd(0x00,x);
 Write_Data(m,n);
}
/*----------------------------------------------------------------
                         写16位数据
----------------------------------------------------------------*/
void  Write_Data_U16(int y)
{
 unsigned char m,n;
 m=y>>8;
 n=y;
 Write_Data(m,n);
}
/*----------------------------------------------------------------
                         设置坐标
----------------------------------------------------------------*/
static void LCD_SetPos(int x0,int x1,int y0,int y1)
{
  Write_Cmd_Data(WINDOW_XADDR_START,x0);
  Write_Cmd_Data(WINDOW_XADDR_END,x1);
  Write_Cmd_Data(WINDOW_YADDR_START,y0);
  Write_Cmd_Data(WINDOW_YADDR_END,y1);
  Write_Cmd_Data(GRAM_XADDR,x0);
  Write_Cmd_Data(GRAM_YADDR,y0);
  Write_Cmd (0x00,0x22);//LCD_WriteCMD(GRAMWR);
}
/*----------------------------------------------------------------
                           清屏函数
输入参数:bColor 清屏所使用的背景色
----------------------------------------------------------------*/
void CLR_Screen(unsigned int bColor)
{
 unsigned int i,j;
 LCD_SetPos(0,240,0,320);//320x240
 for (i=0;i<322;i++)
 {

    for (j=0;j<240;j++)
        Write_Data_U16(bColor);
 }
}
void LCD_L0_SetPixelIndex(int x, int y, int PixelIndex) {
  /* Convert logical into physical coordinates (Dep. on LCDConf.h) */
  #if LCD_SWAP_XY | LCD_MIRROR_X| LCD_MIRROR_Y
    int xPhys = LOG2PHYS_X(x, y);
    int yPhys = LOG2PHYS_Y(x, y);
  #else
    #define xPhys x
    #define yPhys y
  #endif
  /* Write into hardware ... Adapt to your system */
  {
   // /* ... */
      LCD_SetPos(xPhys,xPhys,yPhys,yPhys);
      Write_Data_U16(PixelIndex);

  }
}
/*********************************************************************
*
*       LCD_L0_GetPixelIndex
*
* Purpose:
*   Returns the index of the given pixel. The upper layers
*   calling this routine make sure that the coordinates are in range, so
*   that no check on the parameters needs to be performed.
*/
unsigned int LCD_L0_GetPixelIndex(int x, int y) {
  LCD_PIXELINDEX PixelIndex;
  /* Convert logical into physical coordinates (Dep. on LCDConf.h) */
  #if LCD_SWAP_XY | LCD_MIRROR_X| LCD_MIRROR_Y
    int xPhys = LOG2PHYS_X(x, y);
    int yPhys = LOG2PHYS_Y(x, y);
  #else
    #define xPhys x
    #define yPhys y
  #endif
  /* Read from hardware ... Adapt to your system */
  {
    LCD_SetPos(xPhys,xPhys,yPhys,yPhys);
    PixelIndex =ReadData();//空读
    PixelIndex =ReadData();
  }
  return PixelIndex;
}
/*********************************************************************
*
*       LCD_L0_XorPixel
*/
void LCD_L0_XorPixel(int x, int y) {
  LCD_PIXELINDEX PixelIndex = LCD_L0_GetPixelIndex(x, y);
  LCD_L0_SetPixelIndex(x, y, LCD_NUM_COLORS - PixelIndex - 1);
}
/*********************************************************************
*
*       LCD_L0_DrawHLine
*/
void LCD_L0_DrawHLine  (int x0, int y,  int x1) {
  if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
    for (; x0 <= x1; x0++) {
      LCD_L0_XorPixel(x0, y);
    }
  } else {
/*    for (; x0 <= x1; x0++) {
      LCD_L0_SetPixelIndex(x0, y, LCD_COLORINDEX);
    }*/
         LCD_SetPos(x0,x1,y,y);
    for(; x0 <= x1; x0++)
        {
          Write_Data_U16(LCD_COLORINDEX);
        }
  }
}
/*********************************************************************
*
*       LCD_L0_DrawVLine
*/
void LCD_L0_DrawVLine  (int x, int y0,  int y1) {
  if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
    for (; y0 <= y1; y0++) {
      LCD_L0_XorPixel(x, y0);
    }
  } else {
/*    for (; y0 <= y1; y0++) {
      LCD_L0_SetPixelIndex(x, y0, LCD_COLORINDEX); 
    }*/
      LCD_SetPos(x,x,y0,y1);
    for(; y0 <= y1; y0++)
        {
          Write_Data_U16(LCD_COLORINDEX);
        }
  }
}
/*********************************************************************
*
*       LCD_L0_FillRect
*/
void LCD_L0_FillRect(int x0, int y0, int x1, int y1)
{
//  for (; y0 <= y1; y0++)
//  {
//    LCD_L0_DrawHLine(x0, y0, x1);//LCD_COLORINDEX
//  }
  //改进后
  if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR)
  {
      LCD_SetPos(x0,x1,y0,y1);
      for (; y0 <= y1; y0++)
      {
        for (; x0 <= x1; x0++)
        LCD_L0_XorPixel(x0, y0);
      }
  }
  else
  {
      LCD_SetPos(x0,x1,y0,y1);
      for (; y0 <= y1; y0++)
      {
        for (; x0 <= x1; x0++)
        Write_Data_U16(LCD_COLORINDEX);
      }
  }

}
/*********************************************************************
*
*       LCD_L0_DrawBitmap
*/
void LCD_L0_DrawBitmap(int x0, int y0,
                       int xsize, int ysize,
                       int BitsPerPixel, 
                       int BytesPerLine,
                       const U8 GUI_UNI_PTR * pData, int Diff,
                       const LCD_PIXELINDEX* pTrans)
{
  int i;
  /* Use _DrawBitLineXBPP */
  for (i=0; i<ysize; i++) {
    switch (BitsPerPixel) {
    case 1:
      _DrawBitLine1BPP(x0, i + y0, pData, Diff, xsize, pTrans);
      break;
    #if (LCD_MAX_LOG_COLORS > 2)
      case 2:
        _DrawBitLine2BPP(x0, i + y0, pData, Diff, xsize, pTrans);
        break;
    #endif
    #if (LCD_MAX_LOG_COLORS > 4)
      case 4:
        _DrawBitLine4BPP(x0, i + y0, pData, Diff, xsize, pTrans);
        break;
    #endif
    #if (LCD_MAX_LOG_COLORS > 16)
      case 8:
        _DrawBitLine8BPP(x0, i + y0, pData, xsize, pTrans);
        break;
    #endif
    #if (LCD_BITSPERPIXEL > 8)
      case 16:
        DrawBitLine16BPP(x0, i + y0, (const U16 *)pData, xsize, pTrans);
        break;
    #endif
    }
    pData += BytesPerLine;
  }
}
/*********************************************************************
*
*       LCD_L0_SetOrg
*/
void LCD_L0_SetOrg(int x, int y) {
  GUI_USE_PARA(x);
  GUI_USE_PARA(y);
}
/*********************************************************************
*
*       LCD_On / LCD_Off
*/
void LCD_On (void) {
#ifdef LCD_ON
  LCD_ON();
#endif
}
void LCD_Off (void) {
#ifdef LCD_OFF
  LCD_OFF();
#endif
}
/*********************************************************************
*
*       LCD_L0_Init
*
* Purpose:
*   Initialises the LCD-controller.
*/
int  LCD_L0_Init(void) {
  LCD_INIT_CONTROLLER();
  //R61505_Initial();
  return 0;
}
/*********************************************************************
*
*       LCD_L0_SetLUTEntry
*/
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR Color) {
  GUI_USE_PARA(Pos);
  GUI_USE_PARA(Color);
}
#else
void LCDDummy_c(void);
void LCDDummy_c(void) { } /* avoid empty object files */
#endif /* (LCD_CONTROLLER undefined) */

/*----------------------------------------------------------------
                            液晶初始化
----------------------------------------------------------------*/
void R61505_Initial()
{   LCD_REST_out;
  LCD_REST1;
  LCD_RD_out;
  LCD_RD1;
    Write_Cmd_Data(0x0000,0x0000);
    Write_Cmd_Data(0x0000,0x0000);
    Write_Cmd_Data(0x0000,0x0000);
    Write_Cmd_Data(0x0000,0x0000);
    Write_Cmd_Data(0x0010,0x0600);   // SLP=0,

    Write_Cmd_Data(0x0007,0x0000);       
    Write_Cmd_Data(0x0012,0x011A);
    Write_Cmd_Data(0x00A4,0x0001);
    Write_Cmd_Data(0x0008,0x020E);  // FP,BP
    Write_Cmd_Data(0x000A,0x0008);
    Write_Cmd_Data(0x000D,0x0008);
    Write_Cmd_Data(0x0030,0x0707);
    Write_Cmd_Data(0x0031,0x0007);
    Write_Cmd_Data(0x0032,0x0603); 
    Write_Cmd_Data(0x0033,0x0700); 
    Write_Cmd_Data(0x0034,0x0202); 
    Write_Cmd_Data(0x0035,0x0002); 
    Write_Cmd_Data(0x0036,0x1E00); 
    Write_Cmd_Data(0x0037,0x0707); 
    Write_Cmd_Data(0x0038,0x0000); 
    Write_Cmd_Data(0x0039,0x0000); 
    Write_Cmd_Data(0x003A,0x0707); 
    Write_Cmd_Data(0x003B,0x0000); 
    Write_Cmd_Data(0x003C,0x0007); 
    Write_Cmd_Data(0x003D,0x0000); 

   Write_Cmd_Data(0x0011,0x0007);     
   Write_Cmd_Data(0x0060,0x2700);
   Write_Cmd_Data(0x0090,0x0016);  // DIVI, RTNI
    Write_Cmd_Data(0x0017,0x0001); 
   Write_Cmd_Data(0x0019,0x0000); // TBT[1:0]

    Write_Cmd_Data(0x0010,0x16B0);            
    Write_Cmd_Data(0x0012,0x011A); 

    Write_Cmd_Data(0x0013,0x1800); // VDV[4:0]   
    Write_Cmd_Data(0x002A,0x000E); // VCMSEL, VCM2[4:0]
    Write_Cmd_Data(0x0029,0x000E); // VCM1[4:0]

    Write_Cmd_Data(0x0012,0x013A); // VCOMR[0], VREG1R, PSON, PON, VRH[3:0]

    Write_Cmd_Data(0x0050,0x0000); 
    Write_Cmd_Data(0x0051,0x00EF); 
    Write_Cmd_Data(0x0052,0x0000); 
    Write_Cmd_Data(0x0053,0x013F); 
    Write_Cmd_Data(0x0020,0x0000); 
    Write_Cmd_Data(0x0021,0x0000);           
    Write_Cmd_Data(0x0061,0x0001); 
    Write_Cmd_Data(0x006A,0x0000); 
    Write_Cmd_Data(0x0080,0x0000); 
    Write_Cmd_Data(0x0081,0x0000); 
    Write_Cmd_Data(0x0082,0x0000); 
    Write_Cmd_Data(0x0083,0x0000); 
    Write_Cmd_Data(0x0084,0x0000); 
    Write_Cmd_Data(0x0085,0x0000);         
    Write_Cmd_Data(0x0092,0x0300); 
    Write_Cmd_Data(0x0093,0x0005); 
    Write_Cmd_Data(0x0095,0x0000); 
    Write_Cmd_Data(0x0097,0x0000); 
    Write_Cmd_Data(0x0098,0x0000); 
    Write_Cmd_Data(0x0001,0x0100); 
    Write_Cmd_Data(0x0002,0x0700); 
    Write_Cmd_Data(0x0003,0x1030); 
    Write_Cmd_Data(0x0004,0x0000); 
    Write_Cmd_Data(0x000C,0x0000); 
    Write_Cmd_Data(0x000F,0x0000); 

    Write_Cmd_Data(0x0007,0x0001);
    Write_Cmd_Data(0x0007,0x0021); 

    Write_Cmd_Data(0x0010,0x16B0);  // Write final user’s setting values to BT bits
    Write_Cmd_Data(0x0011,0x0007);  // Write final user’s setting values to VC bits

    Write_Cmd_Data(0x0007,0x0061); 

    Write_Cmd_Data(0x0007,0x0173); 

}
1
0

猜你在找
【直播】机器学习&数据挖掘7周实训--韦玮
【套餐】系统集成项目管理工程师顺利通关--徐朋
【直播】3小时掌握Docker最佳实战-徐西宁
【套餐】机器学习系列套餐(算法+实战)--唐宇迪
【直播】计算机视觉原理及实战--屈教授
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之矩阵--黄博士
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之凸优化--马博士
【套餐】Javascript 设计模式实战--曾亮
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:339685次
    • 积分:3813
    • 等级:
    • 排名:第8324名
    • 原创:91篇
    • 转载:5篇
    • 译文:1篇
    • 评论:50条
    博客专栏
    我的开源项目
    最新评论