/*[CR]*************************************************************************

  Copyright (c) 2003 by PEP Modular Computers GmbH

  All Rights reserved.

*/
/*[FH]*************************************************************************
  FILE:     hwmon_common.h
  MODULE:   HWMON
  CMM ID:   $ID$
  CONTENTS: Common interface definitions
*/


#ifndef __hwmon_common__h_
#define __hwmon_common__h_

#ifdef __cplusplus
extern "C" {
#endif

//=============================================================================
// Defines
//=============================================================================
#define DEFAULT_VALUE		0
#define HIGH_LIMIT_VALUE	1
#define LOW_LIMIT_VALUE		2
#define HIST_VALUE			3
#define DIVISOR_VALUE		4
#define DAC_VALUE			5


#define MAX_SENSOR_NAME		20
#define MAX_TEMP_SENSOR		16
#define MAX_VOLTAGE_SENSOR	16
#define MAX_FAN_SENSOR		16


//=============================================================================
// Types
//=============================================================================

typedef enum {stUnknown, stTemperature, stVoltage, stFan, stDac} TSensorType;


//=============================================================================
// Structures
//=============================================================================
#pragma pack(1)

//
// structure used by GetLibraryInfo
//
typedef struct _LIBRARY_INFO
{
	char  *description;				// character string describing library
	char  strVersion[24];			// library version in string format 
	DWORD (*Connect) (UCHAR);		// pointer to connect function
	DWORD (*Disconnect) (UCHAR);	// pointer to disconnect function
	DWORD (*SensorInfoGet)(TSensorType, UCHAR, PVOID);
	DWORD (*SensorCountGet)(TSensorType, PUCHAR);
	DWORD (*GetValue)(UCHAR, TSensorType, UCHAR, UCHAR, PCHAR);
	DWORD (*SetValue)(UCHAR, TSensorType, UCHAR, UCHAR, CHAR);
	UCHAR minDevAddress;			// minimal device address on SM Bus
	UCHAR maxDevAddress;			// maximal device address on SM Bus
} LIBRARY_INFO, *PLIBRARY_INFO;



typedef struct _TEMP_SENSOR
{
 	char 		Name[MAX_SENSOR_NAME];	// name of sensor
	double 		LSB;		
	char		min;					// minimal temperature
	char		max; 					// maximal temperature

}TEMP_SENSOR, *PTEMP_SENSOR;


typedef struct _VOLT_SENSOR
{
 	char 		Name[MAX_SENSOR_NAME];	// name of sensor
	double 		LSB;

}VOLT_SENSOR, *PVOLT_SENSOR;


typedef struct _FAN_SENSOR
{
 	char 		Name[MAX_SENSOR_NAME];	// name of sensor
	double 		LSB;
	UCHAR		divisors;				// number of divisors 

}FAN_SENSOR, *PFUN_SENSOR;

#pragma pack(8)


//=============================================================================
// Declarations
//=============================================================================

/*******************************************************************************
*
* GetLibraryInfo - get structure describing library	
* 
* PARAMETERS: This routine requires the following parameter
*
* PLIBRARY_INFO pLibInfo - valid pointer to LIBRARY_INFO structure
*
* RETURNS:	ERROR_SUCCESS					
*			ERROR_INVALID_PARAMETER			pointer is incorrect
*/
__declspec(dllexport) DWORD GetLibraryInfo( 
										   PLIBRARY_INFO pLibInfo 
										   );



/*******************************************************************************
*
* GetValue - gets specify value from device	
* 
* PARAMETERS: This routine requires the following parameter
*
* UCHAR SmbAddr				- must be set to a valid SM bus address
* TSensorType sensorType	- type of sensor
* UCHAR Sensor				- sensor number	
* UCHAR valueType			- type of value to read
* PCHAR pValue				- pointer to location to store value 
*
* RETURNS:	ERROR_SUCCESS					
*			ERROR_INVALID_PARAMETER			pointer to pValue is incorrect
*											SmbAddr is incorrect
*											incorect sensor number
*											incorrect value type
*/
__declspec(dllexport) DWORD GetValue( UCHAR SmbAddr, 
									 TSensorType sensorType , 
									 UCHAR Sensor,  
									 UCHAR valueType, 
									 PCHAR pValue);




/*******************************************************************************
*
* SetValue - sets specify value from device	
* 
* PARAMETERS: This routine requires the following parameter
*
* UCHAR SmbAddr				- must be set to a valid SM bus address
* TSensorType sensorType	- type of sensor
* UCHAR Sensor				- sensor number	
* UCHAR valueType			- type of value to read
* PCHAR pValue				- value 
*
* RETURNS:	ERROR_SUCCESS					
*			ERROR_INVALID_PARAMETER			SmbAddr is incorrect
*											incorect sensor number
*											incorrect value type
*/
__declspec(dllexport) DWORD SetValue( UCHAR SmbAddr, 
									 TSensorType sensorType , 
									 UCHAR Sensor,  
									 UCHAR valueType, 
									 CHAR Value);


/*******************************************************************************
*
* SensorInfoGet - gets information describing sensor
* 
* PARAMETERS: This routine requires the following parameter
*
* TSensorType sensorType	- type of sensor
* UCHAR Sensor				- sensor number	
* PVOID pInfo				- pointer to location to store structure describing sensor 
*
* RETURNS:	ERROR_SUCCESS					
*			ERROR_INVALID_PARAMETER			pointer to pInfo is incorrect
*											incorect sensor number
*											
*/
__declspec(dllexport) DWORD SensorInfoGet( TSensorType sensorType, 
										  UCHAR sensor, 
										  PVOID pInfo);


/*******************************************************************************
*
* SensorCountGet - gets number of sensors
* 
* PARAMETERS: This routine requires the following parameter
*
* TSensorType sensorType	- type of sensor
* PUCHAR pCount				- pointer to location to store number of senors
*
* RETURNS:	ERROR_SUCCESS					
*			ERROR_INVALID_PARAMETER			pointer to pCount is incorrect
*											
*											
*/
__declspec(dllexport) DWORD SensorCountGet( TSensorType sensorType, 
										   PUCHAR pCount );


#ifdef __cplusplus
}
#endif


#endif