?? lcd13xx.c
字號:
/*********************************************************************************************************** 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 : LCD13XX.CPurpose : Driver for LCDs using a single Seiko Epson SED13XX controllers This version supports a single LCD controller in (almost) any hardware configuration. The following derivatives are currently supported: SED1352 SED1354 SED1356 (With/Without BitBlt engine support) SED1374 SED1375 SED13806 Other Epson LCD controllers are very similar and could be covered by this driver as well, but have not been tested.---------------------------------------------------------------------- ---------------------------LIST OF CONFIG SWITCHES--------------------The following is a list of additional configuration switches for thisdriver. These switches might not be listed in the manual, becausethe manual mainly covers the general config switches which aresupported by all drivers.----------------------------------------------------------------------define ----------------------Explanation------------------------------LCD_SWAP_BYTE_ORDER Activate if high low bytes are swapped Default: 0LCD_WRITE_MEM32(Off,Data32) This macro accelerates display access if defined by allowing the CPU to write 32 bits at a time to the controller. (For 32 bits CPUs only and only if the BUS interface unit can automatically convert this to 2 16 bit accessesLCD_OPTIMIZE Controls the use of optimized routines. If 1, several (speed) optimizations are used. Default: ON (1)LCD_USE_BITBLT This switch controls the use of optimized routines with SED1356 bitblt engine. If 1, the optimized routines with bitblt access are used. The default value depends of LCD_BITSPERPIXEL: (4 ) -> 0, (8,15) -> 1LCD_ENABLE_REG_ACCESS() LCD_ENABLE_MEM_ACCESS() In most systems (and with most LCD-controllers) registers / memory can be accessed at different addresses. However, in some systems, it could be necessary to exec code in order to be able to access the registers or memory. This code should then be placed in these macros (rather than the actual access macros, which would be slowed down)LCD_DATAADR define adress if video memory can be treated like regular memory (will speed up driver)----------------------------------------------------------------------Known problems or limitations with current version----------------------------------------------------------------------none----------------------------------------------------------------------Open issues----------------------------------------------------------------------None---------------------------END-OF-HEADER------------------------------*/#include <stddef.h> /* needed for definition of NULL */#include "LCD_Private.H" /* private modul definitions & config */#include "GUI_Private.H"#include "GUIDebug.h"#include "LCD_0.h" /* Defines for first display */// extern U8 LCD_Buffer [LCD_XSIZE*LCD_YSIZE];extern U8 LCD_Buffer [];// 對 Video RAM 區的讀寫操作.#define LCD_READ_MEM(Off) LCD_Buffer[Off]/* LCD_Buffer[(Off/80)*80+((Off%80)/4)*4+4-(Off%80)%4]*/#define LCD_WRITE_MEM(Off,data) LCD_Buffer[Off]=data/*LCD_Buffer[(Off/80)*80+((Off%80)/4)*4+4-(Off%80)%4]=data*/#define LCD_READ_REG(Off) 0#define LCD_WRITE_REG(Off,data) #if (LCD_CONTROLLER/100 == 13) && (LCD_CONTROLLER/10 != 133) \ && (!defined(WIN32) | defined(LCD_SIMCONTROLLER))/* ********************************************************* * * * Compiler specific settings * * * **********************************************************/#ifdef WIN32 /* Avoid warnings in MS-compiler */ #pragma warning(disable : 4244) // warning C4244: '=' : conversion from 'long ' to 'unsigned char ', possible loss of data #pragma warning(disable : 4761) // warning C4761: integral size mismatch in argument; conversion supplied#endif/************************************************************ Controller renumbering********************************************************** EPSON decided to rename all of their controllers. In order to be able to work with old and new numbers, we simply map the old ones to the new ones.*/#if LCD_CONTROLLER == 1386 #undef LCD_CONTROLLER #define LCD_CONTROLLER 13806#endif/* ********************************************************* * * * Defaults for configuration * * * **********************************************************//* 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_BUSWIDTH #define LCD_BUSWIDTH (16)#endif#ifndef LCD_OPTIMIZE #define LCD_OPTIMIZE (1)#endif#if (LCD_CONTROLLER == 1356) || (LCD_CONTROLLER == 13806) #ifndef LCD_USE_BITBLT #if ((LCD_BITSPERPIXEL == 16) || (LCD_BITSPERPIXEL == 8 )) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0) #define LCD_USE_BITBLT (1) #else #define LCD_USE_BITBLT (0) #endif #else #if (LCD_MIRROR_Y) #error BITBLT engine does not support LCD_MIRROR_Y = 1! #endif #if (LCD_SWAP_XY) #error BITBLT engine does not support LCD_SWAP_XY = 1! #endif #endif#else #define LCD_USE_BITBLT (0)#endif#ifndef LCD_ENABLE_REG_ACCESS #define LCD_ENABLE_REG_ACCESS()#endif#ifndef LCD_ENABLE_MEM_ACCESS #define LCD_ENABLE_MEM_ACCESS()#endif#ifndef STATIC #define STATIC static#endif/* ********************************************************* * * * Defines for configuration simulation * * * **********************************************************/#if defined(WIN32) && !defined(USE_PC_HARDWARE) void SIM_WriteMem8(unsigned int Off, int Data); void SIM_WriteReg8(unsigned int Off, int Data); int SIM_ReadMem8(unsigned int Off); int SIM_ReadReg8(unsigned int Off); void SIM_WriteMem16(unsigned int Off, int Data); void SIM_WriteReg16(unsigned int Off, int Data); int SIM_ReadMem16(unsigned int Off); int SIM_ReadReg16(unsigned int Off); #undef LCD_READ_MEM #undef LCD_READ_REG #undef LCD_WRITE_MEM #undef LCD_WRITE_REG #if LCD_BUSWIDTH==8 #define LCD_READ_MEM(Off) SIM_ReadMem8(Off) #define LCD_WRITE_MEM(Off,Data) SIM_WriteMem8(Off, Data) #define LCD_READ_REG(Off) SIM_ReadReg8(Off) #define LCD_WRITE_REG(Off,Data) SIM_WriteReg8(Off, Data) #elif LCD_BUSWIDTH==16 #define LCD_READ_MEM(Off) SIM_ReadMem16(Off) #define LCD_WRITE_MEM(Off,Data) SIM_WriteMem16(Off, Data) #define LCD_READ_REG(Off) SIM_ReadReg16(Off) #define LCD_WRITE_REG(Off,Data) SIM_WriteReg16(Off, Data) #endif#elif defined(WIN32) && defined(USE_PC_HARDWARE) void PC_WriteMem8(unsigned int Off, int Data); void PC_WriteReg8(unsigned int Off, int Data); int PC_ReadMem8(unsigned int Off); int PC_ReadReg8(unsigned int Off); void PC_WriteMem16(unsigned int Off, int Data); void PC_WriteReg16(unsigned int Off, int Data); int PC_ReadMem16(unsigned int Off); int PC_ReadReg16(unsigned int Off); #undef LCD_READ_MEM #undef LCD_READ_REG #undef LCD_WRITE_MEM #undef LCD_WRITE_REG #if LCD_BUSWIDTH==8 #define LCD_READ_MEM(Off) PC_ReadMem8(Off) #define LCD_WRITE_MEM(Off,Data) PC_WriteMem8(Off, Data) #define LCD_READ_REG(Off) PC_ReadReg8(Off) #define LCD_WRITE_REG(Off,Data) PC_WriteReg8(Off, Data) #else #define LCD_READ_MEM(Off) PC_ReadMem16(Off) #define LCD_WRITE_MEM(Off,Data) PC_WriteMem16(Off, Data) #define LCD_READ_REG(Off) PC_ReadReg16(Off) #define LCD_WRITE_REG(Off,Data) PC_WriteReg16(Off, Data) #endif#endif/********************************************************** Remap Hardware macros***********************************************************/#if LCD_NUM_DISPLAYS ==1 /* Use single display macros */#else #if LCD_DISPLAY_INDEX == 0 /* First display in a multi-display configuration */ #define LCD_READ_MEM(Off) LCD_READ_MEM_0(Off) #define LCD_WRITE_MEM(Off,Data) LCD_WRITE_MEM_0(Off,Data) #define LCD_READ_REG(Off) LCD_READ_REG_0(Off) #define LCD_WRITE_REG(Off,Data) LCD_WRITE_REG_0(Off,Data) #define LCD_INIT_CONTROLLER LCD_INIT_CONTROLLER_0 #else #define LCD_READ_MEM(Off) LCD_READ_MEM_1(Off) #define LCD_WRITE_MEM(Off,Data) LCD_WRITE_MEM_1(Off,Data) #define LCD_READ_REG(Off) LCD_READ_REG_1(Off) #define LCD_WRITE_REG(Off,Data) LCD_WRITE_REG_1(Off,Data) #define LCD_INIT_CONTROLLER LCD_INIT_CONTROLLER_1 #endif#endif/* ********************************************************* * * * Internal types * * * **********************************************************//* ********************************************************* * * * 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/* ********************************************************* * * * Macro calculations * * * **********************************************************//* 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#if LCD_BITSPERPIXEL == 1 #define BYTESPERLINE (LCD_VXSIZE_P/8) #define WORDSPERLINE (LCD_VXSIZE_P/16)#elif LCD_BITSPERPIXEL == 2 #define BYTESPERLINE (LCD_VXSIZE_P/4) #define WORDSPERLINE (LCD_VXSIZE_P/8)#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)#elif (LCD_BITSPERPIXEL == 16) #define BYTESPERLINE (LCD_VXSIZE_P*2) #define WORDSPERLINE (LCD_VXSIZE_P)#else #error This colordepth is not supported !!!#endif#ifndef LCD_USE_32BIT_OFF #if ((WORDSPERLINE * LCD_YSIZE) > 0xFFFF) #define LCD_USE_32BIT_OFF 1 #else #define LCD_USE_32BIT_OFF 0 #endif#endif#if LCD_USE_32BIT_OFF typedef unsigned long tOff;#else typedef unsigned int tOff;#endif/* ********************************************************* * * * Macros, standard * * * *********************************************************These macros can be found in any LCD-driver as they serve purposesthat can be found in any class of LCD-driver (Like clipping).*/#define BKCOLOR LCD_BKCOLORINDEX#define COLOR LCD_COLORINDEX/* ********************************************************* * * * 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#if ((LCD_CONTROLLER==1356)||(LCD_CONTROLLER==13806)) && (LCD_BUSWIDTH !=16) #error This controller does not work with 8-bit bus#endif#if (((LCD_CONTROLLER==1356)||(LCD_CONTROLLER==13806)) && LCD_USE_BITBLT && ((LCD_BITSPERPIXEL != 8) && (LCD_BITSPERPIXEL != 16))) #error BitBlt-Access only available for 8bpp and 16bpp mode#endif#if (LCD_CONTROLLER==1374) #if (LCD_BITSPERPIXEL == 8) #if (LCD_FIXEDPALETTE != 233) #error This controller supports only 233 palette in 8 bpp mode ! #endif #endif#endif/* ********************************************************* * * * Macros for internal use * * * **********************************************************/#if !defined (LCD_LUT_COM) #define LINE2COM(y) y#else #define LINE2COM(y) LCD__aLine2Com0[y]#endif#if LCD_BUSWIDTH == 16 #if (LCD_BITSPERPIXEL == 16) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)WORDSPERLINE+(x)) #elif (LCD_BITSPERPIXEL == 15) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)WORDSPERLINE+(x)) #elif (LCD_BITSPERPIXEL == 8) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)WORDSPERLINE+(x>>1)) #elif (LCD_BITSPERPIXEL == 4) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)WORDSPERLINE+(x>>2)) #elif (LCD_BITSPERPIXEL == 2) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)WORDSPERLINE+((x)>>3)) #elif (LCD_BITSPERPIXEL == 1) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)WORDSPERLINE+((x)>>4)) #endif#else #if (LCD_BITSPERPIXEL == 16) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)BYTESPERLINE+((x)<<1)) #elif (LCD_BITSPERPIXEL == 15) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)BYTESPERLINE+((x)<<1)) #elif (LCD_BITSPERPIXEL == 8) #define XY2OFF(x,y) (tOff)((tOff)LINE2COM(y)*(tOff)BYTESPERLINE+(x)) #elif (LCD_BITSPERPIXEL == 4)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -