PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
TC74 simple driver |
Posted: Thu May 10, 2007 5:17 am |
|
|
Code: |
#ifndef TC74
#define TC74
#define TMP_write 0B10010000
#define TMP_read 0B10010001
#define _TMPREG_ 0x00
#define _CONFREG_ 0x01
void TC74Init()
{
i2c_start();
i2c_write(TMP_write);
i2c_write(_CONFREG_);
i2c_write(0x00);
i2c_stop();
}
byte GetTemp()
{
byte temp;
i2c_start();
i2c_write(TMP_write);
i2c_write(_TMPREG_);
i2c_start(); // restart
i2c_write(TMP_read);
temp = i2c_read(0);
i2c_stop();
return temp;
}
#endif
|
|
|