/* ====================================================================== * * * singleCycle.c * Sample program for accessing the VME bus with the vme_/rcc libraries * by Markus.Joos CERN.Ch; * adapted and commented by Dirk Hoffmann -CPPM-, April 2004. * * ====================================================================== */ #include "rcc_error/rcc_error.h" #include "vme_rcc/vme_rcc.h" int main(void) { VME_MasterMap_t master_map; /* Declare VMEbus pointers volatile to avoid problems with code * optimization by the compiler */ volatile u_int *lptr, ldata; u_int ret, vbase; int handle; if ((ret = VME_Open()) != VME_SUCCESS) { /* Never call a function withouth checking errors! */ VME_ErrorPrint(ret); exit(-1); } master_map.vmebus_address = 0x02000000; master_map.window_size = 0x1000; master_map.address_modifier = VME_A32; master_map.options = 0; if ((ret = VME_MasterMap(&master_map, &handle)) != VME_SUCCESS) { VME_ErrorPrint(ret); exit(-1); } ret = VME_MasterMapVirtualAddress(handle, &vbase); if (ret != VME_SUCCESS) { VME_ErrorPrint(ret); exit(-1); } /* Access is performed here! */ lptr = (u_int *)(vbase + 0xA50); ldata = *lptr; /* Always cleanup when we are done! */ ret = VME_MasterUnmap(handle); if (ret != VME_SUCCESS) { VME_ErrorPrint(ret); exit(-1); } ret = VME_Close(); if (ret != VME_SUCCESS) { VME_ErrorPrint(ret); exit(-1); } /* If there was no problem, we return 0 to the calling shell */ exit(0); }