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

📄 difdiotest_183.c

📁 Curtiss-Wright Controls Embedded Computing公司的cw183板bsp源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	if((~intEnLine & mask) != mask)	    {	    printf ("mask of different value than register in Int disable test #%d\n\n", i);	    return (ERROR);	    }			 status = difDioIntEnable(ddioCpuConfig);	 mask = mask << 1;	 }    return (OK);    }/************************ Function Header *****************************	difEdgeSetTest() - tests the rising/falling edges of interrupts**	**	RETURNS: OK on success, ERROR on failure************************ End Function Header *************************/STATUS difEdgeSetTest()	{	STATUS status;		/* return status of various function calls */	UINT8 mask;		/* mask to set the edge register */	UINT8 readReg;		/* value read back from Edge register */	int i;			/* loop variable */	mask = ddioCpuConfig;        difDioIntDisable  (mask);	status = difDioIntEdgeSet ((UINT32)mask, FALLING); 	readReg = sysInByte ((UINT32)FPGA_DIFFDIO_EDGE);	/* read back reg value */	mask = 0x01;	for (i = 0; i < DIFFDIO_LINES; i++)		{		status = difDioIntEdgeSet ((mask & ddioCpuConfig), RISING);			readReg = sysInByte ((UINT32)FPGA_DIFFDIO_EDGE);			/* compare - should be same as mask */		if ((readReg & ddioCpuConfig) != (mask & ddioCpuConfig))				{			printf ("difEdgeSetTest() Failed - iteration #%d\n\n", i);			printf ("value on failure: readReg = %x, mask = %x\n", (unsigned int)readReg, mask);			return (ERROR);			}		/* set all edge bits to Falling */		status = difDioIntEdgeSet ((UINT32)ddioCpuConfig, FALLING);				mask = mask << 1;		}			status = difDioIntEdgeSet ((UINT32)ddioCpuConfig, RISING);	mask = (UINT32)0x01;	for (i = 0; i < DIF_LINES; i++)		{		status = difDioIntEdgeSet((mask & ddioCpuConfig), FALLING);		readReg = sysInByte ((UINT32)FPGA_DIFFDIO_EDGE);		/* clearing the top byte of mask before compare */		if ((readReg & ddioCpuConfig) != (~mask & ddioCpuConfig))				{			printf ("difEdgeSetTest Fail - Falling test #%d\n\n", i);			printf ("value on failure: readReg = %x, mask = %x\n", (unsigned int)readReg, mask);			return (ERROR);			}				mask = mask << 1;		status = difDioIntEdgeSet ((UINT32)ddioCpuConfig, RISING);		}	return (OK);	}/******************** Function Header ************************       difIntIsr() - Interrupt service routine**       This will modify some area of memory with a distinct*		value per ISR in consecutive locations in memory.*       then return.********************* End Function Header ********************/void difIntIsr(int arg){    logMsg("Received Diff Isr mask#0x%x\n",arg,0,0,0,0,0);    switch (arg)        {        case 0x1: /* difIntIsr1 */	  {	    *(UINT32*)msg_base_addr = 0xdeadbeef; break;	  }	case 0x2: /* difIntIsr2 */	  {	    *(UINT32*)(msg_base_addr + 0x4) = 0xdefaced; break;	  }	case 0x4: /* difIntIsr3() */	  {	    *(UINT32*)(msg_base_addr + 0x8) = 0xbeaddeaf; break;	  }	case 0x8: /* difIntIsr4() */	  {	    *(UINT32*)(msg_base_addr + 0xc) = 0xdeadfeed; break;	  }	case 0x10: /* difIntIsr5() */	  {	    *(UINT32*)(msg_base_addr + 0x10) = 0xeffaced; break;	  }	case 0x20: /* difIntIsr6() */	  {	    *(UINT32*)(msg_base_addr + 0x14) = 0xdeafbead; break;	  }	case 0x40: /* difIntIsr7() */	  {	    *(UINT32*)(msg_base_addr + 0x18) = 0xdabadaba; break;	  }	case 0x80: /* difIntIsr8() */	  {	    *(UINT32*)(msg_base_addr + 0x1c) = 0xbebadbee; break;	  }	}}/********************** Function Header ***********************       difIntTest - This function tests interrupts on the Diff I/O*       lines.**		Description:  This test sets up the upper 6 bits as outputs*		and the lower (LSBits) to be inputs.  An individual ISR*		is attached to each dif line of the lower 6 bits.  Then a *		logical 1 is written to the upper six bits which should*		generate an interrupt for each of the corresponding input *		bits.  Each individual ISR writes to an area of memory a *		uniques value. (0x300000) is the default location and can *		modified by changing the #define ISR_BASE_ADRS in dif.h**       A terse algorithm is as follows**       Set up pins 0 through 5 to inputs*       Set up pins 6 through 11 for outputs*       Attach interrupt ISR to 0 through 5*       Enable the interrupts on lines 0 through 5*       Send data out - generating an interrupt*       Service and return - loop de loop for all********************** End Function Header ********************/STATUS difIntTest(){    STATUS status;         /* return status from various function calls */    UINT16 i,mask;         /* mask used for various IO pins and functions */    UINT32  intPatt[8] = {                            0xdeadbeef,                            0x0defaced,                            0xbeaddeaf,                            0xdeadfeed,                            0x0effaced,                            0xdeafbead,			    0xdabadaba,			    0xbebadbee                         };    static char* errConnect = "Error returned from difConnect()\n";    printf("Start Diff DIO Interrupt test\n");    printf("-----------------------------\n");    msg_base_addr = malloc(32);    memset(msg_base_addr, 0, 32);    printf("Interrupt Message Base Address = 0x%x\n",(UINT)msg_base_addr);    /* attach ISR to bit 0 */    status = difDioIntConnect (0x01, (FUNCPTR)difIntIsr, 0x01);    if (status == ERROR)        {  puts(errConnect); return (ERROR);     }    /* attach ISR to bit 1 */    status = difDioIntConnect (0x02, (FUNCPTR)difIntIsr, 0x02);      if (status == ERROR)        {  puts(errConnect); return (ERROR);     }    /* attach ISR to bit 2 */    status = difDioIntConnect (0x04, (FUNCPTR)difIntIsr, 0x04);    if (status == ERROR)        {  puts(errConnect); return (ERROR);     }    /* attach ISR to bit 3 */    status = difDioIntConnect (0x08, (FUNCPTR)difIntIsr, 0x08);      if (status == ERROR)        {  puts(errConnect); return (ERROR);     }    /* attach ISR to pin 4 */    status = difDioIntConnect (0x10, (FUNCPTR)difIntIsr, 0x10);      if (status == ERROR)        {  puts(errConnect); return (ERROR);     }    /* attach ISR to pin 5 */    status = difDioIntConnect (0x20, (FUNCPTR)difIntIsr, 0x20);      if (status == ERROR)        {  puts(errConnect); return (ERROR);     }    /* attach ISR to pin 6 */    status = difDioIntConnect (0x40, (FUNCPTR)difIntIsr, 0x40);      if (status == ERROR)        {  puts(errConnect); return (ERROR);     }    /* attach ISR to pin 7 */    status = difDioIntConnect (0x80, (FUNCPTR)difIntIsr, 0x80);      if (status == ERROR)        {  puts(errConnect); return (ERROR);     }    difDioIntDisable  (ddioCpuConfig);    status = difDioIntEdgeSet (ddioCpuConfig, RISING);    if (status == ERROR)        {        printf ("Error returned from difEdgeSet()\n");        return (ERROR);        }    status = difDioWrite (0x0);    if (status == ERROR)        {        printf ("Error returned from difWrite()\n");        return (ERROR);        }    /* enable interrupt lines */    status = difDioIntEnable (ddioCpuConfig);    if (status == ERROR)        {        printf ("Error returned from difIntEnable()\n");        return (ERROR);        }	for (mask = 1, i = 0; i < DIFFDIO_LINES; i++, mask <<= 1)	{	    if (difDioWrite (mask & ddioCpuConfig) == ERROR)	      {		printf ("Error returned from difWrite()\n");		return (ERROR);	      }	}    taskDelay(10);    printf("---------------------------\n");    printf("End Diff DIO Interrupt test\n");              if (strncmp((char *)intPatt, msg_base_addr,32) != 0)		{                  status = ERROR;                }              else                  status = OK;    return status;}/************************* Function Header *****************************	difTest - main menu for test suite**	This function is a menu driven test suite to test the various*	functionality of the Diff I/O driver:*	- test difRead()*	- test difWrite()*	- test difIntEnable()*	- test difIntDisable()*       - test difEdgeSetTest()*	- test interupts with loopback connector installed************************ End Function Header **************************/void difTest(BOOL connectorIn){    STATUS	status = ERROR;	/* status returned from selected test */	    puts (info);    if(connectorIn==TRUE)         {        connector = 1;        }    else         {        connector = 0;        }   printf ("Function               Pass/Fail\n");   printf ("================================\n");   status = difReadTest();   if (status == ERROR)      printf ("difRead                **FAILED**\n");   else      printf ("difRead                **PASSED**\n");   status = difWriteTest();   if (status == ERROR)      printf ("difWrite               **FAILED**\n");   else      printf ("difWrite               **PASSED**\n");   status = difIntEnableTest();   if (status == ERROR)      printf ("difIntEnable           **FAILED**\n");   else      printf ("difIntEnable           **PASSED**\n");   status = difIntDisableTest();   if (status == ERROR)      printf ("difIntDisable          **FAILED**\n");   else      printf ("difIntDisable          **PASSED**\n");   status = difEdgeSetTest();   if (status == ERROR)      printf ("difEdgeSet             **FAILED**\n");   else      printf ("difEdgeSet             **PASSED**\n");   if (connector)   {      status = difIntTest();      if (status == ERROR)         printf ("difIntTest             **FAILED**\n");      else         printf ("difIntTest             **PASSED**\n");   }   else puts ("difIntTest             **SKIPPED**");}

⌨️ 快捷键说明

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