annotate 1wire.h @ 27:d5a265299a4b

Test programs to talk to the hardware from a PC
author darius
date Mon, 10 Apr 2006 17:22:17 +0930
parents 2b0ed085b95b
children b0cb873c0206
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
f9a085a0ba93 Change the 1 wire routines to mostly C with assembly delay routines
darius
parents: 0
diff changeset
1 /*
f9a085a0ba93 Change the 1 wire routines to mostly C with assembly delay routines
darius
parents: 0
diff changeset
2 * 1 wire header code
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
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
7 * Daniel O'Connor <darius@dons.net.au>. All rights reserved.
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
8 *
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
9 * Redistribution and use in source and binary forms, with or without
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
10 * modification, are permitted provided that the following conditions
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
11 * are met:
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
12 * 1. Redistributions of source code must retain the above copyright
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer.
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
14 * 2. Redistributions in binary form must reproduce the above copyright
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
15 * notice, this list of conditions and the following disclaimer in the
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
16 * documentation and/or other materials provided with the distribution.
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
17 *
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
18 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
21 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
28 * SUCH DAMAGE.
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
29 */
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
30
12
4b141cc7cbd4 - Reduce type widths where possible.
darius
parents: 10
diff changeset
31 uint8_t OWTouchReset(void);
4b141cc7cbd4 - Reduce type widths where possible.
darius
parents: 10
diff changeset
32 void OWWriteBit(uint8_t bit);
4b141cc7cbd4 - Reduce type widths where possible.
darius
parents: 10
diff changeset
33 uint8_t OWReadBit(void);
0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
34 void OWWriteByte(uint8_t data);
12
4b141cc7cbd4 - Reduce type widths where possible.
darius
parents: 10
diff changeset
35 uint8_t OWReadByte(void);
4b141cc7cbd4 - Reduce type widths where possible.
darius
parents: 10
diff changeset
36 uint8_t OWTouchByte(uint8_t data);
0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
37 void OWBlock(uint8_t *data, int len);
12
4b141cc7cbd4 - Reduce type widths where possible.
darius
parents: 10
diff changeset
38 uint8_t OWFirst(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only);
4b141cc7cbd4 - Reduce type widths where possible.
darius
parents: 10
diff changeset
39 uint8_t OWNext(uint8_t *ROM, uint8_t do_reset, uint8_t alarm_only);
0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
40 void OWCRC(uint8_t x, uint8_t *crc);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
41 void OWSendCmd(uint8_t *ROM, uint8_t cmd);
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
42
24
2b0ed085b95b - Change to 38400 baud.
darius
parents: 12
diff changeset
43 #define OWIREOUTPORT PORTD
2b0ed085b95b - Change to 38400 baud.
darius
parents: 12
diff changeset
44 #define OWIREOUTPIN 2
0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
45
24
2b0ed085b95b - Change to 38400 baud.
darius
parents: 12
diff changeset
46 #define OWIREINPORT PIND
2b0ed085b95b - Change to 38400 baud.
darius
parents: 12
diff changeset
47 #define OWIREDDR DDRD
0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
48 #define OWIREINPIN OWIREOUTPIN
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
49
10
eb1faf51968e - Add some useful return values to search functions.
darius
parents: 8
diff changeset
50 /* Return codes for OWFirst()/OWNext() */
eb1faf51968e - Add some useful return values to search functions.
darius
parents: 8
diff changeset
51 #define OW_BADWIRE -3
eb1faf51968e - Add some useful return values to search functions.
darius
parents: 8
diff changeset
52 #define OW_BADCRC -2
eb1faf51968e - Add some useful return values to search functions.
darius
parents: 8
diff changeset
53 #define OW_NOPRESENCE -1
eb1faf51968e - Add some useful return values to search functions.
darius
parents: 8
diff changeset
54 #define OW_NOMODULES 0
eb1faf51968e - Add some useful return values to search functions.
darius
parents: 8
diff changeset
55 #define OW_FOUND 1
eb1faf51968e - Add some useful return values to search functions.
darius
parents: 8
diff changeset
56
0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
57 /* General 1 wire commands */
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
58 #define OW_OVRDRV_SKIP_CMD 0x3c
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
59 #define OW_SEARCH_ALRM_CMD 0xec
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
60 #define OW_SEARCH_ROM_CMD 0xf0
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
61 #define OW_READ_ROM_CMD 0x33
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
62 #define OW_MATCH_ROM_CMD 0x55
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
63 #define OW_SKIP_ROM_CMD 0xcc
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
64
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
65 /* DS1820 commands */
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
66 #define OW_CONVERTT_CMD 0x44
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
67 #define OW_RD_SCR_CMD 0xbe
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
68 #define OW_WR_SCR_CMD 0x4e
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
69 #define OW_CPY_SCR_CMD 0x48
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
70 #define OW_RECALL_CMD 0xb8
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
71 #define OW_RD_PSU_CMD 0xb4
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
72
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
73 /* Family codes */
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
74 #define OW_FAMILY_ROM 0x09
ffeab3c04e83 Initial revision
darius
parents:
diff changeset
75 #define OW_FAMILY_TEMP 0x10