|
先谢过楼上各位,我在xp系统测试过这些问题串口,完全正常。排除硬件问题。现把测试程序贴出来,大家帮忙看一下:
在232情况下是没有问题的:
#include "vxworks.h"
#include "stdio.h"
#include "stdLib.h"
#include "sysLib.h"
#include "ioLib.h"
#include "taskLib.h"
#include "math.h"
#include "string.h"
#include "logLib.h"
#include "copyright_wrs.h"
#include "intlib.h"
#include "iv.h"
#include "drv/pci/pciConfigLib.h"
#include "drv/pci/pciIntlib.h"
#include "drv/sio/ns16552Sio.h"
#define EXTEND_COM_NUM 4
#define OX16PCI954_VENDERID 0x13FE
#define OX16PCI954_DEVID 0X1600
#define OX16PCI954_BOARDNO 0
#define OX16PCI954_UART_REG_DELTA 4 /*Memory Access Mode*/
#define OX16PCI954_UART_XTAL 14745600
#define OX16PCI954_DEFAULT_BAUD 9600
UINT32 OX16PCI954_IOBASE[EXTEND_COM_NUM];
UINT32 OX16PCI954_MEMBASE[EXTEND_COM_NUM];
UINT32 OX16PCI954_LCLMEMBASE;
int pciBusNum;
int pciDeviceNum;
int pciFuncNum;
UINT8 OX16PCI954_INT_LINE;
static NS16550_CHAN ox16pci954Chan[EXTEND_COM_NUM];
LOCAL void OX16PCI954Int(void);
/******************************************************************************************
* 函数名称:ox16pci954getInfo
* 功能描述: 读取OX16PCI954 PCI设备信息,
*
* 输入参数: 无
*
* 输出参数: 无
*
* 返回值: int,读取正常返回TRUE,异常返回FALSE
*
******************************************************************************************/
int ox16pci954getInfo(void)
{
UINT32 i;
if (pciFindDevice(OX16PCI954_VENDERID, OX16PCI954_DEVID, OX16PCI954_BOARDNO,
&pciBusNum, &pciDeviceNum, &pciFuncNum) != OK)
{
printf("The %d board's OX16PCI954 pciFindDevice error.\n", OX16PCI954_DEVID);
return (FALSE);
}
/*读各个串口的I/O基地址*/
pciConfigInLong(pciBusNum, pciDeviceNum, pciFuncNum, PCI_CFG_BASE_ADDRESS_0, &(OX16PCI954_IOBASE[0]));
OX16PCI954_IOBASE[0] &= 0Xfffffffe;
for (i = 1; i < EXTEND_COM_NUM; i++)
{
OX16PCI954_IOBASE = OX16PCI954_IOBASE[0] + 8 * i;
}
/*读各个串口的内存基地址和中断线*/
pciConfigInLong(pciBusNum, pciDeviceNum, pciFuncNum, PCI_CFG_BASE_ADDRESS_1, &(OX16PCI954_MEMBASE[0]));
pciConfigInByte(pciBusNum, pciDeviceNum, pciFuncNum, PCI_CFG_DEV_INT_LINE, &(OX16PCI954_INT_LINE));
for (i = 1; i < EXTEND_COM_NUM; i++)
{
OX16PCI954_MEMBASE = OX16PCI954_MEMBASE[0] + OX16PCI954_UART_REG_DELTA * 8 * i;
}
/*读PCI LOCAL基地址*/
pciConfigInLong(pciBusNum, pciDeviceNum, pciFuncNum, PCI_CFG_BASE_ADDRESS_3, &(OX16PCI954_LCLMEMBASE));
return (TRUE);
}
/******************************************************************************************
* 函数名称:OX16PCI954Init
* 功能描述: 初始化OX16PCI954设备结构,使串口设备进入工作的状态。由于硬件使用4个串口设备,
* 因此函数对4个串口设备初始化
* 挂接OX16PCI954Int中断服务程序。
*
* 输入参数: 无
*
* 输出参数: 无
*
* 返回值: void
*
******************************************************************************************/
void OX16PCI954Init(void)
{
int i;
if (ox16pci954getInfo() == FALSE)
{
printf("Getting PCI info error.\n");
return;
}
for (i = 0; i < EXTEND_COM_NUM; i++)
{
ox16pci954Chan.regs = OX16PCI954_MEMBASE;
ox16pci954Chan.level = OX16PCI954_INT_LINE;
ox16pci954Chan.regDelta = OX16PCI954_UART_REG_DELTA;
ox16pci954Chan.xtal = OX16PCI954_UART_XTAL;
ox16pci954Chan.baudRate = OX16PCI954_DEFAULT_BAUD;
ox16pci954Chan.ier = 0x40;
/* Disable the UART */
*((char *)(ox16pci954Chan.regs + (IER * ox16pci954Chan.regDelta))) = 0;
/* Reset FIFOs */
*((char *)(ox16pci954Chan.regs + (FCR * ox16pci954Chan.regDelta))) = 6;
ns16550DevInit(&ox16pci954Chan);
/* (void) pciIntConnect ((VOIDFUNCPTR *)INUM_TO_IVEC(ox16pci954Chan.level + 0x20),
(VOIDFUNCPTR) ns16550Int, &ox16pci954Chan);*/
/*printf("COM%d initialized OK.\n", i+3);*/
}
(void) pciIntConnect ((VOIDFUNCPTR *)INUM_TO_IVEC(OX16PCI954_INT_LINE + 0x20),
(VOIDFUNCPTR) OX16PCI954Int, 0);
sysIntEnablePIC(ox16pci954Chan[0].level);
}
/******************************************************************************************
* 函数名称:OX16PCI954Int
* 功能描述: OX16PCI954设备的中断服务程序,响应4个串口中断.
*
* 输入参数: 无
*
* 输出参数: 无
*
* 返回值: void
*
******************************************************************************************/
void OX16PCI954Int(void)
{
UINT32 reg_GIS;
UINT8 temp;
reg_GIS = *((volatile UINT32 *)(OX16PCI954_LCLMEMBASE + 0x1c));
logMsg("reg_GIS: %x\n.",reg_GIS,0,0,0,0,0);
if (reg_GIS & 1)
{
logMsg("COM3 Interrupted.\n",0,0,0,0,0,0);
ns16550Int(&ox16pci954Chan[0]);
}
if (reg_GIS & 2)
{
logMsg("COM4 Interrupted.\n",0,0,0,0,0,0);
ns16550Int(&ox16pci954Chan[1]);
}
if (reg_GIS & 4)
{
logMsg("COM5 Interrupted.\n",0,0,0,0,0,0);
ns16550Int(&ox16pci954Chan[2]);
}
if (reg_GIS & 8)
{
logMsg("COM6 Interrupted.\n",0,0,0,0,0,0);
ns16550Int(&ox16pci954Chan[3]);
}
}
|
|