annotate 1wire.h @ 0:ffeab3c04e83

Initial revision
author darius
date Sun, 11 Jul 2004 00:45:50 +0930
parents
children f9a085a0ba93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
1 /* Copyright (c) 2004
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
2 * Daniel O'Connor <darius@dons.net.au>. All rights reserved.
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
3 *
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
4 * Redistribution and use in source and binary forms, with or without
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
5 * modification, are permitted provided that the following conditions
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
6 * are met:
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
7 * 1. Redistributions of source code must retain the above copyright
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
8 * notice, this list of conditions and the following disclaimer.
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
9 * 2. Redistributions in binary form must reproduce the above copyright
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer in the
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
11 * documentation and/or other materials provided with the distribution.
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
12 *
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
23 * SUCH DAMAGE.
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
24 */
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
25
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
26 int OWTouchReset(void);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
27 void OWWriteBit(int bit);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
28 int OWReadBit(void);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
29 void OWWriteByte(uint8_t data);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
30 int OWReadByte(void);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
31 int OWTouchByte(uint8_t data);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
32 void OWBlock(uint8_t *data, int len);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
33 int OWFirst(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
34 int OWNext(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
35 void OWCRC(uint8_t x, uint8_t *crc);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
36 void OWSendCmd(uint8_t *ROM, uint8_t cmd);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
37
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
38 #define OWIREOUTPORT PORTC
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
39 #define OWIREOUTPIN 0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
40
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
41 #define OWIREINPORT PINC
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
42 #define OWIREDDR DDRC
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
43 #define OWIREINPIN OWIREOUTPIN
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
44
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
45 /* General 1 wire commands */
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
46 #define OW_OVRDRV_SKIP_CMD 0x3c
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
47 #define OW_SEARCH_ALRM_CMD 0xec
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
48 #define OW_SEARCH_ROM_CMD 0xf0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
49 #define OW_READ_ROM_CMD 0x33
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
50 #define OW_MATCH_ROM_CMD 0x55
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
51 #define OW_SKIP_ROM_CMD 0xcc
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
52
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
53 /* DS1820 commands */
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
54 #define OW_CONVERTT_CMD 0x44
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
55 #define OW_RD_SCR_CMD 0xbe
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
56 #define OW_WR_SCR_CMD 0x4e
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
57 #define OW_CPY_SCR_CMD 0x48
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
58 #define OW_RECALL_CMD 0xb8
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
59 #define OW_RD_PSU_CMD 0xb4
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
60
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
61 /* Family codes */
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
62 #define OW_FAMILY_ROM 0x09
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
63 #define OW_FAMILY_TEMP 0x10