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

📄 vfd.c

📁 AT91RM9200的完整启动代码:包括loader, boot及U-boot三部分均已编译通过!欢迎下载使用!
💻 C
📖 第 1 页 / 共 2 页
字号:
void set_vfd_pixel(unsigned char x, unsigned char y,		   unsigned char color, unsigned char display,		   unsigned char value){	DECLARE_GLOBAL_DATA_PTR;	ulong adr;	unsigned char bit_nr, temp;	if (! gd->vfd_type) {		/* Unknown type. */		return;	}	/* Pixel-Eintrag Nr. 1 */	adr = adr_vfd_table[x][y][color][display][0];	/* Pixel-Eintrag Nr. 1 */	bit_nr = bit_vfd_table[x][y][color][display][0];	temp=(*(volatile unsigned char*)(adr));	if (value)		temp |=  (1<<bit_nr);	else		temp &= ~(1<<bit_nr);	(*(volatile unsigned char*)(adr))=temp;}/* * transfer image from BMP-File */void transfer_pic(int display, unsigned char *adr, int height, int width){	int x, y;	unsigned char temp;	for (; height > 0; height -= 18)	{		if (height > 18)			y = 18;		else			y = height;		for (; y > 0; y--)		{			for (x = 0; x < width; x += 2)			{				temp = *adr++;				set_vfd_pixel(x, y-1, 0, display, 0);				set_vfd_pixel(x, y-1, 1, display, 0);				if ((temp >> 4) == BLAU)					set_vfd_pixel(x, y-1, 0, display, 1);				else if ((temp >> 4) == ROT)					set_vfd_pixel(x, y-1, 1, display, 1);				else if ((temp >> 4) == VIOLETT)				{					set_vfd_pixel(x, y-1, 0, display, 1);					set_vfd_pixel(x, y-1, 1, display, 1);				}				set_vfd_pixel(x+1, y-1, 0, display, 0);				set_vfd_pixel(x+1, y-1, 1, display, 0);				if ((temp & 0x0F) == BLAU)					set_vfd_pixel(x+1, y-1, 0, display, 1);				else if ((temp & 0x0F) == ROT)					set_vfd_pixel(x+1, y-1, 1, display, 1);				else if ((temp & 0x0F) == VIOLETT)				{					set_vfd_pixel(x+1, y-1, 0, display, 1);					set_vfd_pixel(x+1, y-1, 1, display, 1);				}			}		}		if (display > 0)			display--;		else			display = 3;	}}/* * This function initializes VFD clock that is needed for the CPLD that * manages the keyboard. */int vfd_init_clocks (void){	/* try to determine display type from the value	 * defined by pull-ups	 */	rPCUP = (rPCUP & 0xFFF0);	/* activate  GPC0...GPC3 pullups */	rPCCON = (rPCCON & 0xFFFFFF00);	/* configure GPC0...GPC3 as inputs */	udelay (10);				/* allow signals to settle */	vfd_board_id = (~rPCDAT) & 0x000F;	/* read GPC0...GPC3 port pins */	VFD_DISABLE;				/* activate blank for the vfd */#define	NEW_CPLD_CLK#ifdef NEW_CPLD_CLK	if (vfd_board_id) {		/* If new board revision, then use PWM 3 as cpld-clock */		/* Enable 500 Hz timer for fill level sensor to operate properly */		/* Configure TOUT3 as functional pin, disable pull-up */		rPDCON &= ~0x30000;		rPDCON |= 0x20000;		rPDUP |= (1 << 8);		/* Configure the prescaler */		rTCFG0 &= ~0xff00;		rTCFG0 |= 0x0f00;		/* Select MUX input (divider) for timer3 (1/16) */		rTCFG1 &= ~0xf000;		rTCFG1 |= 0x3000;		/* Enable autoreload and set the counter and compare		 * registers to values for the 500 Hz clock		 * (for a given  prescaler (15) and divider (16)):		 * counter = (66000000 / 500) >> 9;		 */		rTCNTB3 = 0x101;		rTCMPB3 = 0x101 / 2;		/* Start timer */		rTCON = (rTCON | UPDATE3 | RELOAD3) & ~INVERT3;		rTCON = (rTCON | START3) & ~UPDATE3;	}#endif	/* If old board revision, then use vm-signal as cpld-clock */	rLCDCON2 = 0x00FFC000;	rLCDCON3 = 0x0007FF00;	rLCDCON4 = 0x00000000;	rLCDCON5 = 0x00000400;	rLCDCON1 = 0x00000B75;	/* VM (GPD1) is used as clock for the CPLD */	rPDCON = (rPDCON & 0xFFFFFFF3) | 0x00000008;	return 0;}/* * initialize LCD-Controller of the S3C2400 for using VFDs * * VFD detection depends on the board revision: * starting from Rev. 200 a type code can be read from the data pins, * driven by some pull-up resistors; all earlier systems must be * manually configured. The type is set in the "vfd_type" environment * variable. */int drv_vfd_init(void){	char *tmp;	ulong palette;	static int vfd_init_done = 0;	int vfd_inv_data = 0;	DECLARE_GLOBAL_DATA_PTR;	if (vfd_init_done != 0)		return (0);	vfd_init_done = 1;	debug("Detecting Revison of WA4-VFD: ID=0x%X\n", vfd_board_id);	switch (vfd_board_id) {	case 0:			/* board revision < Rev.200 */		if ((tmp = getenv ("vfd_type")) == NULL) {			break;		}		if (strcmp(tmp, "T119C") == 0) {			gd->vfd_type = VFD_TYPE_T119C;		} else if (strcmp(tmp, "MN11236") == 0) {			gd->vfd_type = VFD_TYPE_MN11236;		} else {			/* cannot use printf for a warning here */			gd->vfd_type = 0;	/* unknown */		}		break;	default:		/* default to MN11236, data inverted */		gd->vfd_type = VFD_TYPE_MN11236;		vfd_inv_data = 1;		setenv ("vfd_type", "MN11236");	}	debug ("VFD type: %s%s\n",		(gd->vfd_type == VFD_TYPE_T119C)   ? "T119C" :		(gd->vfd_type == VFD_TYPE_MN11236) ? "MN11236" :		"unknown",		vfd_inv_data ? ", inverted data" : "");	gd->fb_base = gd->fb_base;	create_vfd_table();	init_grid_ctrl();	for (palette=0; palette < 16; palette++)		(*(volatile unsigned int*)(PALETTE+(palette*4)))=palette;	for (palette=16; palette < 256; palette++)		(*(volatile unsigned int*)(PALETTE+(palette*4)))=0x00;	/*	 * Hinweis: Der Framebuffer ist um genau ein Nibble verschoben	 * Das erste angezeigte Pixel wird aus dem zweiten Nibble geholt	 * das letzte angezeigte Pixel wird aus dem ersten Nibble geholt	 * (wrap around)	 * see manual S3C2400	 */	/* Stopp LCD-Controller */	rLCDCON1 = 0x00000000;	/* frame buffer startadr */	rLCDSADDR1 = gd->fb_base >> 1; 	/* frame buffer endadr */	rLCDSADDR2 = (gd->fb_base + FRAME_BUF_SIZE) >> 1;	rLCDSADDR3 = ((256/4));rLCDCON2 = 0x000DC000;	if(gd->vfd_type == VFD_TYPE_MN11236)		rLCDCON2 = 37 << 14;	/* MN11236: 38 lines */	else		rLCDCON2 = 55 << 14;	/* T119C:   56 lines */	rLCDCON3 = 0x0051000A;	rLCDCON4 = 0x00000001;	if (gd->vfd_type && vfd_inv_data)		rLCDCON5 = 0x000004C0;	else		rLCDCON5 = 0x00000440;	/* Port pins as LCD output */	rPCCON =   (rPCCON & 0xFFFFFF00)| 0x000000AA;	rPDCON =   (rPDCON & 0xFFFFFF03)| 0x000000A8;	/* Synchronize VFD enable with LCD controller to avoid flicker	*/	rLCDCON1 = 0x00000B75;			/* Start LCD-Controller	*/	while((rLCDCON5 & 0x180000)!=0x100000);	/* Wait for end of VSYNC */	while((rLCDCON5 & 0x060000)!=0x040000);	/* Wait for next HSYNC	*/	while((rLCDCON5 & 0x060000)==0x040000);	while((rLCDCON5 & 0x060000)!=0x000000);	if(gd->vfd_type)		VFD_ENABLE;	debug ("LCDSADDR1: %lX\n", rLCDSADDR1);	debug ("LCDSADDR2: %lX\n", rLCDSADDR2);	debug ("LCDSADDR3: %lX\n", rLCDSADDR3);	return 0;}/* * Disable VFD: should be run before resetting the system: * disable VM, enable pull-up */void disable_vfd (void){	VFD_DISABLE;	rPDCON &= ~0xC;	rPDUP  &= ~0x2;}/************************************************************************//* ** ROM capable initialization part - needed to reserve FB memory	*//************************************************************************//* * This is called early in the system initialization to grab memory * for the VFD controller. * * Note that this is running from ROM, so no write access to global data. */ulong vfd_setmem (ulong addr){	ulong size;	/* Round up to nearest full page */	size = (FRAME_BUF_SIZE + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);	debug ("Reserving %ldk for VFD Framebuffer at: %08lx\n", size>>10, addr);	return (size);}#endif /* CONFIG_VFD */

⌨️ 快捷键说明

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