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

📄 options.c

📁 qnx powerpc MPC8245的 BSP源文件
💻 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.  * $  *//*#ifdef __USAGE%C - Serial driver for 8250's%C [options] [port[^shift][,irq]] &Options: -b number    Define initial baud rate (default 57600) -c clk[/div] Set the input clock rate and divisor -C number    Size of canonical input buffer (default 256) -e           Set options to "edit" mode -E           Set options to "raw" mode (default) -I number    Size of raw input buffer (default 2048) -f           Enable hardware flow control (default) -F           Disable hardware flow control -O number    Size of output buffer (default 2048) -s           Enable software flow control -S           Disable software flow control (default) -t number    Enable recieve FIFO and set receive FIFO trigger level -T number    Enable transmit FIFO and set transmit FIFO size -u unit      Set serial unit number (default 1)#endif*/#include "externs.h"unsignedoptions(int argc, char *argv[]) {	int opt, numports = 0;	char *cp;	void *link;	unsigned unit;	unsigned fifo_tx = 0, fifo_rx = 0;	static TTYINIT devinit ={		0, 0, 0, 57600,		2048, 2048, 256,		0, 0, 0, 0, 0, 0, 0,		"/dev/ser" };	// Initialize the devinit to raw mode	ttc(TTC_INIT_RAW, &devinit, 0);	sys_ttyinit(&devinit);		unit = 1;	while(optind < argc) {		// Process dash options.		while((opt = getopt(argc, argv, IO_CHAR_SERIAL_OPTIONS "c:t:T:u:")) != -1) {				switch(ttc(TTC_SET_OPTION, &devinit, opt)) {			case 'c':				devinit.clk = strtoul(optarg, &optarg, 0);				if((cp = strchr(optarg, '/'))) {					devinit.div = strtoul(cp + 1, NULL, 0);				}				break;			case 't':				fifo_rx = strtoul(optarg, NULL, 0);				if( !((fifo_rx == 1) || (fifo_rx == 4) || (fifo_rx == 8) || (fifo_rx == 14)) ) {					fprintf(stderr,"Illegal rx fifo trigger. \n");					fprintf(stderr,"Trigger number must be 1, 4, 8 or 14. \n");					fprintf(stderr,"Rx trigger will not be enabled.\n\n");					fifo_rx = 0;				}				break;			case 'T':				fifo_tx = strtoul(optarg, NULL, 0);				if( !((fifo_tx == 1) || (fifo_tx == 4) || (fifo_tx == 8) || (fifo_tx == 14)) ) {					fprintf(stderr,"Illegal tx fifo size. \n");					fprintf(stderr,"Tx fifo size must be 1, 4, 8 or 14. \n");					fprintf(stderr,"Tx fifo will not be enabled.\n\n");					fifo_tx = 0;				}                break;			case 'u':				unit = strtoul(optarg, NULL, 0);				break;			}		}        //Store the rx and tx fifo's		devinit.fifo = fifo_rx | (fifo_tx << 4);		// Process ports and interrupts.		while(optind < argc  &&  *(optarg = argv[optind]) != '-') {			devinit.port = strtoull(optarg, &optarg, 16);			if(*optarg == '^') {				devinit.port_shift = strtoul(optarg + 1, &optarg, 0);			}			if(*optarg == ',') {				devinit.intr = strtoul(optarg + 1, NULL, 0);			}			create_device(&devinit, unit++);			++numports;			++optind;		}	}	if(numports == 0) {		link = NULL;		for( ;; ) {			link = query_default_device(&devinit, link);			if(link == NULL) break;			create_device(&devinit, unit++);			++numports;		}	}	return(numports);}

⌨️ 快捷键说明

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