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

📄 data.c

📁 QNX ADS BSP code for i.MX27 chips
💻 C
字号:
/* * $QNXLicenseC:  * Copyright 2007, QNX Software Systems.   *   * Licensed under the Apache License, Version 2.0 (the "License"). You   * may not reproduce, modify or distribute this software except in   * compliance with the License. You may obtain a copy of the License   * at: http://www.apache.org/licenses/LICENSE-2.0   *   * Unless required by applicable law or agreed to in writing, software   * distributed under the License is distributed on an "AS IS" basis,   * WITHOUT WARRANTIES OF ANY KIND, either express or implied.  *  * This file may contain contributions from others, either as   * contributors under the License or as licensors under other terms.    * Please review this entire file for other proprietary rights or license   * notices, as well as the QNX Development Suite License Guide at   * http://licensing.qnx.com/license-guide/ for other information.  * $  */#include <stdlib.h>#include <string.h>#include <errno.h>#include "imx21.h"static char *imx21_opts[] = {#define I_X		0			"x",#define I_Y		1			"y",#define I_MBASE		2			"mmio",#define I_TFT		3			"tft",#define I_COLOR		4			"color",#define I_PBW		5			"pbw",#define I_PIXPOL	6			"pixpol",#define I_FLMPOL	7			"flmpol",#define I_LPPOL		8				"lppol",#define I_CLKPOL	9				"clkpol",#define I_OEPOL		10				"oepol",#define I_SCLKIDLE	11			"sclkidle",#define I_ENDIAN	12			"end_sel",#define I_SWAPSEL	13			"swap_sel",#define I_REV_VS	14			"rev_vs",#define I_ACDSEL	15			"acdsel",#define I_ACD		16			"acd",	#define I_SCLKSEL	17			"sclksel",	#define I_SHARP		18				"sharp",	#define I_HSW		19				"hsw",	#define I_HW1		20				"hw1",	#define I_HW2		21				"hw2",	#define I_VSW		22				"vsw",	#define I_VW1		23				"vw1",	#define I_VW2		24				"vw2",	#define I_PCD		25				"pcd",	#define i_CON		26			"con",#define i_DMA		27			"dma",#define i_PA1		28			"pa1",			NULL};intget_config_data(imx21_context_t *i_ctx, const char *filename){	FILE	*fin = NULL;	char	buf[512], *c, *opt, *value;	if (filename == NULL)		disp_printf(i_ctx->adapter,		    "No config file specified, using default parameters\n");	else if ((fin = fopen(filename, "r")) == NULL)		disp_printf(i_ctx->adapter,		    "Could not open config file \"%s\": %s\n",		    filename, strerror(errno));	/* set default valies */	i_ctx->width = 240;	i_ctx->height = 320;        i_ctx->regbase = LCDC_REG_BASE;        i_ctx->cregbase = PLL_REG_BASE;	i_ctx->gregbase = GPIO_REG_BASE;	i_ctx->mmiobase = MMIO_BASE;        i_ctx->tft = 1;        i_ctx->color = 1;        i_ctx->pixpol = 1;        i_ctx->flmpol = 0;        i_ctx->lppol = 0;        i_ctx->clkpol = 0;        i_ctx->oepol = 1;        i_ctx->sclkidle = 0;        i_ctx->end_sel = 0; /* make LCD controller little end_sel */        i_ctx->swap_sel = 0;        i_ctx->rev_vs = 0;        i_ctx->sclksel = 1;         i_ctx->sharp = 0x120300;	i_ctx->pcd = 8;	i_ctx->contrast = 0xA903ff;	i_ctx->dma = 0x20008;	i_ctx->pa1 = 0;	i_ctx->hsw = 2;	i_ctx->hw1 = 16;	i_ctx->hw2 = 9;	i_ctx->vsw = 1;	i_ctx->vw1 = 9;	i_ctx->vw2 = 7;        /* not applicable to tft:		i_ctx->pbsiz        	i_ctx->acdsel;        	i_ctx->acd;	*/	/* use defaults */	if (fin == NULL) {		return 0;	}	while (fgets(buf, sizeof (buf), fin) != NULL) {		c = buf;		while (*c == ' ' || *c == '\t')			c++;		if (*c == '\015' || *c== '\032' || *c == '\0' || *c == '\n' || *c == '#')			continue;		opt = c;		while (*c == '\015' || *c== '\032' || *c != '\0' && *c != '\n' && *c != '#')			c++;		*c = '\0';		break;	}	while (*opt != '\0') {		c = opt;		switch (getsubopt(&opt, imx21_opts, &value)) {		case I_X:			i_ctx->width = strtol(value, NULL, 0);			break;		case I_Y:			i_ctx->height = strtol(value, NULL, 0);			break;		case I_MBASE:			i_ctx->mmiobase = strtoul(value, NULL, 0);			break;		case I_TFT:			i_ctx->tft = strtol(value, NULL, 0);			if (i_ctx->tft)				i_ctx->tft = 1;			break;		case I_COLOR:			i_ctx->color = strtol(value, NULL, 0);			if (i_ctx->color)				i_ctx->color = 1;			break;		case I_PBW:			i_ctx->pbsiz = strtol(value, NULL, 0);			break;		case I_PIXPOL:			i_ctx->pixpol = strtol(value, NULL, 0);			if (i_ctx->pixpol)				i_ctx->pixpol = 1;			break;		case I_FLMPOL:			i_ctx->flmpol = strtol(value, NULL, 0);			if (i_ctx->flmpol)				i_ctx->flmpol = 1;			break;		case I_LPPOL:			i_ctx->lppol = strtol(value, NULL, 0);			if (i_ctx->lppol)				i_ctx->lppol = 1;			break;		case I_CLKPOL:			i_ctx->clkpol = strtol(value, NULL, 0);			if (i_ctx->clkpol)				i_ctx->clkpol = 1;			break;		case I_OEPOL:			i_ctx->oepol = strtol(value, NULL, 0);			if (i_ctx->oepol)				i_ctx->oepol = 1;			break;		case I_SCLKIDLE:			i_ctx->sclkidle = strtol(value, NULL, 0);			if (i_ctx->sclkidle)				i_ctx->sclkidle = 1;			break;		case I_ENDIAN:			i_ctx->end_sel = strtol(value, NULL, 0);			if (i_ctx->end_sel)				i_ctx->end_sel = 1;			break;		case I_SWAPSEL:			i_ctx->swap_sel = strtol(value, NULL, 0);			if (i_ctx->swap_sel)				i_ctx->swap_sel = 1;			break;		case I_REV_VS:			i_ctx->rev_vs = strtol(value, NULL, 0);			if (i_ctx->rev_vs)				i_ctx->rev_vs = 1;			break;		case I_ACDSEL:			i_ctx->acdsel = strtol(value, NULL, 0);			if (i_ctx->acdsel)				i_ctx->acdsel = 1;			break;		case I_ACD:			i_ctx->acd = strtol(value, NULL, 0);			break;		case I_SCLKSEL:			i_ctx->sclksel = strtol(value, NULL, 0);			if (i_ctx->sclksel)				i_ctx->sclksel = 1;			break;		case I_SHARP:				i_ctx->sharp = strtol(value, NULL, 0);			break;		case I_HSW:				i_ctx->hsw = strtol(value, NULL, 0);			break;		case I_HW1:			i_ctx->hw1 = strtol(value, NULL, 0);			break;		case I_HW2:				i_ctx->hw2 = strtol(value, NULL, 0);			break;		case I_VSW:				i_ctx->vsw = strtol(value, NULL, 0);			break;		case I_VW1:				i_ctx->vw1 = strtol(value, NULL, 0);			break;		case I_VW2:				i_ctx->vw2 = strtol(value, NULL, 0);			break;		case I_PCD:				i_ctx->pcd = strtol(value, NULL, 0);			break;		case i_CON:			i_ctx->contrast = strtol(value, NULL, 0);			break;		case i_DMA:			i_ctx->dma = strtol(value, NULL, 0);			break;		case i_PA1:			i_ctx->pa1 = strtol(value, NULL, 0);			break;		default:			disp_printf(i_ctx->adapter, "Unknown option %s\n", c);			break;		}	}	fclose(fin);	return 0;}

⌨️ 快捷键说明

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