device enumeration works, and it's much faster than under BASIC :-)
git-svn-id: https://svn.salfter.gotdns.org/svn/a2bfc/trunk@87 1b90f75b-8b96-4784-87c0-14078182fce6
This commit is contained in:
25
ow-temp.c
25
ow-temp.c
@@ -6,20 +6,15 @@ short ow_temp_read(unsigned char* devid, unsigned char format)
|
||||
short rawtemp;
|
||||
unsigned char i;
|
||||
|
||||
if (devid[0]!=40)
|
||||
if (!ow_temp_idcheck(devid))
|
||||
return OW_ERR_INVALIDDEVICE;
|
||||
do
|
||||
{
|
||||
ow_selectdevice(devid);
|
||||
ow_writebyte(68); // ask for a temperature reading
|
||||
ow_wait(); // wait for operation to complete
|
||||
ow_selectdevice(devid);
|
||||
ow_writebyte(190); // retrieve the reading
|
||||
for (i=0; i<8; i++)
|
||||
data[i]=ow_readbyte();
|
||||
ow_mswait();
|
||||
}
|
||||
while (ow_crc(data,8)!=0); // repeat until we get a valid reading
|
||||
ow_selectdevice(devid);
|
||||
ow_writebyte(68); // ask for a temperature reading
|
||||
ow_wait(); // wait for operation to complete
|
||||
ow_selectdevice(devid);
|
||||
ow_writebyte(190); // retrieve the reading
|
||||
for (i=0; i<8; i++)
|
||||
data[i]=ow_readbyte();
|
||||
|
||||
rawtemp=(short)(data[0]+((int)data[1]<<8));
|
||||
switch (format)
|
||||
@@ -34,3 +29,7 @@ short ow_temp_read(unsigned char* devid, unsigned char format)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char ow_temp_idcheck(unsigned char* devid)
|
||||
{
|
||||
return (devid[0]==40)?1:0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user