1 /* $NetBSD: onewirereg.h,v 1.2 2006/04/08 23:41:46 riz Exp $ */
2 /* $OpenBSD: onewirereg.h,v 1.1 2006/03/04 16:27:03 grange Exp $ */
5 * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #ifndef _DEV_ONEWIRE_ONEWIREREG_H_
21 #define _DEV_ONEWIRE_ONEWIREREG_H_
24 * 1-Wire bus protocol definitions.
32 #define ONEWIRE_ROM_FAMILY(x) ((x) & 0xff)
33 #define ONEWIRE_ROM_FAMILY_TYPE(x) ((x) & 0x7f)
34 #define ONEWIRE_ROM_FAMILY_CUSTOM(x) (((x) >> 7) & 0x1)
37 #define ONEWIRE_ROM_SN(x) (((x) >> 8) & 0xffffffffffffULL)
40 #define ONEWIRE_ROM_CRC(x) (((x) >> 56) & 0xff)
47 #define ONEWIRE_CMD_READ_ROM 0x33
48 #define ONEWIRE_CMD_SKIP_ROM 0xcc
49 #define ONEWIRE_CMD_MATCH_ROM 0x55
50 #define ONEWIRE_CMD_SEARCH_ROM 0xf0
51 #define ONEWIRE_CMD_OVERDRIVE_SKIP_ROM 0x3c
52 #define ONEWIRE_CMD_OVERDRIVE_MATCH_ROM 0x69
54 /* Scratchpad commands */
55 #define ONEWIRE_CMD_READ_SCRATCHPAD 0xaa
56 #define ONEWIRE_CMD_WRITE_SCRATCHPAD 0x0f
57 #define ONEWIRE_CMD_COPY_SCRATCHPAD 0x55
60 #define ONEWIRE_CMD_READ_MEMORY 0xf0
61 #define ONEWIRE_CMD_WRITE_MEMORY 0x0f
62 #define ONEWIRE_CMD_EXT_READ_MEMORY 0xa5
64 /* Password commands */
65 #define ONEWIRE_CMD_READ_SUBKEY 0x66
66 #define ONEWIRE_CMD_WRITE_SUBKEY 0x99
67 #define ONEWIRE_CMD_WRITE_PASSWORD 0x5a
70 #define ONEWIRE_CMD_READ_STATUS 0xaa
71 #define ONEWIRE_CMD_WRITE_STATUS 0x55
73 #endif /* !_DEV_ONEWIRE_ONEWIREREG_H_ */