manueller import aus nem CVS checkout (ist eh nur zum testen)
[ds1820tousb.git] / ds1820.h
1 /* $Id: ds1820.h,v 1.2 2010/03/23 07:57:04 simimeie Exp $
2  * USB interface for ds1820
3  * This file handles everything that has to do with the temperature probes.
4  * (C) Michael "Fox" Meier 2009
5  * There are two modes: KISS (keep it simple stupid), activated when you
6  * define KISS, can only ever support one probe on the bus. When KISS is
7  * not defined, multiple probes are supported up to a compile time maximum,
8  * and the bus is searched for probes.
9  */
10
11 #ifndef __DS1820_H__
12 #define __DS1820_H__
13
14 #include <inttypes.h> 
15
16 /* Number of probes supported */
17 #define DS1820_MAXPROBES  4
18
19 #ifdef KISS  /* We can only ever handle one probe in this mode, so override define */
20 #undef DS1820_MAXPROBES
21 #define DS1820_MAXPROBES 1
22 #endif
23
24 #define DS1820FLAG_SLOTINUSE  0x01      /* 1 if this slot is in use */
25 #define DS1820FLAG_PARASITE   0x02      /* 1 if the device is parasite powered */
26
27 #define DS1820_CMD_SEARCHROM    0xF0
28 #define DS1820_CMD_SKIPROM      0xCC
29 #define DS1820_CMD_MATCHROM     0x55
30 #define DS1820_CMD_READROM      0x33
31 #define DS1820_CMD_CONVERTT     0x44
32 #define DS1820_CMD_READSCRPAD   0xBE
33 #define DS1820_CMD_READPOWER    0xB4
34
35 struct probe {
36   uint8_t family;
37   uint8_t serial[6];
38   uint8_t flags;
39   uint8_t lasttemp[2]; /* Temperature we read last */
40   uint32_t lastts;  /* Timestamp when we last read it */
41 };
42
43 extern struct probe ds1820probes[DS1820_MAXPROBES];
44
45 /* Inits ds1820 code and bus */
46 void ds1820init(void);
47
48 /* Actively pull down the bus. For hard resetting probes that have gone
49  * bonkers. */
50 void ds1820killbus(void);
51
52 /* Scan the bus to find all probes. Populates the ds1820probes array. */
53 void ds1820scan(void);
54
55 /* Tells one probe to do temperature conversion. Since that takes
56  * about 1 second, you will need to wait that long before
57  * calling ds1820updateprobe.
58  * the number is the index number for the ds1820probes array. */
59 void ds1820queryprobe(uint8_t probenum);
60
61 /* Reads the answer from the probe queried with ds1820queryprobe
62  * before and updates its data.
63  * the number is the index number for the ds1820probes array.
64  * Returns 1 on successful update, 0 otherwise */
65 uint8_t ds1820updateprobe(uint8_t probenum);
66
67 #endif /* __DS1820_H__ */
This page took 0.0807290000000001 seconds and 3 git commands to generate.