#ifndef _BIWAK_STLM75DS2F_H_
#define _BIWAK_STLM75DS2F_H_

#include <biwak/gpio.hpp>
#include <biwak/i2c_slave.h>
#include <biwak/input.hpp>
#include <lepto/log.h>

// With all address pins low the address is 0x48:7Bit

class CStlm75ds2f: public CI2cSlave
{
private:
   //CI2c     &m_i2c;

public:
   CStlm75ds2f(CI2c &i2c, int addr);
   int getTemperature()
   {
      //int data=0;
      char data[2];
      //m_i2c.readWord(0x48, 0)
      //int sta=m_i2c.readData(0x48 , 0, &data, 1);
      //int sta=m_i2c.readData(0x48 , 2, &data, 2);
      int sta=i2cReadData(0, &data, 2);
      int value=(data[0]<<1) | (data[1]>>7);
      value*=50;

      if(sta!=HAL_OK)
      {
         value=-1;
      }
      return(value);
   }
   int getConfig()
   {
      char data;
      int sta=i2cReadData(1, &data, 1);
      lAssert( sta == 0 );

      return(data);
   }
};


#endif // _BIWAK_STLM75DS2F_H_
