National Instruments NI-VXI Network Card User Manual


 
Chapter 2 Introduction to the NI-VXI Functions
© National Instruments Corporation 2
-
15 NI-VXI User Manual
timeout = 2000L; /* 2 seconds */
/* Notice the use of the macros for defining the access */
/* parameters. These can be found in the NI-VXI header files */
addrptr1 = (UINT32) MapVXIAddress(AccessP_Space(A16_SPACE) |
AccessP_Priv(NonPriv_DATA) |
AccessP_BO(MOTOROLA_ORDER) |
AccessP_Owner(0),
addr, timeout, &window1, &ret);
if (ret >= 0) /** MapVXIAddress call is successful **/
{
/* The following code reads the ID register of a device */
/* at logical address 10. */
la = 10;
addrptr = (UINT16 *)((UINT32) addrptr1 + 64 * la);
VXIpeek(addrptr,2, &svalue));
if (BusErrorRecv)
printf("Bus Error has occurred.\n");
else
printf("Value read was %hd.\n", svalue));
ret = UnMapVXIAddress(window1);
} else
printf("Unable to access window.\n");
/* Close library when done */
ret = CloseVXIlibrary();
}
Notice that the return variable for the
MapVXIAddress()
function is a
pointer. While you can dereference this pointer directly on some
platforms, we recommend that you use the
VXIpeek()
and
VXIpoke()
macros and functions in NI-VXI instead.
You can define
BINARY_COMPATIBLE
when compiling your program
to force NI-VXI to use a version of
VXIpeek()
and
VXIpoke()
macros that will work on all embedded and MXI platforms. In addition,
you can use the functions, rather than the macros, to ensure future
compatibility. To force the compiler to use the functions, put the
function name in parentheses, for example,
(VXIpoke) (addrptr, 2, 0);
instead of
VXIpoke (addrptr, 2, 0);