#include "i2cmaster.h"
#include "usart.h"
#include "print.h"
//////////////////////////////////////
void delay () {
  volatile unsigned n = 5'000'000u;
  while (n--);
}
static I2CMaster iic;
static Usart serial (115200);
static Print cout   (DEC);
static const unsigned char addr = 0x90u;
static const unsigned char cmd1 [] = {1u, 6u};
static const unsigned char cmd2 [] = {0u};

int main () {
  cout += serial;
  delay();
  iic.FindActive(cout);
  iic.Send(addr, cmd1 , 2);
  iic.Send(addr, cmd2 , 1);
  
  for (;;) {
    delay();
    unsigned char buf [2];
    if (iic.Receive (addr, buf, 2)) {
      const char * d = buf [1] != 0 ? ".5" : ".0";
      cout << "T = " << (int) buf [0] << d << EOL;
    } else {
      cout << "error\r\n";
    }
  }
  return 0;
}