Mercurial > ~darius > hgwebdir.cgi > tempctrl
annotate 1wire.h @ 77:ca5fc59ec4f0
Change default temperature to 18C - better for Ale yeast.
author | darius@Inchoate |
---|---|
date | Wed, 21 Jan 2009 22:51:59 +1030 |
parents | 4abce5954d25 |
children |
rev | line source |
---|---|
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
0
diff
changeset
|
1 /* |
32
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
2 * 1 wire header which defines functions and constants |
8
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
0
diff
changeset
|
3 * |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
0
diff
changeset
|
4 * $Id$ |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
0
diff
changeset
|
5 * |
f9a085a0ba93
Change the 1 wire routines to mostly C with assembly delay routines
darius
parents:
0
diff
changeset
|
6 * Copyright (c) 2004 |
0 | 7 * Daniel O'Connor <darius@dons.net.au>. All rights reserved. |
8 * | |
9 * Redistribution and use in source and binary forms, with or without | |
10 * modification, are permitted provided that the following conditions | |
11 * are met: | |
12 * 1. Redistributions of source code must retain the above copyright | |
13 * notice, this list of conditions and the following disclaimer. | |
14 * 2. Redistributions in binary form must reproduce the above copyright | |
15 * notice, this list of conditions and the following disclaimer in the | |
16 * documentation and/or other materials provided with the distribution. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
21 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE | |
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 * SUCH DAMAGE. | |
29 */ | |
30 | |
32
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
31 void OWInit(void); |
12 | 32 uint8_t OWTouchReset(void); |
33 void OWWriteBit(uint8_t bit); | |
34 uint8_t OWReadBit(void); | |
0 | 35 void OWWriteByte(uint8_t data); |
12 | 36 uint8_t OWReadByte(void); |
37 uint8_t OWTouchByte(uint8_t data); | |
0 | 38 void OWBlock(uint8_t *data, int len); |
12 | 39 uint8_t OWFirst(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only); |
40 uint8_t OWNext(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only); | |
0 | 41 void OWCRC(uint8_t x, uint8_t *crc); |
42 void OWSendCmd(uint8_t *ROM, uint8_t cmd); | |
33
0aa6bf4b98ae
- Don't wrap individual debug statements in ifdef, use a conditionally
darius
parents:
32
diff
changeset
|
43 uint8_t OWProgROM(uint8_t *ROM, uint8_t start, uint8_t len, uint8_t *data, uint8_t exact, uint8_t status); |
41 | 44 int16_t OWGetTemp(uint8_t *ROM); |
76
4abce5954d25
Add a routine to return text versions of errors from the temperature
darius@Inchoate
parents:
75
diff
changeset
|
45 const PROGMEM char *OWTempStatusStr(int16_t val, uint8_t shrt); |
48
94f71ddb0cda
Move declaration of error table up with the function declarations.
darius@Inchoate
parents:
45
diff
changeset
|
46 extern const PROGMEM char *OWProgROM_Status[]; |
94f71ddb0cda
Move declaration of error table up with the function declarations.
darius@Inchoate
parents:
45
diff
changeset
|
47 |
0 | 48 |
10 | 49 /* Return codes for OWFirst()/OWNext() */ |
50 #define OW_BADWIRE -3 | |
51 #define OW_BADCRC -2 | |
52 #define OW_NOPRESENCE -1 | |
53 #define OW_NOMODULES 0 | |
54 #define OW_FOUND 1 | |
55 | |
0 | 56 /* General 1 wire commands */ |
57 #define OW_OVRDRV_SKIP_CMD 0x3c | |
58 #define OW_SEARCH_ALRM_CMD 0xec | |
59 #define OW_SEARCH_ROM_CMD 0xf0 | |
60 #define OW_READ_ROM_CMD 0x33 | |
61 #define OW_MATCH_ROM_CMD 0x55 | |
62 #define OW_SKIP_ROM_CMD 0xcc | |
63 | |
64 /* DS1820 commands */ | |
65 #define OW_CONVERTT_CMD 0x44 | |
66 #define OW_RD_SCR_CMD 0xbe | |
67 #define OW_WR_SCR_CMD 0x4e | |
68 #define OW_CPY_SCR_CMD 0x48 | |
69 #define OW_RECALL_CMD 0xb8 | |
70 #define OW_RD_PSU_CMD 0xb4 | |
71 | |
32
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
72 /* DS2502 commands */ |
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
73 #define OW_READ_MEMORY 0xf0 |
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
74 #define OW_READ_STATUS 0xaa |
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
75 #define OW_GEN_CRC 0xc3 |
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
76 #define OW_WRITE_MEMORY 0x0f |
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
77 #define OW_WRITE_STATUS 0x55 |
b0cb873c0206
Isolate the bus frobbing parts and the delays into a separate header.
darius
parents:
24
diff
changeset
|
78 |
0 | 79 /* Family codes */ |
80 #define OW_FAMILY_ROM 0x09 | |
81 #define OW_FAMILY_TEMP 0x10 | |
41 | 82 |
83 /* Return codes for OWGetTemp */ | |
75
39d629c7d935
Change error #define's so that they are outside the range the DS1820 can report.
darius@Inchoate
parents:
65
diff
changeset
|
84 #define OW_TEMP_BADVAL -6000 |
39d629c7d935
Change error #define's so that they are outside the range the DS1820 can report.
darius@Inchoate
parents:
65
diff
changeset
|
85 #define OW_TEMP_WRONG_FAM -6001 |
39d629c7d935
Change error #define's so that they are outside the range the DS1820 can report.
darius@Inchoate
parents:
65
diff
changeset
|
86 #define OW_TEMP_CRC_ERR -6002 |
39d629c7d935
Change error #define's so that they are outside the range the DS1820 can report.
darius@Inchoate
parents:
65
diff
changeset
|
87 #define OW_TEMP_NO_ROM -6003 |
45
efd44dc40934
Add macros for number system used for temperatures.
darius@Inchoate
parents:
41
diff
changeset
|
88 |
efd44dc40934
Add macros for number system used for temperatures.
darius@Inchoate
parents:
41
diff
changeset
|
89 /* Helpers for OWGetTemp's number system */ |
efd44dc40934
Add macros for number system used for temperatures.
darius@Inchoate
parents:
41
diff
changeset
|
90 #define GETWHOLE(x) ((x) / 100) |
65 | 91 #define GETFRAC(x) abs((x) - (GETWHOLE(x) * 100)) |