#ifndef	_FILE_AD77X8_DRIVER_H_
#define	_FILE_AD77X8_DRIVER_H_

// ****************************************************************************
// CONDITIONAL COMPILATION DIRECTIVES: Conditional compilation control
// ****************************************************************************


// ****************************************************************************
// INCLUDE FILES: Header files of modules referenced by this module
// ****************************************************************************
#include <stdint.h>
#include <stdbool.h>


// ****************************************************************************
// MODULE DOCUMENTATION: Detailed description of the module
// ****************************************************************************


// ****************************************************************************
// PUBLIC TYPES: Public types shared with other modules
// ****************************************************************************
typedef struct
{
	uint8_t ChopingDisabled;
	uint8_t CommonInputBuffered;
	uint8_t ReferenceSelection;
	uint8_t ChannelConfiguration;
	uint8_t OscilatorPowerDownEnabled;
}Ad77x8Opt_t;

typedef enum
{
	AD77X8_CHANNEL_AIN1_AINCOM,
	AD77X8_CHANNEL_AIN2_AINCOM,
	AD77X8_CHANNEL_AIN3_AINCOM,
	AD77X8_CHANNEL_AIN4_AINCOM,
	AD77X8_CHANNEL_AIN5_AINCOM,
	AD77X8_CHANNEL_AIN6_AINCOM,
	AD77X8_CHANNEL_AIN7_AINCOM,
	AD77X8_CHANNEL_AIN8_AINCOM,
	AD77X8_CHANNEL_AIN1_AIN2,
	AD77X8_CHANNEL_AIN3_AIN4,
	AD77X8_CHANNEL_AIN5_AIN6,
	AD77X8_CHANNEL_AIN7_AIN8,
	AD77X8_CHANNEL_AIN2_AIN2,
	AD77X8_CHANNEL_AIN9_AIN10 = AD77X8_CHANNEL_AIN2_AIN2,
	AD77X8_CHANNEL_AINCOM_AINCOM,
	AD77X8_CHANNEL_REFINP_REFINN,
	AD77X8_CHANNEL_AIN9_AINCOM = AD77X8_CHANNEL_REFINP_REFINN,
	AD77X8_CHANNEL_AIN10_AINCOM,
	AD77X8_CHANNEL_NUM,
}Ad77x8Channel_t;

typedef enum
{
	AD77X8_RANGE_20_MV,
	AD77X8_RANGE_40_MV,
	AD77X8_RANGE_80_MV,
	AD77X8_RANGE_160_MV,
	AD77X8_RANGE_320_MV,
	AD77X8_RANGE_640_MV,
	AD77X8_RANGE_1280_MV,
	AD77X8_RANGE_2560_MV,
}Ad77x8Range_t;

typedef enum
{
	AD77X8_POLARITY_BIPOLAR = 0,
	AD77X8_POLARITY_UNIPOLAR = 1,
}Ad77x8Polarity_t;

typedef struct  
{
    Ad77x8Range_t range;
    Ad77x8Polarity_t polarity;
}Ad77x8ChnlOpt_t;


// ****************************************************************************
// PUBLIC MACROS: Public #define directives shared with other modules
// ****************************************************************************
#define AD77X8_OPT_CHOPING_ENABLED		 (0x0)
#define AD77X8_OPT_CHOPING_DISABLED		 (0x1)
#define AD77X8_OPT_COM_IN_UNBUFFERED	 (0x0)
#define AD77X8_OPT_COM_IN_BUFFERED		 (0x1)
#define AD77X8_OPT_CHANNEL_CFG_8_INPUTS  (0x0)
#define AD77X8_OPT_CHANNEL_CFG_10_INPUTS (0x1)

// ****************************************************************************
// PUBLIC VARIABLES: Public variables shared with other modules
// ****************************************************************************


// ****************************************************************************
// PUBLIC FUNCTIONS: Public functions shared with other modules
// ****************************************************************************
uint8_t Ad77x8DriverInit( Ad77x8Opt_t const * options );
void Ad77x8DriverInitSPIOnly(void);
uint8_t Ad77x8DriverSetUpdateRate( uint16_t updateRateHz );
void Ad77x8DriverStartContinousConversion( Ad77x8Channel_t channel, Ad77x8ChnlOpt_t const * channelOptions );
void Ad77x8DriverChangeContConversionChannel( Ad77x8Channel_t channel, Ad77x8ChnlOpt_t const * channelOptions );
void Ad77x8DriverStartSingleConversion( Ad77x8Channel_t channel, Ad77x8ChnlOpt_t const * channelOptions );
bool Ad77x8ReadRawConversionResult( uint32_t * rawResult, uint8_t * statusReg );
bool Ad77x8ReadConversionResult( float * resultmV, uint8_t * statusReg );

#endif   //_FILE_AD77X8_DRIVER_H_