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

📄 usrserial.c

📁 powerPC866 系列平台BSP移植开发的参考代码
💻 C
字号:
/* usrSerial.c - serial device configuration file */

/* Copyright 1984-2001 Wind River Systems, Inc. */

/*
modification history
--------------------
01d,05jan01,lmk  allow use of console baud set by Planet Core boot params
01c,24feb99,pr   added control for PC_CONSOLE in IO initialization (SPR#23075)
01b,11oct97,ms   use itos instead of sprintf to break dependecy on fioLib
01a,09oct97,ms   taken from usrConfig.c
*/

/*
DESCRIPTION

User configurable serial device intialization.
*/
#include "ep8xx.h"

#define	TY_NAME_BASE	"/tyCo/"

/******************************************************************************
*
* itos - given an integer, return a string representing it.
*/

static char * itos (int val)
    {
    static char str [20];
    char strtmp [20];
    str [0] = '\0';

    if (val == 0)
	return "0";

    while (val != 0)
	{
	strcpy (strtmp, str);
	str[0] = '0' + (val % 10);
	str[1] = '\0';
	strcat (str, strtmp);
	val = val - (val %= 10);
	}

    return str;
    }

/******************************************************************************
*
* usrSerialInit - initialize the serial ports
*/

STATUS usrSerialInit (void)
    {
    EPCFG *cfg = getEpCfg();
    char tyName [20];
    int ix;

    if (NUM_TTY > 0)
	{
	ttyDrv();				/* install console driver */

	for (ix = 0; ix < NUM_TTY; ix++)	/* create serial devices */
	    {
#if     (defined(INCLUDE_WDB) && defined(INCLUDE_WDB_COMM_SERIAL))
	    if (ix == WDB_TTY_CHANNEL)		/* don't use WDBs channel */
		continue;
#endif
	    tyName[0] = '\0';
	    strcat (tyName, TY_NAME_BASE);
	    strcat (tyName, itos (ix));
	    (void) ttyDevCreate (tyName, sysSerialChanGet(ix), 512, 512);

#if  (!(defined(INCLUDE_PC_CONSOLE)))

	    if (ix == CONSOLE_TTY)		/* init the tty console */
		{
		consoleFd = open (tyName, O_RDWR, 0);

		(void) ioctl (consoleFd, FIOBAUDRATE, cfg->sysConsoleBaud);

		(void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);
		}
#endif /* INCLUDE_PC_CONSOLE */

	    }
	}

    ioGlobalStdSet (STD_IN,  consoleFd);
    ioGlobalStdSet (STD_OUT, consoleFd);
    ioGlobalStdSet (STD_ERR, consoleFd);

    return (OK);
    }

⌨️ 快捷键说明

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