源码地址:https://github.com/774639008/MyProject/commit/2129384d2e0004dc859caa4d8b81d8669ecf5850?diff=unified
lcd.c文件如下
#include <s3c2440.h>
#include <string.h>
#include "lcd.h"
#include "type.h"
//1.LCDCON1的控制寄存器参数
#define CLKVAL (4 << 8) //设置公式:VCLK=HCLK / [(CLKVAL + 1) × 2] (CLKVAL≥0)
#define MMODE (0 << 7) //VM触发频率,TFT不用,设置为0
#define PNRMODE (3 << 5) //显示模式 TFT 11
#define BEEMODE (12 << 1) //像素点位数,TFT 16位模式:1100
#define ENVID (0 << 0) //控制视频输出,也就是EN位,先默认关闭
#define LCDCON_VAL1 (CLKVAL | MMODE | PNRMODE | BEEMODE | ENVID)
//2.LCDCON2
#define VBPD (2 << 24) //垂直同步信号周期后无效的行数
#define LINEVAL ((LCD_HIGH-1) << 14) //LCD的垂直尺寸(高度)
#define VFPD (2 << 6) //垂直同步周期信号
#define VSPW (10 << 0)
#define LCDCON_VAL2 (VBPD | LINEVAL | VFPD | VSPW)
//LCDCON3
#define HBPD (2 << 19)
#define HOZVAL ((LCD_WIDTH-1) << 8)
#define HFPD (2 << 0)
#define LCDCON_VAL3 (HBPD | HOZVAL | HFPD)
//LCDCON4
#define HSPW (40 << 0) //TYP=41标准再减1
#define LCDCON_VAL4 HSPW
//LCDCON5
#define BPP24BL (0 << 12)
#define FRM565 (1 << 11)
//时序图引脚翻转配置
#define INVVCLK (0x0 << 10)
#define INVLINE (0x1 << 9)
#define INVFRAME (0x1 << 8)
#define INVVD (0x0 << 7)
#define INVVDEN (0x1 << 6)
#define INVPWREN (0x0 << 5)
#define INVLEND (0x0 << 4)
#define PWREN (0 << 3)
#define ENLEND (0 << 2)
#define BSWP (0x0 << 1)
#define HWSWP (0x1 << 0)
#define LCDCON_VAL5 (BPP24BL | FRM565 | INVVCLK | INVLINE | \
INVFRAME | INVVD | INVVDEN | INVPWREN | \
INVLEND | PWREN | ENLEND | BSWP | HWSWP)
static volatile rgb_t G_lcdBuffer[LCD_HIGH][LCD_WIDTH];
//LCD缓冲区,用来给数据
#define LCDBASE ((unsigned long)G_lcdBuffer)
//配置缓冲区地址
#define LCDBANK (((LCDBASE >>22) & 0x1FF) << 21)
#define LCDBASEU ((LCDBASE >>1) & 0x1FFFFF << 0)
#define vLCDADDR1 (LCDBANK | LCDBASEU)
#define LCDBASEL (((LCDBASE + LCD_WIDTH * LCD_HIGH * 2) >> 1) & 0x1FFFFF)
#define vLCDADDR2 LCDBASEL
#define OFFSIZE 0x0
#define PAGEWIDTH (LCD_WIDTH)
#define vLCDADDR3 (OFFSIZE | PAGEWIDTH)
//帧缓冲区 一帧的数据,所有的像素点,16位
typedef unsigned short RGB_COLOR;
volatile RGB_COLOR frameBuf