lcdmemc.c
来自「瑞泰创新的GX-ARM9-2410EP教学实验系统UCOS移植源代码,包含GUI」· C语言 代码 · 共 1,152 行 · 第 1/3 页
C
1,152 行
/*
*********************************************************************************************************
* 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 : LCDMem.C
Purpose : Driver for LCDs using internal memory
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
2.01a 010927 JE a) Reworked to work with LCD_MIRROR_...
and LCD_SWAP_XY
2.01 010814 JE a) Support for 6bpp added,
HLine & 1bpp optimized
2.00 010402 RS a) LCD_GetDevCaps removed from driver
(now LCD.c)
0.92 000122 RS _GetPixel functionality written
0.91 000121 RS Default for LCD_VRAMTYPE defined
0.90 991205 RS Driver accelerated
0.00 990118 RS First release.
----------------------------------------------------------------------
Known problems or limitations with current version
----------------------------------------------------------------------
*/
/**************************************************************************
* *
* PROJECT : uc/GUI port for S3C2410 *
* *
* MODULE : LCDMemC.c *
* *
* AUTHOR : gexin *
* URL : http://www.gexin.com.cn *
* EMAIL: xgmygs@public.bta.net.cn *
* *
* PROCESSOR : S3c2410x (32 bit ARM920T RISC core from Samsung) *
* LCD : LQ035Q7DB02 (SHARP 3.5'' 240*320 16BIT TFT LCD) *
* *
* IDE : SDT 2.51 & ADS 1.2 *
* *
* DESCRIPTION : *
* This is the GUI driver module. *
* *
**************************************************************************/
#define LCDMEMC_C
#include "..\..\uCOS-II\ARM_UCOS\S3c2410x\inc\S3c2410x.h"
#include "..\..\uCOS-II\ARM_UCOS\common\inc\def.h"
#include <stdarg.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#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 */
#define SCR_XSIZE (240)
#define SCR_YSIZE (320)
#define SCR_XSIZE_TFT (240*2)
#define SCR_YSIZE_TFT (320*2)
#define COLOR_NUMBER 65535
#define BSWP 1 //LITTLE ENDIAN ,LCD DATA SWAP ENABLE
#define LCDFRAMEBUFFER 0x33800000 //_NONCACHE_STARTADDRESS
// 1. The LCD frame buffer should be write-through or non-cachable.
// 2. The total frame memory should be inside 4MB.
// 3. To meet above 2 conditions, the frame buffer should be
// inside the following regions.
// 0x31000000~0x313ffffff,
// 0x31400000~0x317ffffff,
// 0x31800000~0x31bffffff,
// .....
// 0x33800000~0x33bffffff
#define M5D(n) ((n) & 0x1fffff) // To get lower 21bits
/**************************************************************************
* *
* DESCRIPTION : LCD DEFINE *
* *
**************************************************************************/
#define UNDEFINE (0)
//LCD CON & ADDR Register Value
//LCDCON1_CLKVAL
#define CLKVAL (7) //Rate of VCLK and CLKVAL
//LCDCON1_MMODE
#define MMODE (0) //VM for Each Frame
//LCDCON1_PNRMODE
#define PNRMODE (3) //TFT LCD pannel
//LCDCON1_BPPMODE
#define BPPMODE (12) //16 bpp for TFT
//LCDCON1_ENVID
#define ENVID (0) //enable video output
//LCDCON2
#define VBPD (4) //Vertical back porch is the number of inactive lines at the start of a frame
#define LINEVAL (319) //Vertical size of LCD pannel
#define VFPD (1) //Vertical front porch
#define VSPW (1) //Vertical sync pulse width
//LCDCON3
#define HBPD (6) //Horizontal back porch is the number of VCLK periodes between the falling edge of HSYNC and the start of active data
#define HOZVAL (239) //Horizontal size of LCD pannel
#define HFPD (30) //Horizontal front porch is the number of VCLK periode between
//the end of active data and the rising edge of HSYNC
//LCDCON4
#define MVAL (13) //Rate at which the VM signal will toggle if the MMODE bit set to logic '1'
#define HSPW (3) //Horizontal sync pulse width
//LCDCON5
#define VSTATUS UNDEFINE
#define HSTATUS UNDEFINE
#define BPP24BL (0) //The order of 24 bpp video memory is LSB valid
#define FRM565 (1) //The format of 16 bpp is 5:6:5
#define INVVCLK (0) //VCLK active falling edge
#define INVVLINE (0) //VLINE/HSYNC signal polarity Normal
#define INVVFRAME (0) //VFRAME/VSYNC signal polarity Normal
#define INVVD (0) //INVVD signal polarity Normal
#define INVVDEN (0) //VDEN signal polarity Normal
#define INVPWREN (0) //PWREN signal polarity Normal
#define INVLEND (0) //LEND signal polarity Normal
#define PWREN (1) //LCD_PWREN output signal enable
#define ENLEND (0) //LEND output signal disable
#define BSWPLCD (0) //Byte swap disable
#define HWSWP (1) //Half-Word swap Enable
//#define HWSWP (0) //Half-Word swap Enable
//LCDADDR1
#define LCDBANK ((U32)LCDFRAMEBUFFER>>22)
#define LCDBASEU (M5D((U32)LCDFRAMEBUFFER>>1))
//LCDADDR2
//#define LCDBASEL (M5D( ((U32)LCDFRAMEBUFFER+(SCR_XSIZE_TFT*SCR_YSIZE*2))>>1 ))
#define LCDBASEL (M5D( ((U32)LCDFRAMEBUFFER+(SCR_XSIZE*SCR_YSIZE*2))>>1 ))
//LCDADDR3
//#define OFFSIZE ((SCR_XSIZE_TFT-SCR_XSIZE)/1)
#define OFFSIZE ((SCR_XSIZE-SCR_XSIZE)/1)
#define PAGEWIDTH (SCR_XSIZE/1)
#ifndef LCD_VRAMTYPE
#define LCD_VRAMTYPE
#endif
#if (LCD_CONTROLLER == 0) && (LCD_BITSPERPIXEL == 16) \
&& (!defined(WIN32) | defined(LCD_SIMCONTROLLER))
#define LCD_BYTESPERLINE LCD_VXSIZE_PHYS
#ifndef WIN32
U16 (* LCD_VRam)[LCD_VYSIZE_PHYS*LCD_BYTESPERLINE];
#else
// U8* pVRam;
#endif
/*
********************************************************************
* *
* Defaults for configuration *
* *
********************************************************************
Please be aware that not all configuration errors can be captured !
*/
#ifndef LCD_VERIFY
#define LCD_VERIFY (0)
#endif
/* Switch for support of multiple pages.
Only available with certain LCD-controllers */
#ifndef LCD_SUPPORT_PAGING
#define LCD_SUPPORT_PAGING (0)
#endif
/* Switch for support of run-time inversion of display. */
#ifndef LCD_SUPPORT_REVERSEMODE
#define LCD_SUPPORT_REVERSEMODE (0)
#endif
/* Switch support for the LCD_SetOrg function of the driver */
#ifndef LCD_SUPPORT_SETORG
#define LCD_SUPPORT_SETORG (1)
#endif
#ifndef LCD_SUPPORT_PALETTE
#define LCD_SUPPORT_PALETTE (1)
#endif
#ifndef LCD_SCHEDULE_CNT
#define LCD_SCHEDULE_CNT (0)
#endif
#ifndef LCD_ISRDATA
#define LCD_ISRDATA
#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
/*
********************************************************************
* *
* 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
#if LCD_SUPPORT_COMTRANS
extern U8 LCD__aLine2Com0[LCD_LASTCOM0-LCD_FIRSTCOM0+1];
#endif
#if LCD_SUPPORT_SEGTRANS
extern U8 LCD__aRow2Seg0[LCD_LASTSEG0-LCD_FIRSTSEG0+1];
#endif
/*
********************************************************************
* *
* Macro calculations *
* *
********************************************************************
*/
/* 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)
/* Define total number of used coms/segments */
#define LCD_NUM_SEGS LCD_NUM_SEGS0
#define LCD_NUM_COMS LCD_NUM_COMS0
#define BKCOLOR LCD_BKCOLORINDEX
#define COLOR LCD_COLORINDEX
/*
********************************************************************
* *
* Configuration switch checking *
* *
********************************************************************
Please be aware that not all configuration errors can be captured !
*/
/* Check if number of segments / coms equals resolution */
#if (LCD_NUM_SEGS < LCD_XSIZE_PHYS)
/* #error Please check segment setup of controller 0 and X/YSIZE !!!*/
#endif
#if (LCD_NUM_COMS < LCD_YSIZE_PHYS)
/* #error Please check com setup of controller 0 and X/YSIZE !!!*/
#endif
/*
********************************************************************
* *
* EXPORTs for ISR *
* *
********************************************************************
*/
#ifndef LCD_TIMERINIT1
#define LCD_TIMERINIT1 1599
#endif
#ifndef LCD_TIMERINIT0
#define LCD_TIMERINIT0 1065
#endif
LCD_ISRDATA U16 LCD__BitsPerPixel = LCD_BITSPERPIXEL/3;
LCD_ISRDATA U8 LCD_VRAMTYPE* LCD__apVRam[LCD_BITSPERPIXEL/3];
LCD_ISRDATA U16 LCD__aTimerReload[LCD_BITSPERPIXEL/3] = {
LCD_TIMERINIT0
#if LCD_BITSPERPIXEL/3 >1
,LCD_TIMERINIT1
#endif
};
/*
********************************************************************
*
* ID translation table
*
********************************************************************
This table contains 0, 1, 2, ... and serves as translation table for DDBs
*/
#define INTS(Base) Base+0,Base+1,Base+2,Base+3,Base+4,Base+5, \
Base+6,Base+7,Base+8,Base+9,Base+10,Base+11, \
Base+12,Base+13,Base+14,Base+15
static const LCD_PIXELINDEX aID[] = {
INTS(0),
#if LCD_MAX_LOG_COLORS > 0x10
INTS(0x10),
#endif
#if LCD_MAX_LOG_COLORS > 0x20
INTS(0x20),
INTS(0x30),
#endif
#if LCD_MAX_LOG_COLORS > 0x40
INTS(0x40),
INTS(0x50),
INTS(0x60),
INTS(0x70),
#endif
#if LCD_MAX_LOG_COLORS > 0x80
INTS(0x80),
INTS(0x90),
INTS(0xa0),
INTS(0xb0),
INTS(0xc0),
INTS(0xd0),
INTS(0xe0),
INTS(0xf0)
#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
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?