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

📄 sysserial.c

📁 mpc5200 for bsp,it is have passed built.
💻 C
字号:
/* sysSerial.c - Motorola MPC5200 BSP serial device initialization */#include "vxWorks.h"#include "iv.h"#include "intLib.h"#include "config.h"#include "sysLib.h"#include "drv/sio/m5200PscSio.h"#include "sio/m5200PscSio.c"/* externals */IMPORT UCHAR sysInByte(ULONG);IMPORT void  sysOutByte(ULONG, UCHAR);IMPORT int   intEnable (int intLevel);/* device initialization structures */#ifdef INCLUDE_M5200_PSC_SIOtypedef struct    {    VOIDFUNCPTR *vector;		/* Interrupt vector */    void   *baseAdrs;			/* Register base address */    USHORT regSpace;			/* Address Interval */    USHORT intLevel;			/* Interrupt level */    USHORT portNum;				/* port number */    } M5200_PSC_CHAN_PARAS;#endif /*INCLUDE_M5200_PSC_SIO*//* Local data structures */#ifdef INCLUDE_M5200_PSC_SIOstatic M5200_PSC_CHAN  m5200PscChan[N_SIO_CHANNELS];static M5200_PSC_CHAN_PARAS devParas[] =     {       {COM1_INT_VEC, (void *) COM1_BASE_ADR, UART_REG_ADDR_INTERVAL, COM1_INT_LVL, COM1_PORT_NUM},#ifdef IS_CP2       {COM2_INT_VEC, (void *) COM2_BASE_ADR, UART_REG_ADDR_INTERVAL, COM2_INT_LVL, COM2_PORT_NUM},       {COM3_INT_VEC, (void *) COM3_BASE_ADR, UART_REG_ADDR_INTERVAL, COM3_INT_LVL, COM3_PORT_NUM},#endif    };#endif /*INCLUDE_M5200_PSC_SIO*/#define UART_REG(reg,chan) \		(devParas[chan].baseAdrs + reg * devParas[chan].regSpace)#define UART_REG_UCHAR(reg,chan)  (UCHAR *)(UART_REG(reg,chan))#define UART_REG_USHORT(reg,chan) (USHORT *)(UART_REG(reg,chan))#define UART_REG_ULONG(reg,chan) (ULONG *)(UART_REG(reg,chan))/* globals *//* * sysSioChans - Array of pointers to all serial channels configured in system. * * Channel pointer position in this table determines the device name * under vxWorks.  The first pointer points to the device for /tyCo/0, * the second to /tyCo/1, etc.  See sysSerialChanGet(). */SIO_CHAN * sysSioChans [N_SIO_CHANNELS] =    {#ifdef INCLUDE_M5200_PSC_SIO    (SIO_CHAN *)&m5200PscChan[0].pDrvFuncs,	/* /tyCo/0 */#ifdef IS_CP2    (SIO_CHAN *)&m5200PscChan[1].pDrvFuncs,	/* /tyCo/1 */    (SIO_CHAN *)&m5200PscChan[2].pDrvFuncs,	/* /tyCo/2 */#endif#endif /*INCLUDE_M5200_PSC_SIO*/    };/************************************************************************* sysSerialHwInit - initialize the BSP serial devices to a quiescent state** This routine initializes the BSP serial device descriptors and puts the* devices in a quiescent state.  It is called from sysHwInit() with* interrupts locked.  Polled mode serial operations are possible, but not* interrupt mode operations which are enabled by sysSerialHwInit2().** RETURNS: N/A** SEE ALSO: sysHwInit(), sysSerialHwInit2()*/void sysSerialHwInit     (    void    )    {#ifdef INCLUDE_M5200_PSC_SIO    int i;    for (i = 0; i < N_SIO_CHANNELS; i++)        {	m5200PscChan[i].clkRate	 = UART_CLOCK;	m5200PscChan[i].intVec	 = devParas[i].vector;	m5200PscChan[i].portNum	 = devParas[i].portNum;	m5200PscChan[i].mr	     = UART_REG_UCHAR(PSC_MR, i);	m5200PscChan[i].sr	     = UART_REG_USHORT(PSC_SR_CSR, i);	m5200PscChan[i].csr	 	 = UART_REG_USHORT(PSC_SR_CSR, i);	m5200PscChan[i].cr	 	 = UART_REG_UCHAR(PSC_CR, i);	m5200PscChan[i].rb	 	 = UART_REG_ULONG(PSC_RB_TB, i);	m5200PscChan[i].tb	 	 = UART_REG_UCHAR(PSC_RB_TB, i);	m5200PscChan[i].ipcr	 = UART_REG_UCHAR(PSC_IPCR_ACR, i);	m5200PscChan[i].acr	 	 = UART_REG_UCHAR(PSC_IPCR_ACR, i);	m5200PscChan[i].isr	 	 = UART_REG_USHORT(PSC_ISR_IMR, i);	m5200PscChan[i].imr	 	 = UART_REG_USHORT(PSC_ISR_IMR, i);#if  0	m5200PscChan[i].ivr	 	 = UART_REG_UCHAR(PSC_IVR, i);#endif	m5200PscChan[i].op1	     = UART_REG_UCHAR(PSC_OP1, i);	m5200PscChan[i].sicr     = UART_REG_UCHAR(PSC_SICR, i);	m5200PscChan[i].dp       = UART_REG_UCHAR(PSC_DP, i);	m5200PscChan[i].dl       = UART_REG_UCHAR(PSC_DL, i);	m5200PscChan[i].rfalarm  = UART_REG_USHORT(PSC_RFALARM, i);	m5200PscChan[i].tfalarm  = UART_REG_USHORT(PSC_TFALARM, i); 	m5200PscSioDevInit (&m5200PscChan[i]);        }#endif /*INCLUDE_M5200_PSC_SIO*/    }/************************************************************************* sysSerialHwInit2 - connect BSP serial device interrupts** This routine connects the BSP serial device interrupts.  It is called from* sysHwInit2().  * * Serial device interrupts cannot be connected in sysSerialHwInit() because* the kernel memory allocator is not initialized at that point, and* intConnect() calls malloc().** RETURNS: N/A** SEE ALSO: sysHwInit2()*/void sysSerialHwInit2     (    void    )    {#ifdef INCLUDE_M5200_PSC_SIO    int i;    /* connect serial interrupts */     for (i = 0; i < N_SIO_CHANNELS; i++)         if (m5200PscChan[i].intVec)	     {             (void) intConnect (INUM_TO_IVEC ((int)m5200PscChan[i].intVec),				m5200PscSioInt, (int)&m5200PscChan[i] );	     m5200PscSioDevInit2(&m5200PscChan[i]);             intEnable (devParas[i].intLevel);              }#endif /*INCLUDE_M5200_PSC_SIO*/    }/************************************************************************* 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 >= NELEMENTS(sysSioChans))        return (SIO_CHAN *)ERROR;    return sysSioChans[channel];    }/************************************************************************* sysSerialReset - reset all serial devices to a quiescent state** This routine resets all serial devices to a quiescent state.  It is called * by sysToMonitor().** RETURNS: N/A** SEE ALSO: sysToMonitor()*/void sysSerialReset     (    void    )    {#ifdef INCLUDE_M5200_PSC_SIO    int i;    for (i = 0; i < N_SIO_CHANNELS; i++)        m5200PscSioDevInit(&m5200PscChan[i]);#endif /*INCLUDE_M5200_PSC_SIO*/    }

⌨️ 快捷键说明

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