/*
 * 
 */

 #ifndef LTC2497_H
 #define LTC2497_H

 #include "I2CDevice.h"

 class LTC2497 : public I2CDevice
 {
  public:
    enum ADC_CHAN { CHAN_0 = 0b00000000, 
                    CHAN_1 = 0b00001000, 
                    CHAN_2 = 0b00000001, 
                    CHAN_3 = 0b00001001, 
                    CHAN_4 = 0b00000010, 
                    CHAN_5 = 0b00001010, 
                    CHAN_6 = 0b00000011, 
                    CHAN_7 = 0b00001011, 
                    CHAN_8 = 0b00000100, 
                    CHAN_9 = 0b00001100, 
                    CHAN_10 = 0b00000101, 
                    CHAN_11 = 0b00001101, 
                    CHAN_12 = 0b00000110, 
                    CHAN_13 = 0b00001110, 
                    CHAN_14 = 0b00000111, 
                    CHAN_15 = 0b00001111};
                    
    LTC2497(const uint8_t address = 0x45, double vref = 3300);

    virtual boolean begin(){return I2CDevice::begin();};
    void setVref(double vref);
    int32_t sampleValue(ADC_CHAN channel, boolean sgl = true);
    int32_t sampleValue();
    double sampleVoltage(ADC_CHAN channel, boolean sgl = true);
    double sampleVoltage();
  protected:
  private:
    double _vref; //Delta de tension de la plage : vref-gnd en mV
    uint8_t _dataBytes[3], _adcRes;
    double _quantum;
 };
 
 #endif //LTC2497_H
