// DS1822OD.c
// STUB

#include "DS1822OD.h"

static int index = 0;

UInt8 msb_values_OD [] = {
  0xFF,
  0xFC,
  0xFE,
  0xFF,
  0xFF,
  0x00,
  0x00,
  0x00,
  0x01,
  0x05
};

UInt8 lsb_values_OD [] = {
  0xFF,
  0x90,
  0x6F,
  0x5E,
  0xF8,
  0x00,
  0x08,
  0xA2,
  0x91,
  0x50
};

UInt8 GetLsbOD () { 
  if (index > 9) return 0xFF;
  return lsb_values_OD[index];
}
UInt8 GetMsbOD () {
  UInt8 value;
  if (index > 9) return 0xFF;
  
  value = msb_values_OD[index];
  index++;
  return value;
}

// Return value :
// 0 : Failed
// 1 : Conversion started
UInt8 DS1822OD_StartConversion () {
  return 1;
}

UInt8 DS1822OD_ReadTemperature(UInt8 *lsb, UInt8 *msb) {
  static UInt16 tmp = 0x0300;

  //*lsb = GetLsb ();
  //*msb = GetMsb ();
  *lsb = tmp & 0xFF;
  *msb = ( tmp >> 8) & 0xFF;
  tmp-=0x0008;
  return 1; // Valid

}

// Return value :
// 0 : Failed
// 1 : Conversion started
UInt8 DS1822OD_Init (UInt8 mode) {
  index = 0;
  return 1;
}


// End of file
