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

📄 sysserial.c

📁 4510b的vxworks的BSP
💻 C
字号:
/* sysSerial.c - Samsung SNDS100 serial device initialization */

/* Copyright 1996-1998 Wind River Systems, Inc. */
#include "copyright_wrs.h"

/*
modification history
--------------------
01d,23feb98,jpd  comments changes.
01c,26nov97,cdp  added sysSerialReset; documentation/tidy.
01b,27oct97,kkk  took out "EOF" line at end of file.
01a,03jul96,cdp  written.
*/

/*
DESCRIPTION
This file contains the board-specific routines for serial channel
initialization of the Samsung SNDS100 development board.

SEE ALSO:
.I "Samsung KS32C50100 Microcontroller User's Manual."
*/


#include "vxWorks.h"
#include "iv.h"
#include "intLib.h"
#include "config.h"
#include "sysLib.h"
#include "sndsSio.h"


/* device initialization structure */

typedef struct
    {
    UINT  vectorRx;
    UINT  vectorTx;
    UINT32 *baseAdrs;
    UINT  regSpace;
    UINT  intLevelRx;
    UINT  intLevelTx;
    } SNDS_CHAN_PARAS;


/* Local data structures */

LOCAL SNDS_CHAN_PARAS devParas[] =
    {
      {INT_VEC_UARTRX0, INT_VEC_UARTTX0, (UINT32 *)SERIAL_A_BASE_ADR, UART_REG_ADDR_INTERVAL,
	  INT_LVL_UARTRX0, INT_LVL_UARTTX0},
      {INT_VEC_UARTRX1, INT_VEC_UARTTX1, (UINT32 *)SERIAL_B_BASE_ADR, UART_REG_ADDR_INTERVAL,
	  INT_LVL_UARTRX1, INT_LVL_UARTTX1}
    };
 
LOCAL SNDS_CHAN sndsChan[N_SNDS_UART_CHANNELS];

/*
 * Array of pointers to all serial channels configured in system.
 * See sioChanGet(). It is this array that maps channel pointers
 * to standard device names.  The first entry will become "/tyCo/0",
 * the second "/tyCo/1", and so forth.
 */

SIO_CHAN * sysSioChans [] =
    {
    &sndsChan[0].sio, /* /tyCo/0 */
    &sndsChan[1].sio, /* /tyCo/1 */
    };


/* forward declarations */

/******************************************************************************
*
* sysSerialHwInit - initialize the BSP serial devices to a quiesent state
*
* This routine initializes the BSP serial device descriptors and puts the
* devices in a quiesent state.  It is called from sysHwInit() with
* interrupts locked.
*
* RETURNS: N/A
*
* SEE ALSO: sysHwInit()
*/

void sysSerialHwInit (void)
    {
    int i;

    for (i = 0; i < N_SNDS_UART_CHANNELS; i++)
	{
	sndsChan[i].regDelta = devParas[i].regSpace;
	sndsChan[i].regs = devParas[i].baseAdrs;
	sndsChan[i].baudRate = CONSOLE_BAUD_RATE;
/*	sndsChan[i].level = devParas[i].intLevel;	temp mod NB 4/9/99 - member not used*/

	/*
	 * Initialise driver functions, getTxChar, putRcvChar and channelMode
	 * and initialise UART
	 */

	sndsDevInit(&sndsChan[i]);
	}
    }

/******************************************************************************
*
* sysSerialHwInit2 - connect BSP serial device interrupts
*
* This routine connects the BSP serial device interrupts.  It is called from
* sysHwInit2().  Serial device interrupts could not be connected in
* sysSerialHwInit() because the kernel memory allocator was not initialized
* at that point, and intConnect() may call malloc(). 
* 
* RETURNS: N/A 
*
* SEE ALSO: sysHwInit2()
*/

void sysSerialHwInit2 (void)
    {
    int i;

    for (i = 0; i < N_SNDS_UART_CHANNELS; i++)
	{
	/*
	 * Connect and enable the interrupt.
	 * We would like to check the return value from this and log a message
	 * if it failed. However, logLib has not been initialised yet, so we
	 * cannot log a message, so there's little point in checking it.
	 */

	(void) intConnect (INUM_TO_IVEC(devParas[i].vectorTx),
			   sndsIntTx, (int) &sndsChan[i] );
	(void) intConnect (INUM_TO_IVEC(devParas[i].vectorRx),
			   sndsIntRcv, (int) &sndsChan[i] );

	intEnable (devParas[i].intLevelRx);
	sndsDevInit2(&sndsChan[i]);
	}
    }

/******************************************************************************
*
* sysSerialChanGet - get the SIO_CHAN device associated with a serial channel
*
* This routine returns a pointer to the SIO_CHAN device associated with
* a specified serial channel.  It is called by usrRoot() to obtain
* pointers when creating the system serial devices '/tyCo/x'.  It is also
* used by the WDB agent to locate its serial channel.
*
* RETURNS: A pointer to the SIO_CHAN structure for the channel, or ERROR
* if the channel is invalid.
*/

SIO_CHAN * sysSerialChanGet
    (
    int channel         /* serial channel */
    )
    {
    if (channel < 0 || channel >= (int)(NELEMENTS(sysSioChans)))
	return (SIO_CHAN *)ERROR;

    return sysSioChans[channel];
    }

/******************************************************************************
*
* sysSerialReset - reset the sio devices to a quiet state
*
* Reset all devices to prevent them from generating interrupts.
*
* This is called from sysToMonitor to shutdown the system gracefully before
* transferring to the bootroms.
*
* RETURNS: N/A.
*/

void sysSerialReset (void)
    {
    int i;

    for (i = 0; i < N_SNDS_UART_CHANNELS; i++)
	{
	/* disable serial interrupts */

	intDisable (devParas[i].intLevelTx);
	intDisable (devParas[i].intLevelRx);
	}
    }

⌨️ 快捷键说明

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