Subversion Repositories f9daq

Rev

Rev 17 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. //-------------------------------------------------------------------------------------------
  2. // pcivme_ni.c - a ni labview dll skeleton for the ARW pcivme interface
  3. //
  4. // (c) 1999-2004 ARW Elektronik, Germany
  5. //
  6. // this source code is published under GPL (Open Source). You can use, redistrubute and
  7. // modify it unless this header  is  not modified or deleted. No warranty is given that
  8. // this software will work like expected.
  9. // This product is not authorized for use as critical component in life support systems
  10. // wihout the express written approval of ARW Elektronik Germany.
  11. //
  12. // Please announce changes and hints to ARW Elektronik
  13. //
  14. //
  15. // $Log: pcivme_ni.c,v $
  16. // Revision 1.2  2004/07/24 07:47:00  klaus
  17. // Update copyright to 2004
  18. //
  19. // Revision 1.1.1.1  2003/11/14 23:17:18  klaus
  20. // First put into repository
  21. //
  22. // Revision 1.2  2002/10/27 17:05:33  klaus
  23. // CVS log added, file addressing bug > 2 Gbtye circumvent
  24. //
  25. // what                                                              who    when
  26. // first steps                                                       AR     07.11.1999
  27. //
  28. //-------------------------------------------------------------------------------------------
  29. // INCLUDES
  30. //
  31.  
  32.  
  33. #include <windows.h>
  34. #include <os_info.h>
  35. #include <pcivme_ni_NT.h>
  36. #include <pcivme_ni.h>
  37. #include <stdio.h>
  38.  
  39. //-------------------------------------------------------------------------------------------
  40. // DEFINES
  41. //
  42.  
  43. //-------------------------------------------------------------------------------------------
  44. // TYPEDEFS
  45. //
  46. typedef struct
  47. {
  48.         int (*VMEinit)(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, int *pnHandle);
  49.         int (*VMEread)(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer);
  50.         int (*VMEwrite)(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer);
  51.         int (*VMEaccessVIC)(int Handle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent);
  52.         int (*VMEreset)(int Handle);
  53.         int (*VMETAS)(int Handle, unsigned long ulAddress, unsigned char *ubResult);
  54.         int (*VMEinterrupt)(int Handle, unsigned char *ubVector);
  55.         int (*VMEsysfailGet)(int nHandle, BOOLEAN *bResult);
  56.         int (*VMEsysfailSet)(int nHandle, BOOLEAN bForce);
  57.         int (*VMEclose)(int nHandle);
  58. } MY_ACTIONS;
  59.  
  60. //-------------------------------------------------------------------------------------------
  61. // LOCALS
  62. //
  63. static MY_ACTIONS ma;  // the selected actions
  64. static BOOLEAN firstTime = TRUE;
  65.  
  66. //-------------------------------------------------------------------------------------------
  67. // EXTERNALS
  68. //
  69.  
  70. //-------------------------------------------------------------------------------------------
  71. // GLOBALS
  72. //
  73.  
  74. //-------------------------------------------------------------------------------------------
  75. // FUNCTIONS
  76. //
  77. int __declspec(dllexport) VMEinit(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, int *pnHandle)
  78. {
  79.  
  80.         if (firstTime)
  81.         {
  82.                 if (IsWindowsNT())
  83.                 {
  84.                         ma.VMEinit               = VMEinitNT;
  85.                         ma.VMEread               = VMEreadNT;
  86.                         ma.VMEwrite              = VMEwriteNT;
  87.                         ma.VMEaccessVIC  = VMEaccessVICNT;
  88.                         ma.VMEreset              = VMEresetNT;
  89.                         ma.VMETAS                = VMETASNT;
  90.                         ma.VMEinterrupt  = VMEinterruptNT;
  91.                         ma.VMEsysfailGet = VMEsysfailGetNT;
  92.                         ma.VMEsysfailSet = VMEsysfailSetNT;
  93.                         ma.VMEclose              = VMEcloseNT;
  94.                 }
  95.                
  96.                         else
  97.                                 return -1;
  98.  
  99.                 firstTime = FALSE;
  100.         }
  101.        
  102.         return ma.VMEinit(cszDeviceName, nVMEMM, ubAddressModifier, pnHandle);
  103. }
  104.  
  105. int __declspec(dllexport) VMEread(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer)
  106. {
  107.         return ma.VMEread(nHandle, ulAddress, ubAccessWidth, ulElementCount, pvBuffer);
  108. }      
  109.  
  110. int __declspec(dllexport) VMEwrite(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer)
  111. {
  112.         return ma.VMEwrite(nHandle, ulAddress, ubAccessWidth, ulElementCount, pvBuffer);
  113. }
  114.  
  115. int __declspec(dllexport) VMEaccessVIC(int nHandle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent)
  116. {
  117.         return ma.VMEaccessVIC(nHandle, ubAccessMode, uwAddress, ubContent);
  118. }
  119.  
  120. int __declspec(dllexport) VMEreset(int nHandle)
  121. {
  122.         return ma.VMEreset(nHandle);
  123. }
  124.  
  125. int __declspec(dllexport) VMETAS(int nHandle, unsigned long ulAddress, unsigned char *ubResult)
  126. {
  127.         return ma.VMETAS(nHandle, ulAddress, ubResult);
  128. }
  129.  
  130. int __declspec(dllexport) VMEsysfailGet(int nHandle, BOOLEAN *bResult)
  131. {
  132.         return ma.VMEsysfailGet(nHandle, bResult);
  133. }
  134.  
  135. int __declspec(dllexport) VMEsysfailSet(int nHandle, BOOLEAN bForce)
  136. {
  137.         return ma.VMEsysfailSet(nHandle, bForce);
  138. }
  139.  
  140. int __declspec(dllexport) VMEinterrupt(int nHandle, unsigned char *ubVector)
  141. {
  142.         return ma.VMEinterrupt(nHandle, ubVector);
  143. }
  144.  
  145. int __declspec(dllexport) VMEclose(int nHandle)
  146. {
  147.         return ma.VMEclose(nHandle);
  148. }