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

📄 vfd.c

📁 AT91RM9200的完整启动代码:包括loader, boot及U-boot三部分均已编译通过!欢迎下载使用!
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * (C) Copyright 2001 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de * * See file CREDITS for list of people who contributed to this * project. * * 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 *//************************************************************************//* ** DEBUG SETTINGS							*//************************************************************************//* #define DEBUG	*//************************************************************************//* ** HEADER FILES							*//************************************************************************/#include <config.h>#include <common.h>#include <version.h>#include <stdarg.h>#include <linux/types.h>#include <devices.h>#include <s3c2400.h>#ifdef CONFIG_VFD/************************************************************************//* ** CONFIG STUFF -- should be moved to board config file		*//************************************************************************//************************************************************************/#ifndef PAGE_SIZE#define	PAGE_SIZE	4096#endif#define ROT	0x09#define BLAU	0x0C#define VIOLETT	0X0D/* MAGIC */#define	FRAME_BUF_SIZE	((256*4*56)/8)#define frame_buf_offs 4/* defines for starting Timer3 as CPLD-Clk */#define START3			(1 << 16)#define UPDATE3			(1 << 17)#define INVERT3			(1 << 18)#define RELOAD3			(1 << 19)/* CPLD-Register for controlling vfd-blank-signal */#define VFD_DISABLE	(*(volatile uchar *)0x04038000=0x0000)#define VFD_ENABLE	(*(volatile uchar *)0x04038000=0x0001)/* Supported VFD Types */#define	VFD_TYPE_T119C		1	/* Noritake T119C VFD */#define	VFD_TYPE_MN11236	2/*#define NEW_CPLD_CLK*/int vfd_board_id;/* taken from armboot/common/vfd.c */unsigned long adr_vfd_table[112][18][2][4][2];unsigned char bit_vfd_table[112][18][2][4][2];/* * initialize the values for the VFD-grid-control in the framebuffer */void init_grid_ctrl(void){	DECLARE_GLOBAL_DATA_PTR;	ulong adr, grid_cycle;	unsigned int bit, display;	unsigned char temp, bit_nr;	/*	 * clear frame buffer (logical clear => set to "black")	 */	memset ((void *)(gd->fb_base), 0, FRAME_BUF_SIZE);	switch (gd->vfd_type) {	case VFD_TYPE_T119C:	    for (display=0; display<4; display++) {		for(grid_cycle=0; grid_cycle<56; grid_cycle++) {			bit = grid_cycle * 256  * 4 +			     (grid_cycle + 200) * 4 +			     frame_buf_offs + display; 			/* wrap arround if offset (see manual S3C2400) */			if (bit>=FRAME_BUF_SIZE*8)				bit = bit - (FRAME_BUF_SIZE * 8);			adr = gd->fb_base + (bit/32) * 4 + (3 - (bit%32) / 8);			bit_nr = bit % 8;			bit_nr = (bit_nr > 3) ? bit_nr-4 : bit_nr+4;			temp=(*(volatile unsigned char*)(adr));			temp |=  (1<<bit_nr);			(*(volatile unsigned char*)(adr))=temp;			if(grid_cycle<55)				bit = grid_cycle*256*4+(grid_cycle+201)*4+frame_buf_offs+display;			else				bit = grid_cycle*256*4+200*4+frame_buf_offs+display-4; 	/* grid nr. 0 */			/* wrap arround if offset (see manual S3C2400) */			if (bit>=FRAME_BUF_SIZE*8)				bit = bit-(FRAME_BUF_SIZE*8);			adr = gd->fb_base+(bit/32)*4+(3-(bit%32)/8);			bit_nr = bit%8;			bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;			temp=(*(volatile unsigned char*)(adr));			temp |=  (1<<bit_nr);			(*(volatile unsigned char*)(adr))=temp;		}	    }	    break;	case VFD_TYPE_MN11236:	    for (display=0; display<4; display++) {		for (grid_cycle=0; grid_cycle<38; grid_cycle++) {			bit = grid_cycle * 256  * 4 +			     (253 - grid_cycle) * 4 +			     frame_buf_offs + display;			/* wrap arround if offset (see manual S3C2400) */			if (bit>=FRAME_BUF_SIZE*8)				bit = bit - (FRAME_BUF_SIZE * 8);			adr = gd->fb_base + (bit/32) * 4 + (3 - (bit%32) / 8);			bit_nr = bit % 8;			bit_nr = (bit_nr > 3) ? bit_nr-4 : bit_nr+4;			temp=(*(volatile unsigned char*)(adr));			temp |=  (1<<bit_nr);			(*(volatile unsigned char*)(adr))=temp;			if(grid_cycle<37)				bit = grid_cycle*256*4+(252-grid_cycle)*4+frame_buf_offs+display;			/* wrap arround if offset (see manual S3C2400) */			if (bit>=FRAME_BUF_SIZE*8)				bit = bit-(FRAME_BUF_SIZE*8);			adr = gd->fb_base+(bit/32)*4+(3-(bit%32)/8);			bit_nr = bit%8;			bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;			temp=(*(volatile unsigned char*)(adr));			temp |=  (1<<bit_nr);			(*(volatile unsigned char*)(adr))=temp;		}	    }	    break;	default:	    printf ("Warning: unknown display type\n");	    break;	}}/* *create translation table for getting easy the right position in the *physical framebuffer for some x/y-coordinates of the VFDs */void create_vfd_table(void){	DECLARE_GLOBAL_DATA_PTR;	unsigned long vfd_table[112][18][2][4][2];	unsigned int x, y, color, display, entry, pixel;	unsigned int x_abcdef = 0;	switch (gd->vfd_type) {	case VFD_TYPE_T119C:	    for(y=0; y<=17; y++) {	/* Line */		for(x=0; x<=111; x++) {	/* Column */		    for(display=0; display <=3; display++) {			    /* Display 0 blue pixels */			    vfd_table[x][y][0][display][0] =				(x==0) ? y*16+display				       : (x%4)*4+y*16+((x-1)/2)*1024+display;			    /* Display 0 red pixels */			    vfd_table[x][y][1][display][0] =				(x==0) ? y*16+512+display			    	       : (x%4)*4+y*16+((x-1)/2)*1024+512+display;		    }		}	    }	    break;	case VFD_TYPE_MN11236:	    for(y=0; y<=17; y++) {	/* Line */		for(x=0; x<=111; x++) {	/* Column */		    for(display=0; display <=3; display++) {			    vfd_table[x][y][0][display][0]=0;			    vfd_table[x][y][0][display][1]=0;			    vfd_table[x][y][1][display][0]=0;			    vfd_table[x][y][1][display][1]=0;			    switch (x%6) {			    case 0: x_abcdef=0; break; /* a -> a */			    case 1: x_abcdef=2; break; /* b -> c */			    case 2: x_abcdef=4; break; /* c -> e */			    case 3: x_abcdef=5; break; /* d -> f */			    case 4: x_abcdef=3; break; /* e -> d */			    case 5: x_abcdef=1; break; /* f -> b */			    }			    /* blue pixels */			    vfd_table[x][y][0][display][0] =				(x>1) ? x_abcdef*4+((x-1)/3)*1024+y*48+display				      : x_abcdef*4+             0+y*48+display;			    /* blue pixels */			    if (x>1 && (x-1)%3)				    vfd_table[x][y][0][display][1] = x_abcdef*4+((x-1)/3+1)*1024+y*48+display;			    /* red pixels */			    vfd_table[x][y][1][display][0] =				(x>1) ? x_abcdef*4+24+((x-1)/3)*1024+y*48+display				      : x_abcdef*4+24+             0+y*48+display;			    /* red pixels */			    if (x>1 && (x-1)%3)				    vfd_table[x][y][1][display][1] = x_abcdef*4+24+((x-1)/3+1)*1024+y*48+display;		    }		}	    }	    break;	default:	    /* do nothing */	    return;	}	/*	 * Create table with entries for physical byte adresses and	 * bit-number within the byte	 * from table with bit-numbers within the total framebuffer	 */	for(y=0;y<18;y++) {	    for(x=0;x<112;x++) {		for(color=0;color<2;color++) {		    for(display=0;display<4;display++) {			for(entry=0;entry<2;entry++) {			    unsigned long adr  = gd->fb_base;			    unsigned int bit_nr = 0;			    if (vfd_table[x][y][color][display][entry]) {				pixel  = vfd_table[x][y][color][display][entry] + frame_buf_offs;				 /*				  * wrap arround if offset				  * (see manual S3C2400)				  */				if (pixel>=FRAME_BUF_SIZE*8)					pixel = pixel-(FRAME_BUF_SIZE*8);				adr    = gd->fb_base+(pixel/32)*4+(3-(pixel%32)/8);				bit_nr = pixel%8;				bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;			    }			    adr_vfd_table[x][y][color][display][entry] = adr;			    bit_vfd_table[x][y][color][display][entry] = bit_nr;			}		    }		}	    }	}}/* * Set/clear pixel of the VFDs */

⌨️ 快捷键说明

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