#ifndef IDIBUS_1Wire_H_
#define IDIBUS_1Wire_H_

#include "IdiBusSlave.h"				//	Common slave defines
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define IDIBUS_CUSTDEF_ERCODE_OneWIRE_CHANNEL_SETTINGS_ERROR						100U
#define IDIBUS_CUSTDEF_ERCODE_OneWIRE_CHANNEL_CRC_ERROR								101U
#define IDIBUS_CUSTDEF_ERCODE_OneWIRE_CHANNEL_NO_DATA								102U
#define IDIBUS_CUSTDEF_ERCODE_OneWIRE_CHANNEL_NO_SENSOR								103U
#define IDIBUS_CUSTDEF_ERCODE_OneWIRE_CHANNEL_AUTOCONVERSION_ENABLED				105U	
#define IDIBUS_CUSTDEF_ERCODE_OneWIRE_CHANNEL_ONESHOT_IN_PROGRESS					106U	
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
enum IDIBUS_1Wire_MODULE_DEVICES_LIST {	//	Describe devices on module
	IDIBUS_1Wire_CNTRL_DEV = 0,			//	ADC device ID
	IDIBUS_1Wire_DEVICES_NUMBER			//	Device count on module
	};

enum {									//	Describe channel configuration for device (1Wire)
	IDIBUS_1Wire_CH0_NUM = 0,			//	Name for 1st channel
	IDIBUS_1Wire_CH1_NUM,				//			 2nd ...
	IDIBUS_1Wire_CH2_NUM,				//
	IDIBUS_1Wire_CH3_NUM,				//
	IDIBUS_1Wire_CH_COUNT,				// Module channel count
	};

typedef struct {
	int16_t Temperature;		//	Last voltage
	uint8_t MMES_Error;		//	Last error
} IDIBUS_1Wire_DATA_TYPE;	//	Data structure for ADC channels

class IdiBus_1Wire : public IdiBusSlave {									//	ADC module class
	public:																	//	Public methods 
 		IdiBus_1Wire ( IdiBusSerialLine *SlaveLine, uint8_t SlaveAddress);		// Init object with specified bus line and addr
		IdiBus_1Wire ();															// init without specified line and addr (default value line=NULL,addr=1)
		 	
		void	startAllOneShotConversions();
		void	changeAllAutomatiocConversionStates();
		uint8_t getTemperature(uint8_t ChNum);									// Sends MMES and gets Ch voltage (writes to CH structure and return error code)
		void    getAllChTemperature(void);											// Sends MMES and gets all Ch voltages (writes to CH structure)
			
		//void    initAllChs(void);												// Inits all adc channels on module
	
		IDIBUS_1Wire_DATA_TYPE  getChData(uint8_t ChNum);						// Returns data structure for ADC channel
	
	protected :																// 'Private' methods and structures
		IDIBUS_1Wire_DATA_TYPE  CH[IDIBUS_1Wire_CH_COUNT];						// Data structure array
			
		void    setAllChErr(uint8_t ErrCode);									// Set error code for all channels
};

#endif /* IDIBUS_41Wire_H_ */