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.
16 /* Number of probes supported */
17 #define DS1820_MAXPROBES 4
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
24 #define DS1820FLAG_SLOTINUSE 0x01 /* 1 if this slot is in use */
25 #define DS1820FLAG_PARASITE 0x02 /* 1 if the device is parasite powered */
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
39 uint8_t lasttemp[2]; /* Temperature we read last */
40 uint32_t lastts; /* Timestamp when we last read it */
43 extern struct probe ds1820probes[DS1820_MAXPROBES];
45 /* Inits ds1820 code and bus */
46 void ds1820init(void);
48 /* Actively pull down the bus. For hard resetting probes that have gone
50 void ds1820killbus(void);
52 /* Scan the bus to find all probes. Populates the ds1820probes array. */
53 void ds1820scan(void);
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);
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);
67 #endif /* __DS1820_H__ */