Files
a2bfc/main.c
(no author) d8a3fd2194 added RTC functions
git-svn-id: https://svn.salfter.gotdns.org/svn/a2bfc/trunk@89 1b90f75b-8b96-4784-87c0-14078182fce6
2007-09-24 05:41:06 +00:00

61 lines
1.1 KiB
C

#include <stdio.h>
#include <conio.h>
#include "ow.h"
#include "ow-temp.h"
#include "ow-time.h"
#include <errno.h>
int main (void)
{
short i, devcount;
unsigned char devs[80];
unsigned char* tempsensor=NULL;
unsigned char* clock=NULL;
time_t t;
// unsigned char c1, c2;
devcount=ow_enumeratedevices(devs, 10);
/*//
for (c1=0; c1<devcount; c1++)
{
printf("%i: ", c1);
for (c2=0; c2<8; c2++)
printf("%02X ", devs[(c1<<3)+c2]);
printf("\n");
}
//*/
for (i=0; i<devcount; i++)
{
if (ow_temp_idcheck(&devs[i<<3]))
tempsensor=&devs[i<<3];
if (ow_time_idcheck(&devs[i<<3]))
clock=&devs[i<<3];
}
if (tempsensor==NULL || clock==NULL)
{
printf("Error: temperature sensor and/or clock not found.\n");
return -1;
}
ow_time_set(clock, 1190611728-28800);
do
{
do
{
for (i=0; i<250; i++)
ow_mswait();
t=ow_time_read(clock);
printf("%i deg F %s",
ow_temp_read(tempsensor, OW_TEMP_FAHRENHEIT),
asctime(localtime(&t)));
}
while (!kbhit());
}
while (cgetc()!=3);
return 0;
}