/* This example illustrates how to do a block transfer of data from * one VXI address to local memory. This example will move 256 * long words from a device on the VXIbus that uses A24 memory * to a local buffer. VXImove has parameters similar to those of * VXIin and VXIout so you should be familiar with that example. * Block transfers are accomplished through the use of VXImove. * More information can be found in the NI-VXI Software Reference * Manual in Chapter 7, 'High Level VXIbus Access Functions'. * * NOTE: this is NOT an executable example yet. You will need to specify * valid access parameters and a valid address for a VXI device that has shared * memory we can move data from. The lines of code you need to modify are preceeded * by a commend that says 'CHANGE HERE'. You will also need to specify the width of * each transfer (byte, word, or long word) and the total length of the transfer. * If you do not have a device that has memory we can move from, you can use shared * memory to 'mimic' a vxi device with memory. To do this, make sure you have shared * memory set up correctly. You may wish to execute the shared memory example first. * The call to VXImemAlloc will pass the vxi address of the shared memory to * the VXImove function. */ #include "nivxi.h" #include #include #include #include main() { INT16 ret; UINT16 source_parms, dest_parms; /* Source and destination parameters * for transfer. */ UINT32 source_address, dest_address; /* Source and destination addresses * for transfer. */ UINT32 length, i; /* Number of bytes, words, or long words * to transfer. */ UINT16 width; /* Set to 1: Byte * 2: Word * 4: Long Word */ UINT8 *dest_ptr; /*Pointer to local buffer*/ void *useraddr; /* Used in VXImemAlloc */ ret = InitVXIlibrary(); /* Always Init the VXI library */ /*CHANGE HERE*/ width = 4; /* Currently set to long word transfer */ length = 256; /* Currently set to move 256 long words */ source_parms = 3; /* specify source parameters. Right now it is * set for A32 space.*/ source_address = 0x20000000; /* specify location of source data to move. * Right now it is set for address 0x200000. */ /* Using shared memory as a source. This overrides the address 0x200000 that * I specified above. Remove VXImemAlloc if not using shared memory. */ ret = VXImemAlloc(length*width, &useraddr, &source_address); /*END CHANGES*/ dest_parms = 0; /* Specify destination to be local memory */ /* Allocate some local memory for the transfer */ dest_address = (UINT32) malloc (length*width); ret = VXImove(source_parms, source_address, dest_parms, dest_address, length, width); if (ret < 0) { /* An error occured during the block transfer */ } /* Hex dump of memory transfered to local computer */ dest_ptr = (UINT8 *) dest_address; for (i=0; i