Home | History | Annotate | Line # | Download | only in onewire
onewirereg.h revision 1.1
      1 /*	$OpenBSD: onewirereg.h,v 1.1 2006/03/04 16:27:03 grange Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2006 Alexander Yurchenko <grange (at) openbsd.org>
      5  *
      6  * Permission to use, copy, modify, and distribute this software for any
      7  * purpose with or without fee is hereby granted, provided that the above
      8  * copyright notice and this permission notice appear in all copies.
      9  *
     10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     17  */
     18 
     19 #ifndef _DEV_ONEWIRE_ONEWIREREG_H_
     20 #define _DEV_ONEWIRE_ONEWIREREG_H_
     21 
     22 /*
     23  * 1-Wire bus protocol definitions.
     24  */
     25 
     26 /*
     27  * 64-bit ROM section.
     28  */
     29 
     30 /* Family code */
     31 #define ONEWIRE_ROM_FAMILY(x)		((x) & 0xff)
     32 #define ONEWIRE_ROM_FAMILY_TYPE(x)	((x) & 0x7f)
     33 #define ONEWIRE_ROM_FAMILY_CUSTOM(x)	(((x) >> 7) & 0x1)
     34 
     35 /* Serial number */
     36 #define ONEWIRE_ROM_SN(x)		(((x) >> 8) & 0xffffffffffffULL)
     37 
     38 /* CRC */
     39 #define ONEWIRE_ROM_CRC(x)		(((x) >> 56) & 0xff)
     40 
     41 /*
     42  * Command set.
     43  */
     44 
     45 /* ROM commands */
     46 #define ONEWIRE_CMD_READ_ROM		0x33
     47 #define ONEWIRE_CMD_SKIP_ROM		0xcc
     48 #define ONEWIRE_CMD_MATCH_ROM		0x55
     49 #define ONEWIRE_CMD_SEARCH_ROM		0xf0
     50 #define ONEWIRE_CMD_OVERDRIVE_SKIP_ROM	0x3c
     51 #define ONEWIRE_CMD_OVERDRIVE_MATCH_ROM	0x69
     52 
     53 /* Scratchpad commands */
     54 #define ONEWIRE_CMD_READ_SCRATCHPAD	0xaa
     55 #define ONEWIRE_CMD_WRITE_SCRATCHPAD	0x0f
     56 #define ONEWIRE_CMD_COPY_SCRATCHPAD	0x55
     57 
     58 /* Memory commands */
     59 #define ONEWIRE_CMD_READ_MEMORY		0xf0
     60 #define ONEWIRE_CMD_WRITE_MEMORY	0x0f
     61 #define ONEWIRE_CMD_EXT_READ_MEMORY	0xa5
     62 
     63 /* Password commands */
     64 #define ONEWIRE_CMD_READ_SUBKEY		0x66
     65 #define ONEWIRE_CMD_WRITE_SUBKEY	0x99
     66 #define ONEWIRE_CMD_WRITE_PASSWORD	0x5a
     67 
     68 /* Status commands */
     69 #define ONEWIRE_CMD_READ_STATUS		0xaa
     70 #define ONEWIRE_CMD_WRITE_STATUS	0x55
     71 
     72 #endif	/* !_DEV_ONEWIRE_ONEWIREREG_H_ */
     73