⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd07x1.c

📁 在fs2410开发板上的移植好的ucos操作系统和ucgui图形用户接口。
💻 C
📖 第 1 页 / 共 4 页
字号:
/*
*********************************************************************************************************
*                                                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        : LCD07X1.c
Purpose     : Driver for LCDs using K70741 controllers or compatible.
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
2.00c   020708 JE     a) Changed to work with 2bpp DDP bitmaps
2.00b   020204 JE     a) Hardwareinterface routines renamed:
                         ...DATA -> ...A1, ...CMD -> ...A0
2.00a   010924 JE     a) Bugfixes: LCD_MIRROR_X, LCD_MIRROR_Y
2.00    010402 RS     a) LCD_GetDevCaps removed from driver
                         (now LCD.c)
1.04    000925 RS     a) Support for 8bpp DDBs added
1.03    000505 JE     a) XOR mode inserted
                      b) Renamed this file from LCD0711.C -> LCD07X1.C
1.02    000329 RS     Clean up
1.01    000329 RS     Cache flushing optimized
1.00    000329 RS     First official release. Most routine are
                      optimized, cache control added.
0.00    990118 EZ/RS  First release for Motorola Israel only,
                      not configuarable, not optimized.
---------------------------LIST OF CONFIG SWITCHES--------------------
The following is a list of additional configuration switches for this
driver. These switches might not be listed in the manual, because
the manual mainly covers the general config switches which are
supported by all drivers.
----------------------------------------------------------------------
define ----------------------Explanation------------------------------
LCD_OPTIMIZE                 Controls the use of optimized routines.
----------------------------------------------------------------------
Known problems or limitations with current version
----------------------------------------------------------------------
a) LCD_MIRROR_X,Y can not be used together with LCD_SWAP_XY
---------------------------END-OF-HEADER------------------------------
*/


#include <stddef.h>           /* needed for definition of NULL */
#include <string.h> /* memset & memcpy is used in driver! */
#include "LCD_Private.h"      /* private modul definitions & config */
#include "GUI_Private.h"
#include "GUIDebug.h"
#include "LCD_0.h"            /* Defines for first display */

#if   ((LCD_CONTROLLER == 711)|(LCD_CONTROLLER == 741)) \
      && (!defined(WIN32) | defined(LCD_SIMCONTROLLER))



/*
        *********************************************************
        *                                                       *
        *           Defaults for configuration                  *
        *                                                       *
        *********************************************************

*/

#ifndef LCD_STATIC
  #define LCD_STATIC static
#endif

#ifndef LCD_WATCHDOG_TRIGGERCNT
  #define LCD_WATCHDOG_TRIGGERCNT 0
#endif

#ifndef LCD_KICK_WATCHDOG
  #define LCD_KICK_WATCHDOG()
#endif

#ifndef LCD_NUM_EMPTY_LINES
  #define LCD_NUM_EMPTY_LINES           (0)
#endif

#ifndef LCD_FIRSTSEG0
  #define LCD_FIRSTSEG0   (0)     /* Contr.0: first segment line used */
#endif

#ifndef LCD_LASTSEG0
  #if (!LCD_SWAP_XY)
    #define LCD_LASTSEG0    (LCD_XSIZE-1)    /* Contr.0: last segment line used */
  #else
    #define LCD_LASTSEG0    (LCD_YSIZE-1)
  #endif
#endif

#ifndef LCD_FIRSTCOM0
  #define LCD_FIRSTCOM0   (0)     /* Contr.0: first com line used */
#endif

#ifndef LCD_LASTCOM0
  #if (!LCD_SWAP_XY)
    #define LCD_LASTCOM0    (LCD_YSIZE-1)     /* Contr.0: last com line used */
  #else
    #define LCD_LASTCOM0    (LCD_XSIZE-1)     /* Contr.0: last com line used */
  #endif
#endif

#ifndef LCD_CACHE
  #define  LCD_CACHE                    (1)
#endif

#ifndef LCD_SUPPORT_REFRESH
  #define  LCD_SUPPORT_REFRESH LCD_CACHE
#endif

#ifndef LCD_REVERSEMODE_SUPPORT
  #define LCD_REVERSEMODE_SUPPORT       (0)
#endif

#ifndef LCD_SUPPORT_VERIFY
  #define LCD_SUPPORT_VERIFY            (0)
#endif


/* Switch for support of cache control (locking) */
#ifndef  LCD_SUPPORT_CACHECONTROL
  #define  LCD_SUPPORT_CACHECONTROL     LCD_CACHE
#endif

/* If disabled, selected drawmode is ignored.
   ==> XOR, REVERSE drawing not supported */
#ifndef LCD_SUPPORT_DRAWMODE
  #define LCD_SUPPORT_DRAWMODE          (1)
#endif

/* Switch for support of multiple pages.
 Only available with certain LCD-controllers */
#ifndef LCD_SUPPORT_PAGING
  #define LCD_SUPPORT_PAGING            (0)
#endif

#ifndef LCD_SCHEDULE_CNT
  #define LCD_SCHEDULE_CNT              (0)
#endif

#ifndef LCD_NUM_CONTROLLERS
  #define LCD_NUM_CONTROLLERS           (1)
#endif

#ifndef LCD_SUPPORT_CHECKINIT
  #define LCD_SUPPORT_CHECKINIT         (0)
#endif

#ifndef LCD_BUSWIDTH
  #define LCD_BUSWIDTH                  (16)
#endif

/* Bit position of least sig. byte when accessing words */
#ifndef LCD_LSB_SHIFT
  #define LCD_LSB_SHIFT                 (0)
#endif

#ifndef LCD_OPTIMIZE
  #define LCD_OPTIMIZE                (1)
#endif

/*
        *********************************************************
        *                                                       *
        *              Macros, standard                         *
        *                                                       *
        *********************************************************

These macros can be found in any LCD-driver as they serve purposes
that can be found in any class of LCD-driver (Like clipping).

*/

#define BKCOLOR LCD_BKCOLORINDEX
#define   COLOR LCD_COLORINDEX
#define LCD_DrawMode GUI_Context.DrawMode

/*
        *********************************************************
        *                                                       *
        *           Compiler specific settings                  *
        *                                                       *
        *********************************************************

*/
#ifdef WIN32   /* Avoid warnings in MS-compiler */
  #pragma warning(disable : 4761)  // warning C4761: integral size mismatch in argument; conversion supplied
#endif

/*
        *********************************************************
        *
        *           Defines for simulation
        *
        *********************************************************
*/

#ifdef WIN32
  #undef LCD_WRITE_A0
  #undef LCD_WRITE_A1
  #undef LCD_WRITEM_A1
  #undef LCD_INIT_CONTROLLER
  void SIM_WriteA1C0(U8 Data);
  void SIM_WriteA0C0(U8 cmd);
  void SIM_WriteMA1C0(U8*pData, int NumBytes);
  #define LCD_WRITE_A0(cmd)              SIM_WriteA0C0(cmd)
  #define LCD_WRITE_A1(Data)             SIM_WriteA1C0(Data) 
  #define LCD_WRITEM_A1(Data, NumBytes)  SIM_WriteMA1C0(Data, NumBytes)
  #define LCD_INIT_CONTROLLER()
#endif

/*********************************************************************
*
*                Remap ...A0, ...A1 -> ...CMD, ...DATA
*
**********************************************************************
*/

#define LCD_WRITEDATA1 LCD_WRITE_A1
#define LCD_WRITEMDATA LCD_WRITEM_A1
#define LCD_WRITECMD   LCD_WRITE_A0

/*
        *********************************************************
        *                                                       *
        *          Internal types                               *
        *                                                       *
        *********************************************************
*/

/* Define number of available segments of controller */

#if (LCD_CONTROLLER == 711)
  #define LCD_SEGS_MAX  128
  #define LCD_COMS_MAX 64
#elif (LCD_CONTROLLER == 741)
  #define LCD_SEGS_MAX  128
  #define LCD_COMS_MAX  128
#else
  #error Please define a controller to use !
#endif


/*
        *********************************************************
        *                                                       *
        *          Internal types                               *
        *                                                       *
        *********************************************************
*/

#if LCD_BITSPERPIXEL <=8
  #define PIXELCOLOR U8
#elif (LCD_BITSPERPIXEL >8) && (LCD_BITSPERPIXEL < 16)
  #define PIXELCOLOR U16
#else
  #error LCD_BITSPERPIXEL > 16 not supported
#endif


/*
        *********************************************************
        *                                                       *
        *          SCHEDULING                                   *
        *                                                       *
        *********************************************************
*/

#if (LCD_SCHEDULE_CNT !=0)
  static int ScheduleCntRem=LCD_SCHEDULE_CNT;
  #define CHECK_SCHEDULE(PixelCnt)                              \
          if ((ScheduleCntRem-=(PixelCnt)) <=0) {               \
            ScheduleCntRem=LCD_SCHEDULE_CNT;                    \
            LCD_SCHEDULE();                                     \
          }
#else
  #define CHECK_SCHEDULE(PixelCnt)
#endif


/*
        *********************************************************
        *                                                       *
        *          Support for Segment/COMLUTs                  *
        *                                                       *
        *********************************************************
*/

/* For compatibility with older configs, define defaults */
#ifndef LCD_SUPPORT_COMTRANS
  #define LCD_SUPPORT_COMTRANS 0
#endif
#ifndef LCD_SUPPORT_SEGTRANS
  #define LCD_SUPPORT_SEGTRANS 0
#endif


/*
        *********************************************************
        *                                                       *
        *           Macro calculations                          *
        *                                                       *
        *********************************************************
*/

#define LCD_MSB_SHIFT       (8-LCD_LSB_SHIFT)

/* To make life easier, assign physical x/y size */
#if !LCD_SWAP_XY
  #define LCD_XSIZE_P LCD_XSIZE
  #define LCD_YSIZE_P LCD_YSIZE
  #define LCD_VXSIZE_P LCD_VXSIZE
  #define LCD_VYSIZE_P LCD_VYSIZE
#else
  #define LCD_XSIZE_P LCD_YSIZE
  #define LCD_YSIZE_P LCD_XSIZE
  #define LCD_VXSIZE_P LCD_VYSIZE
  #define LCD_VYSIZE_P LCD_VXSIZE
#endif

/* Define number of used coms/segments per controller */
#define LCD_NUM_SEGS0 (LCD_LASTSEG0-LCD_FIRSTSEG0+1)
#define LCD_NUM_COMS0 (LCD_LASTCOM0-LCD_FIRSTCOM0+1)
#if (LCD_NUM_CONTROLLERS >1)
  #define LCD_NUM_SEGS1 (LCD_LASTSEG1-LCD_FIRSTSEG1+1)
  #define LCD_NUM_COMS1 (LCD_LASTCOM1-LCD_FIRSTCOM1+1)
#endif

/* Define total number of used coms/segments */
#if (LCD_NUM_CONTROLLERS ==1)
  #define LCD_NUM_SEGS LCD_NUM_SEGS0
  #define LCD_NUM_COMS LCD_NUM_COMS0
#elif (LCD_NUM_CONTROLLERS ==2)
  #define LCD_NUM_SEGS (LCD_NUM_SEGS0+LCD_NUM_SEGS1)
  #define LCD_NUM_COMS (LCD_NUM_COMS0+LCD_NUM_COMS1)
#endif

#define LCD_MEMSIZE ((LCD_BITSPERPIXEL*LCD_VXSIZE/LCD_BUSWIDTH)*(LCD_VYSIZE+LCD_NUM_EMPTY_LINES))

#if     LCD_BITSPERPIXEL == 2              /* Add by ELIZ 19 Jan 00 */
  #define BYTESPERLINE (LCD_VXSIZE_P/4)    /* Add by ELIZ 19 Jan 00 */
  #define WORDSPERLINE (LCD_VXSIZE_P/8)    /* Add by ELIZ 19 Jan 00 */
#elif   LCD_BITSPERPIXEL == 4
  #define BYTESPERLINE (LCD_VXSIZE_P/2)
  #define WORDSPERLINE (LCD_VXSIZE_P/4)
#elif LCD_BITSPERPIXEL == 8
  #define BYTESPERLINE (LCD_VXSIZE_P)
  #define WORDSPERLINE (LCD_VXSIZE_P/2)
#elif LCD_BITSPERPIXEL == 15
  #define BYTESPERLINE (LCD_VXSIZE_P*2)
  #define WORDSPERLINE (LCD_VXSIZE_P)
#else
  #error This colordepth is not supported !!!
#endif

#define LCD_NUM_PAGES (LCD_NUM_COMS+7)/8


/*
        *********************************************************
        *                                                       *
        *      Configuration switch checking                    *
        *                                                       *
        *********************************************************

Please be aware that not all configuration errors can be captured !

*/

/* Check number of controllers */
#if ((LCD_NUM_CONTROLLERS >1) || (LCD_NUM_CONTROLLERS <0))
  #error "More than 1 controller not supported by this driver"
#endif

/* Check if number of segments / coms equals resolution */
#if (LCD_NUM_SEGS < LCD_XSIZE_P)
/*  #error Please check segment setup of controller 0 and X/YSIZE !!!*/
#endif
#if (LCD_NUM_COMS < LCD_YSIZE_P)
/*  #error Please check com setup of controller 0 and X/YSIZE !!!*/
#endif


/*
        *********************************************************
        *                                                       *
        * Standard variables for driver                         *
        *                                                       *
        *********************************************************
*/

static char CacheLocked =0;
static char CacheStat   =0;
static U8 Cache[LCD_NUM_PAGES][LCD_XSIZE_P][2];
static U8 aCacheDirty[LCD_NUM_PAGES];

#if LCD_WATCHDOG_TRIGGERCNT
  int WatchdogTriggerCnt;
#endif

#if LCD_SUPPORT_VERIFY
  static int ErrCnt;
  static int ErrStat;
#endif



/*
        *********************************************************
        *                                                       *
        *       Macros for internal use                         *
        *                                                       *
        *********************************************************
*/

#if (LCD_SUPPORT_COMTRANS)
  #if (LCD_MIRROR_Y)
    #error LCD_MIRROR_Y not supported with COMTrans !
  #endif
  #if (LCD_MIRROR_X)
    #error LCD_MIRROR_X not supported with COMTrans !
  #endif
#endif

#if (!LCD_SUPPORT_COMTRANS && !LCD_SUPPORT_SEGTRANS)
  #if   (!LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY) 
    #define SETPIXEL(x, y, c)  _SetPixel(x, y, c)
    #define GETPIXEL(x, y)     _GetPixel(x,y)
    #define XORPIXEL(x, y)     XorPixel(x,y)
    #define XORPIXEL_DATA(x, y,c)  XorPixel_Data(x,y,c)
  #elif (!LCD_MIRROR_X && !LCD_MIRROR_Y &&  LCD_SWAP_XY) 
    #define SETPIXEL(x, y, c)  _SetPixel(y, x, c)
    #define GETPIXEL(x, y)     _GetPixel(y, x)
    #define XORPIXEL(x, y)      XorPixel(y, x)
    #define XORPIXEL_DATA(x, y,c)  XorPixel_Data(y,x,c)
  #elif (!LCD_MIRROR_X &&  LCD_MIRROR_Y && !LCD_SWAP_XY) 
    #define SETPIXEL(x, y, c)  _SetPixel(x, LCD_YSIZE-1-(y), c)
    #define GETPIXEL(x, y)     _GetPixel(x, LCD_YSIZE-1-(y))
    #define XORPIXEL(x, y)     XorPixel (x, LCD_YSIZE-1-(y))
    #define XORPIXEL_DATA(x, y,c)  XorPixel_Data(x,LCD_YSIZE-1-(y),c)
  #elif (!LCD_MIRROR_X &&  LCD_MIRROR_Y &&  LCD_SWAP_XY) 
    #define SETPIXEL(x, y, c)  _SetPixel(LCD_YSIZE-1-(y), x, c)
    #define GETPIXEL(x, y)     _GetPixel(LCD_YSIZE-1-(y), x)
    #define XORPIXEL(x, y)      XorPixel(LCD_YSIZE-1-(y), x)
    #define XORPIXEL_DATA(x, y,c)  XorPixel_Data(LCD_YSIZE-1-(y),x,c)
  #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY) 
    #define SETPIXEL(x, y, c)  _SetPixel(LCD_XSIZE-1-(x), y, c)
    #define GETPIXEL(x, y)     _GetPixel(LCD_XSIZE-1-(x), y)
    #define XORPIXEL(x, y)     XorPixel (LCD_XSIZE-1-(x), y)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -