You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1002 B

extern "C" {
#include <Wire/Wire.h>
}
#include "../global.h"
#include "ds1624.h"
DS1624::DS1624()
{
#ifdef WIRE_LIB_SCAN_MOD
/*if (!Wire.isStarted())*/ Wire.begin();
#else
Wire.begin();
#endif
}
DS1624 TEMP = DS1624();
void DS1624::Init(void)
{
Wire.beginTransmission(DS1624_ADDR);
Wire.send(DS1624_CONFIG);
Wire.send(DS1624_CONFIGS);
Wire.endTransmission();
delay(10);
Wire.beginTransmission(DS1624_ADDR);
Wire.send(DS1624_CONFIG);
Wire.endTransmission();
Wire.requestFrom(DS1624_ADDR, 1);
Wire.beginTransmission(DS1624_ADDR);
Wire.send(DS1624_SMPL_START);
Wire.endTransmission();
#ifdef DS1624_HANDLE_BOOT_DELAY
delay(1500);
#endif
}
uint16_t DS1624::readTemp(void)
{
uint16_t res = 0;
Wire.beginTransmission(DS1624_ADDR);
Wire.send(DS1624_READ_TEMP);
Wire.endTransmission();
Wire.requestFrom(DS1624_ADDR, 2);
while (!Wire.available());
res = (uint8_t) (Wire.receive())<<8;
while (!Wire.available());
res |= (uint8_t) Wire.receive();
return res;
}