#include "i2c.h" #include "types.h" #include "hwconfig.h" #include float gettemp(void) { float temp = 0; char i2cbuf[2] = {0, 0}; I2C_MESSAGE probemsg; probemsg.address = DS75_RW|1; probemsg.buf = i2cbuf; probemsg.nrBytes = 2; I2C_Read(&probemsg); temp += (signed char)i2cbuf[0]; if(i2cbuf[1] & 0x40) { temp += 0; } if(i2cbuf[1] & 0x80) { temp += .5; } if(i2cbuf[1] & 0x40) { temp += .25; } if(i2cbuf[1] & 0x20) { temp += .125; } if(i2cbuf[1] & 0x10) { temp += .0625; } return temp; } float ctof(float ctemp) { return (9.0/5.0) * ctemp + 32; }