0
|
1 /*
|
|
2 * 1 wire header which defines functions and constants
|
|
3 *
|
|
4 * Copyright (c) 2004
|
|
5 * Daniel O'Connor <darius@dons.net.au>. All rights reserved.
|
|
6 *
|
|
7 * Redistribution and use in source and binary forms, with or without
|
|
8 * modification, are permitted provided that the following conditions
|
|
9 * are met:
|
|
10 * 1. Redistributions of source code must retain the above copyright
|
|
11 * notice, this list of conditions and the following disclaimer.
|
|
12 * 2. Redistributions in binary form must reproduce the above copyright
|
|
13 * notice, this list of conditions and the following disclaimer in the
|
|
14 * documentation and/or other materials provided with the distribution.
|
|
15 *
|
|
16 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
19 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
26 * SUCH DAMAGE.
|
|
27 */
|
|
28
|
|
29 void OWInit(void);
|
|
30 uint8_t OWTouchReset(void);
|
|
31 void OWWriteBit(uint8_t bit);
|
|
32 uint8_t OWReadBit(void);
|
|
33 void OWWriteByte(uint8_t data);
|
|
34 uint8_t OWReadByte(void);
|
|
35 uint8_t OWTouchByte(uint8_t data);
|
|
36 void OWBlock(uint8_t *data, int len);
|
|
37 uint8_t OWFirst(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only);
|
|
38 uint8_t OWNext(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only);
|
|
39 void OWCRC(uint8_t x, uint8_t *crc);
|
|
40 void OWSendCmd(uint8_t *ROM, uint8_t cmd);
|
|
41 uint8_t OWProgROM(uint8_t *ROM, uint8_t start, uint8_t len, uint8_t *data, uint8_t exact, uint8_t status);
|
|
42 int16_t OWGetTemp(uint8_t *ROM);
|
|
43 const PROGMEM char *OWTempStatusStr(int16_t val, uint8_t shrt);
|
|
44 extern const PROGMEM char *OWProgROM_Status[];
|
|
45
|
|
46
|
|
47 /* Return codes for OWFirst()/OWNext() */
|
|
48 #define OW_BADWIRE -3
|
|
49 #define OW_BADCRC -2
|
|
50 #define OW_NOPRESENCE -1
|
|
51 #define OW_NOMODULES 0
|
|
52 #define OW_FOUND 1
|
|
53
|
|
54 /* General 1 wire commands */
|
|
55 #define OW_OVRDRV_SKIP_CMD 0x3c
|
|
56 #define OW_SEARCH_ALRM_CMD 0xec
|
|
57 #define OW_SEARCH_ROM_CMD 0xf0
|
|
58 #define OW_READ_ROM_CMD 0x33
|
|
59 #define OW_MATCH_ROM_CMD 0x55
|
|
60 #define OW_SKIP_ROM_CMD 0xcc
|
|
61
|
|
62 /* DS1820 commands */
|
|
63 #define OW_CONVERTT_CMD 0x44
|
|
64 #define OW_RD_SCR_CMD 0xbe
|
|
65 #define OW_WR_SCR_CMD 0x4e
|
|
66 #define OW_CPY_SCR_CMD 0x48
|
|
67 #define OW_RECALL_CMD 0xb8
|
|
68 #define OW_RD_PSU_CMD 0xb4
|
|
69
|
|
70 /* DS2502 commands */
|
|
71 #define OW_READ_MEMORY 0xf0
|
|
72 #define OW_READ_STATUS 0xaa
|
|
73 #define OW_GEN_CRC 0xc3
|
|
74 #define OW_WRITE_MEMORY 0x0f
|
|
75 #define OW_WRITE_STATUS 0x55
|
|
76
|
|
77 /* Family codes */
|
|
78 #define OW_FAMILY_ROM 0x09
|
|
79 #define OW_FAMILY_TEMP 0x10
|
|
80
|
|
81 /* Return codes for OWGetTemp */
|
|
82 #define OW_TEMP_BADVAL -6000
|
|
83 #define OW_TEMP_WRONG_FAM -6001
|
|
84 #define OW_TEMP_CRC_ERR -6002
|
|
85 #define OW_TEMP_NO_ROM -6003
|
|
86
|
|
87 /* Helpers for OWGetTemp's number system */
|
|
88 #define GETWHOLE(x) ((x) / 100)
|
|
89 #define GETFRAC(x) abs((x) - (GETWHOLE(x) * 100))
|