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:
19
main.c
19
main.c
@@ -5,13 +5,18 @@
|
||||
|
||||
int main (void)
|
||||
{
|
||||
unsigned char devid[8]={40,12,203,62,0,0,0,108};
|
||||
short i;
|
||||
short i, devcount;
|
||||
unsigned char devs[80];
|
||||
unsigned char* tempsensor=NULL;
|
||||
unsigned char* clock=NULL;
|
||||
|
||||
// activate temperature sensor
|
||||
if (ow_reset())
|
||||
devcount=ow_enumeratedevices(devs, 10);
|
||||
for (i=0; i<devcount; i++)
|
||||
if (ow_temp_idcheck(&devs[i<<3]))
|
||||
tempsensor=&devs[i<<3];
|
||||
if (tempsensor==NULL)
|
||||
{
|
||||
printf("Error: 1-Wire bus disconnected\n");
|
||||
printf("Error: no temperature sensor found.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -19,9 +24,9 @@ int main (void)
|
||||
{
|
||||
do
|
||||
{
|
||||
for (i=0; i<500; i++)
|
||||
for (i=0; i<250; i++)
|
||||
ow_mswait();
|
||||
printf("%i deg F\n", ow_temp_read(devid, OW_TEMP_FAHRENHEIT));
|
||||
printf("%i deg F\n", ow_temp_read(tempsensor, OW_TEMP_FAHRENHEIT));
|
||||
}
|
||||
while (!kbhit());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user