Subversion Repositories f9daq

Rev

Rev 42 | Blame | Compare with Previous | Last modification | View Log | RSS feed

//-------------------------------------------------------------------------------------------
// pcivme_ni.c - a ni labview dll skeleton for the ARW pcivme interface
//
// (c) 1999-2004 ARW Elektronik, Germany
//
// this source code is published under GPL (Open Source). You can use, redistrubute and
// modify it unless this header  is  not modified or deleted. No warranty is given that
// this software will work like expected.
// This product is not authorized for use as critical component in life support systems
// wihout the express written approval of ARW Elektronik Germany.
//
// Please announce changes and hints to ARW Elektronik
//
//
// $Log: pcivme_ni.c,v $
// Revision 1.2  2004/07/24 07:47:00  klaus
// Update copyright to 2004
//
// Revision 1.1.1.1  2003/11/14 23:17:18  klaus
// First put into repository
//
// Revision 1.2  2002/10/27 17:05:33  klaus
// CVS log added, file addressing bug > 2 Gbtye circumvent
//
// what                                                              who    when
// first steps                                                       AR     07.11.1999
//
//-------------------------------------------------------------------------------------------
// INCLUDES
//


#include <windows.h>
#include <os_info.h>
#include <pcivme_ni_NT.h>
#include <pcivme_ni.h>
#include <stdio.h>

//-------------------------------------------------------------------------------------------
// DEFINES
//
 
//-------------------------------------------------------------------------------------------
// TYPEDEFS
//
typedef struct
{
        int (*VMEinit)(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, int *pnHandle);
        int (*VMEread)(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer);
        int (*VMEwrite)(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer);
        int (*VMEaccessVIC)(int Handle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent);
        int (*VMEreset)(int Handle);
        int (*VMETAS)(int Handle, unsigned long ulAddress, unsigned char *ubResult);
        int (*VMEinterrupt)(int Handle, unsigned char *ubVector);
        int (*VMEsysfailGet)(int nHandle, BOOLEAN *bResult);
        int (*VMEsysfailSet)(int nHandle, BOOLEAN bForce);
        int (*VMEclose)(int nHandle);
} MY_ACTIONS;

//-------------------------------------------------------------------------------------------
// LOCALS
//
static MY_ACTIONS ma;  // the selected actions
static BOOLEAN firstTime = TRUE;

//-------------------------------------------------------------------------------------------
// EXTERNALS
//

//-------------------------------------------------------------------------------------------
// GLOBALS
//

//-------------------------------------------------------------------------------------------
// FUNCTIONS
//
int __declspec(dllexport) VMEinit(const char *cszDeviceName, unsigned short nVMEMM, unsigned char ubAddressModifier, int *pnHandle)
{

        if (firstTime)
        {
                if (IsWindowsNT())
                {
                        ma.VMEinit               = VMEinitNT;
                        ma.VMEread               = VMEreadNT;
                        ma.VMEwrite              = VMEwriteNT;
                        ma.VMEaccessVIC  = VMEaccessVICNT;
                        ma.VMEreset              = VMEresetNT;
                        ma.VMETAS                = VMETASNT;
                        ma.VMEinterrupt  = VMEinterruptNT;
                        ma.VMEsysfailGet = VMEsysfailGetNT;
                        ma.VMEsysfailSet = VMEsysfailSetNT;
                        ma.VMEclose              = VMEcloseNT;
                }
               
                        else
                                return -1;

                firstTime = FALSE;
        }
       
        return ma.VMEinit(cszDeviceName, nVMEMM, ubAddressModifier, pnHandle);
}

int __declspec(dllexport) VMEread(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer)
{
        return ma.VMEread(nHandle, ulAddress, ubAccessWidth, ulElementCount, pvBuffer);
}      

int __declspec(dllexport) VMEwrite(int nHandle, unsigned long ulAddress, unsigned char ubAccessWidth, unsigned long ulElementCount, void *pvBuffer)
{
        return ma.VMEwrite(nHandle, ulAddress, ubAccessWidth, ulElementCount, pvBuffer);
}

int __declspec(dllexport) VMEaccessVIC(int nHandle, unsigned char ubAccessMode, unsigned short uwAddress, unsigned char *ubContent)
{
        return ma.VMEaccessVIC(nHandle, ubAccessMode, uwAddress, ubContent);
}

int __declspec(dllexport) VMEreset(int nHandle)
{
        return ma.VMEreset(nHandle);
}

int __declspec(dllexport) VMETAS(int nHandle, unsigned long ulAddress, unsigned char *ubResult)
{
        return ma.VMETAS(nHandle, ulAddress, ubResult);
}

int __declspec(dllexport) VMEsysfailGet(int nHandle, BOOLEAN *bResult)
{
        return ma.VMEsysfailGet(nHandle, bResult);
}

int __declspec(dllexport) VMEsysfailSet(int nHandle, BOOLEAN bForce)
{
        return ma.VMEsysfailSet(nHandle, bForce);
}

int __declspec(dllexport) VMEinterrupt(int nHandle, unsigned char *ubVector)
{
        return ma.VMEinterrupt(nHandle, ubVector);
}

int __declspec(dllexport) VMEclose(int nHandle)
{
        return ma.VMEclose(nHandle);
}