#ifndef PRXINTERNAL_H
#define PRXINTERNAL_H

#ifdef __cplusplus
extern "C" {
#endif

#ifndef	PRX_EXPORTS
#error PRXInternal.h should not be included outside the DLL
#endif

#include <stdarg.h>

#include "NDTSEnums.h"
#include "PRXProtected.h"
#include "PRXMemorySpace.h"

// #defines moved from here to RQProtected.h
// since they might reasonably be of use outside the DLL
typedef struct 
{
    PRX_ReturnCode code ;
    char *codeString ;
} PRX_Errors ;


// RQ_ functions below are for multi-card systems
// The above RQ_ functions are now wrappers for legacy single-card apps

/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_OpenDMAChannel(unsigned long card) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_CloseDMAChannel(unsigned long card) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_SystemRAMTest(unsigned long card) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_SystemFPGAInversionTest(unsigned long card) ;

PRX_API void CALL_CONV PRX_Lock(unsigned long card);
PRX_API void CALL_CONV PRX_Unlock(unsigned long card);

PRX_API NDTS_Boolean CALL_CONV PRX_Commit(unsigned long card);

/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_AddDiagnosticString(unsigned long card, unsigned long registerOffset, unsigned long registerValue) ;

//System FPGA Registers

/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_SetCheckData(unsigned long card, unsigned long data) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_GetCheckData(unsigned long card, unsigned long *pValue) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_SetProgramFPGAs(unsigned long card) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_SetWriteEEPROM(unsigned long card) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_SetReadEEPROM(unsigned long card) ;

/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_SetSystemRegister(unsigned long card, unsigned long offset, unsigned long value) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_GetSystemRegister(unsigned long card, unsigned long offset, unsigned long *value) ;

/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_GetSRAMLong(unsigned long card, unsigned long offset, unsigned long *value) ;
/*PRX_API*/ NDTS_Boolean CALL_CONV PRX_SetSRAMLong(unsigned long card, unsigned long offset, unsigned long value) ;

/*PRX_API*/ void CALL_CONV PRX_CreateCriticalSection(unsigned long card) ;
/*PRX_API*/ void CALL_CONV PRX_DeleteCriticalSection(unsigned long card) ;

// These functions have been added to give a fine grained access to the initialise process.
// They are not designed for general use.
// After calling RQ_StructuresInitialise() it is up to the caller to call RQ_Unlock() when
// the initialisation is complete.

// pci Initiailise has been removed from the main init function 
// so the Hardware Test Script app can just initialise the pci without
// doing a full init


NDTS_Boolean CALL_CONV PRX_GetReadEEPROM(unsigned long card, unsigned long *flag);

void CALL_CONV PRX_HandlePRXError(PRX_ReturnCode code);
PRX_API char * CALL_CONV PRX_GetPRXCodeString(PRX_ReturnCode errorCode);

NDTS_Boolean CALL_CONV PRX_SetSystemRegister(unsigned long card, unsigned long offset, unsigned long value);
NDTS_Boolean CALL_CONV PRX_GetSystemRegister(unsigned long card, unsigned long offset, unsigned long *value);

NDTS_Boolean CALL_CONV PRX_LimitPulseWidth(unsigned long card);


// This is global so that a function can check if a card number is valid
extern unsigned long prxs_found ;

extern NDTS_Boolean CALL_CONV PRX_CommitConditional(unsigned long card);

NDTS_Boolean CALL_CONV PRX_CheckState(unsigned long cardIndex) ;

#ifdef __cplusplus
}
#endif


#endif
