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

📄 lcd.c

📁 基于EP7312 MCU和uC/OS-II的CAN BUS通讯程序
💻 C
字号:
/*
 * $Id: lcd.c,v 1.2 2003/08/29 03:13:18 casic Exp $
 *
 * lcd.c : LCD driver
 *
 * Copyright (C) 2003 ynding ( haoanian@263.net )
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
#include "ep7312.h"
#include "lcd.h"
#include "color.h"
#include "graphic.h"

/* Configuration of LCD */
void setup_lcd(void)
{

	/* LCDEN[12] = 0 : Disable LCD before setting the registers of LCD */
	rSYSCON1 &= ~0x00001000;

	/*
	 * set LCD Control Register
	 * Video Buffer Size[0:12] : 320*240*12 / 128 = 0x1c1f
	 * Line Length[13:18] : 320 / 16 -1 = 0x13
	 * Pixel Prescale[19:24] : 0x01
	 * AC Prescale[25:29] : 0x13
	 * GSEN[30] : =1,Enables gray scale output to LCD
	 * GSMD[31] : =1,4 bpp ( 16-gray scale )
	 */
	rLCDCON = 0xe60f7c1f;

	/* Set Least/Most Significant Word - Set LCD Palette Register */
	rPALLSW = 0x76543210;
	rPALMSW = 0xfedcba98;

	/*
	 * Sets the start location in system memory for LCD frame buffer
	 * thus, the frame buffer starts from the location 0xc0000000
	 * in system memory
	 */
	rFBADDR = 0xc;

	/* LCDEN[12] = 1 : Enable LCD after the LCD configuration */
	rSYSCON1 |= 0x00001000;
        
	return;
}

void clear_lcd(void)
{
	unsigned char *base = (unsigned char*)0xc0000000;
	int i;

	/* clear from the beginning of the frame buffer until the end of it */
	for ( i=0;i<320*240*12/8;i++ ) {
		*base++ = 0x77;
	}

	return;
}
void clear_local_lcd(unsigned int x, unsigned int y,int k)
{

	int i = 0,m;
	unsigned int x1,y1;
	x1 = x;
	y1 = y;
	for( m=0;m<k;m++ )
	{
		x = (x1+m)*8;
		y = y1*16;

		/* total 16 bytes codes*/
		for ( i=0;i<16;++i ) {
			int j = 0;
			x += 8;

			for ( j=0;j<8;++j ) {
				--x;
				draw_dot(x,y,GRAY);
			
			}

			/* move to the next line : x axis unchanged, y axis increase 1 */
			++y;
		}
	}
	return;

		
}
void init_lcd(void)
{
	setup_lcd();
	clear_lcd();

	return;
}

⌨️ 快捷键说明

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