📄 difdiotest_183.c
字号:
/* difDioTest_183.c - Sample code to test Diff I/O channels *//************************************************************************** * * Copyright (c) 2005 Curtiss-Wright Controls, Inc. All rights * reserved. This Source Code is the Property of Curtiss-Wright * Controls, Inc. and can only be used in accordance with Source * Code License Agreement(s) of Curtiss-Wright Controls, Inc. or any * of its subsidiaries. * **************************************************************************//*Modification History--------------------01b, 23nov05,tis -updated the test to support the fixes CR#12295 & CR#12609. -added support for testing DIFFIO on CPU101a, 19Mar05,rcd ported from difDioTest.c rev 01d*/ /*DESCRIPTION This libray contains the following test routines, see function headers for further detailsdifDioTest()difDioReadTest()difDioWriteTest()difDioIntEnableTest()difDioIntDisableTest()Diff I/O signals are available through RS422 connectors on P2.Below is pin layout for CHx cable on P2(Consult your HW manual or see CBL_SBC_P2-000.doc):SIGNAL [From P2] [To_pin] COMMENTSOut A 2 Twisted pair 1Out B 14 Twisted pair 1In A' 3 Twisted pair 2In B' 16 Twisted pair 2Out A 15 Twisted pair 3Out B 24 Twisted pair 3In A' 17 Twisted pair 4In B' 25 Twisted pair 4INCLUDE file: dio_dy4.h*//* includes */#include <vxWorks.h>#include <stdio.h>#include <string.h>#include <ioLib.h>#include "sioLib.h"#include "taskLib.h"#include "tickLib.h"#include "config.h"#include "logLib.h"#include "tyLib.h"#include "iosLib.h"#include "intLib.h"#include "sysLib.h"#include "h/drv/dio/dio_dy4.h"#include "config.h" /* also includes dy418x.h */#include "fpga183.h"extern UINT8 ddioCpuConfig;#define DIFFDIO_LINES 8static char info[] = "This test SW validates the Differential I/O functionality\n" "on the SVME-183 SBC (IPM is required).\n" "Note: Some models may not have Diff I/O.\n" "The test works with loopback connectors on the\n" "P2 serial channels.";/* local variables */LOCAL BOOL connector = FALSE;char *msg_base_addr = NULL;extern int sysProcId;/************************ Function Header ***************************** difReadTest - tests the difDioRead function of the driver.** This test will write a walking 1 then read it back.* Interrupts are NOT tested in this function.** RETURNS: OK on success, ERROR on failure.************************* End Function Header *************************/STATUS difReadTest() { STATUS stat = ERROR; /* return status */ UINT8 readVal; /* value read from data lines */ UINT8 testVal; /* value holding walking 1 or walking zero */ UINT8 portConfigMask = 0x00; int i = 0; /* for loop counter */ readVal = 0x00; testVal = 0x01; /* disable DIFFIO interrupts*/ difDioIntDisable(ddioCpuConfig); /* clear the register */ difDioWrite (~(ddioCpuConfig)); stat = difDioRead (&readVal); if (stat == OK) { for(i = 0; i < DIFFDIO_LINES; i++) { portConfigMask = ddioCpuConfig & (1 << i); if (portConfigMask > 0) { /* test this line */ stat = difDioWrite (testVal); printf ("difReadTest: writing test Value = 0x%x\n", testVal); taskDelay(10); stat = difDioRead (&readVal); printf ("difReadTest: read test Value = 0x%x\n", readVal); if ((readVal&portConfigMask) != testVal) { printf ("difReadTest Fail: readVal = %x, testVal = %x\n", readVal, testVal); stat = ERROR; } else { printf ("difReadTest PASS: readVal = %x, testVal = %x\n", readVal, testVal); } } testVal <<= 1; /* shift the walking 1 once */ readVal = 0x00; /* clear read variable */ if (stat == ERROR) break; taskDelay(1); } /* end for loop */ } if (stat == ERROR) printf ("difReadTest Fail: difDioRead failed\n"); return stat; }/************************ Function Header ***************************** difWriteTest - tests the difWriteTest() of the Diff I/O driver** This test will write a walking 1 then read it back in order to test* the masking ability of the Write function. It will then test a * walking zero as well.* * Interrupts are NOT tested in this function.** RETURNS: OK on success, ERROR on failure************************* End Function Header *************************/STATUS difWriteTest() { STATUS stat = ERROR; /* return status */ UINT8 readVal; /* value read from data lines */ UINT8 testVal; /* value holding walking 1 or walking zero */ int i = 0; /* for loop counter */ /* disable DIFFIO interrupts*/ difDioIntDisable(ddioCpuConfig); /* clear the register */ difDioWrite (~(ddioCpuConfig)); stat = difDioRead (&readVal); testVal = (0xFF & ddioCpuConfig); /* First test: write one to all our DIFF lines */ stat = difDioWrite (testVal); difDioRead (&readVal); if ((readVal&ddioCpuConfig) != testVal) { printf ("difWriteTest Fail: readVal = %x, testVal = %x\n", readVal, testVal); stat = ERROR; } /* test a walking 0 now */ if (stat == OK) { for(i = 0; i < DIFFDIO_LINES; i++) { testVal = ~(0x01 << i); /* shift the walking 0 once */ if ((ddioCpuConfig & (1 << i)) > 0) { /* test this line */ stat = difDioWrite (testVal); taskDelay(10); stat = difDioRead (&readVal); if (readVal != testVal) { printf ("difWriteTest Fail: readVal = %x, testVal = %x\n", readVal, testVal); stat = ERROR; } } readVal = 0x00; /* clear read variable */ if (stat == ERROR) break; taskDelay(10); } /* end for loop */ } if (stat == ERROR) printf ("difWriteTest Fail: difDioWrite failed\n"); return stat; }/************************ Function Header ***************************** difIntEnableTest - tests the masking of interrupts** This function will ensure that each interrupt line can be * individually set. It will mask out all interrupt line except for * one, test it, then perform the same test on the next one.* Interrupts are NOT tested in this function.** RETURNS: OK on success, ERROR on failure************************ End Function Header *************************/STATUS difIntEnableTest() { STATUS status; /* return status of this function */ UINT8 mask; /* interrupt enable mask */ UINT8 intEnLine; /* lines that are enabled in the PIEN register */ int i; /* loop variable */ /* clear all the existing interrupts */ status = difDioIntDisable ((UINT32)ddioCpuConfig); if(0 == sysProcId) intEnLine = sysInByte ((UINT32)FPGA_CPU0_DIFFDIO_INTMSK); /* read back the value */ else intEnLine = sysInByte ((UINT32)FPGA_CPU1_DIFFDIO_INTMSK); /* read back the value */ if((intEnLine & ddioCpuConfig) != 0x00) { printf ("difIntEnableTest: Failed to disable interrupts\n"); printf ("value int eable reg is %x\n", intEnLine); return (ERROR); } /* Clear all pending interrupts for fresh use by enabling the bits in the FPGA_DIFFDIO_INTENBL register * then writing 1 to each bit we use in the FPGA_DIFFDIO_INTSTAT register. */ sysOutByte((UINT32)FPGA_DIFFDIO_INTENBL, ddioCpuConfig ); sysOutByte ((UINT32)FPGA_DIFFDIO_INTSTAT, ddioCpuConfig ); mask = (0x01 & ddioCpuConfig); /* set up mask for initial value */ for (i = 0; i < DIFFDIO_LINES; i++) { if(mask == 0) continue; difDioIntEnable (mask); if(0 == sysProcId) intEnLine = sysInByte ((UINT32)FPGA_CPU0_DIFFDIO_INTMSK); else intEnLine = sysInByte ((UINT32)FPGA_CPU1_DIFFDIO_INTMSK); if((intEnLine & ddioCpuConfig) != (mask & ddioCpuConfig)) /* only check our lines */ { printf ("mask of different value than register in Int Enable " "test #%d, mask = 0x%x, intEnLine = 0x%x\n\n", i, mask, intEnLine); return (ERROR); } status = difDioIntDisable (mask); mask = mask << 1; } return (OK); }/************************ Function Header ***************************** difIntDisableTest - tests the disabling and masking of interrupts** This function will ensure that each interrupt line can be * individually cleared. It will enable all interrupt lines and then* disable them one at a time until all have been tested.* * Interrupts are NOT tested in this function.** RETURNS: OK on success, ERROR on failure************************ End Function Header *************************/STATUS difIntDisableTest() { STATUS status; /* return status of various function calls */ UINT8 mask; /* used to clear a particular interrupt */ UINT8 intEnLine; /* lines that are enabled in the PIEN register */ int i; /* loop variable */ /* clear all the existing interrupts */ status = difDioIntEnable (ddioCpuConfig); if(0 == sysProcId) intEnLine = sysInByte ((UINT32)FPGA_CPU0_DIFFDIO_INTMSK); /* read back the value */ else intEnLine = sysInByte ((UINT32)FPGA_CPU1_DIFFDIO_INTMSK); /* read back the value */ if((intEnLine & ddioCpuConfig) != ddioCpuConfig) { printf ("difIntDisableTest: Failed to enable interrupts\n"); printf ("value int eable reg is %x\n", intEnLine); return (ERROR); } mask = 0x01; /* set up mask for initial value */ for (i = 0; i < DIFFDIO_LINES; i++) { difDioIntDisable (mask & ddioCpuConfig); if(0 == sysProcId) intEnLine = sysInByte ((UINT32)FPGA_CPU0_DIFFDIO_INTMSK); /* read back the value */ else intEnLine = sysInByte ((UINT32)FPGA_CPU1_DIFFDIO_INTMSK); /* read back the value */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -