This page describes briefly the use of the VME access library and the library routines available.
The following sample progam is used to describe the routines needed. You can use the hyperlinks to get a more detailed description of the routine. The lines marked with 1,2,3,4 must exist for each VME channel defined.
/* vme_test.c, a simple Vme Access Example */ #include "stdio.h" /* 1. Include the Vme header file to define ** function prototypes and property names. */ #include "Vme.h" #define VME_ADDRESS 0x10000000 /* VME address to map */ #define VME_SIZE 0x100000 /* VME space to map */ #define VME_AM 0x09 /* VME address modifier */ #define VME_OFFSET 0x100 /* VME offset from base */ main () { int cid, data, count, on=1, blt_am=0x0b; int *vme_ptr; char buffer[100]; /* 2. Open a VME channel */ cid = VmeOpenChannel("Example"); /* -> Define VME specific properties (if needed) */ (void)VmeSetProp(cid, Vme_SET_READ_PREFETCH, &on); /* 3. Define and map VME address space */ vme_ptr=(int *)VmeMapAddress(cid,VME_ADDRESS,VME_SIZE,VME_AM); /* - > Do VME read/write using the pointer (if supported) ** Note: not possible with the DEC AXPvme board ! */ *vme_ptr = 0xBEEFFACE; /* VME A32/D32 write */ data = *vme_ptr; /* VME A32/D32 read */ /* -> Define properties for VME copy (if needed) */ (void)VmeSetProp(cid, Vme_SET_COPY_AM, &blt_am); /* -> Do VME copy from and to user memory */ count = VmeRead (cid, VME_OFFSET, (char *)buffer, 100); count = VmeWrite(cid, VME_OFFSET, (char *)buffer, 100); /* 4. Close VME channel and free resources */ (void)VmeCloseChannel(cid); }
int VmeOpenChannel( char *channel_name )
if ( (cid = VmeOpenChannel("Example")) < 0 ) { printf("VmeOpenChannel() failed!\n"); exit(1); }
int VmeCloseChannel( int cid )
if ( VmeCloseChannel(cid) < 0 ) { printf("VmeCloseChannel() failed!\n"); }
void* VmeMapAddress( int cid, unsigned int vme_addr, int vme_size, int vme_am )
Not all VME CPUs support transparent VME access via pointer
like the DEC AXPvme boards.
Use VmeRead or VmeWrite instead.
But this routine must always be called!
int *ptr; ... ptr = (int *)VmeMapAddress(cid,0xE0000000,0x100000,0x09); if ( ptr == NULL ) { printf("VmeMapAddress() failed!\n"); exit(1); }
int VmeSetProp( int cid, int prop, void* value )
int blt = 0x0B; /* BLT D32 */ ... if ( VmeSetProp( cid, Vme_SET_COPY_AM, (int *)&blt) < 0 ) { printf("VmeSetProp() failed!\n"); exit(1); }
int VmeGetProp( int cid, int prop, void* value )
int VmeRead ( int cid, int offset, void* buffer, int length ) int VmeWrite( int cid, int offset, void* buffer, int length )
Vme_SET_COPY_AM : VME address modifier Vme_SET_COPY_DTYPE : Data type D8, D16 or D32 Vme_SET_COPY_FIFO : Do not increment VME addressThe address modifier defines, if the transfer is done in VME block mode (if available) or not.
int blt = 0x0B; /* BLT D32 */ char buffer[100]; ... if ( VmeSetProp( cid, Vme_SET_COPY_AM, (int *)&blt) < 0 ) exit(1); cnt = VmeRead( cid, 0x10, (char *)buffer, 100); if ( cnt < 0) { printf("VmeRead() failed!\n"); exit(1); }
Suggestions, comments or questions? Please contact: