Home | History | Annotate | Line # | Download | only in onewire
onewirevar.h revision 1.3.2.2
      1  1.3.2.2  elad /* $NetBSD: onewirevar.h,v 1.3.2.2 2006/04/19 03:25:33 elad Exp $ */
      2  1.3.2.2  elad /*	$OpenBSD: onewirevar.h,v 1.1 2006/03/04 16:27:03 grange Exp $	*/
      3  1.3.2.2  elad 
      4  1.3.2.2  elad /*
      5  1.3.2.2  elad  * Copyright (c) 2006 Alexander Yurchenko <grange (at) openbsd.org>
      6  1.3.2.2  elad  *
      7  1.3.2.2  elad  * Permission to use, copy, modify, and distribute this software for any
      8  1.3.2.2  elad  * purpose with or without fee is hereby granted, provided that the above
      9  1.3.2.2  elad  * copyright notice and this permission notice appear in all copies.
     10  1.3.2.2  elad  *
     11  1.3.2.2  elad  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12  1.3.2.2  elad  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13  1.3.2.2  elad  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14  1.3.2.2  elad  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15  1.3.2.2  elad  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16  1.3.2.2  elad  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17  1.3.2.2  elad  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18  1.3.2.2  elad  */
     19  1.3.2.2  elad 
     20  1.3.2.2  elad #ifndef _DEV_ONEWIRE_ONEWIREVAR_H_
     21  1.3.2.2  elad #define _DEV_ONEWIRE_ONEWIREVAR_H_
     22  1.3.2.2  elad 
     23  1.3.2.2  elad /*
     24  1.3.2.2  elad  * 1-Wire bus interface.
     25  1.3.2.2  elad  */
     26  1.3.2.2  elad 
     27  1.3.2.2  elad /* Bus master interface */
     28  1.3.2.2  elad struct onewire_bus {
     29  1.3.2.2  elad 	void *	bus_cookie;
     30  1.3.2.2  elad 
     31  1.3.2.2  elad 	int	(*bus_reset)(void *);
     32  1.3.2.2  elad 	int	(*bus_bit)(void *, int);
     33  1.3.2.2  elad 	int	(*bus_read_byte)(void *);
     34  1.3.2.2  elad 	void	(*bus_write_byte)(void *, int);
     35  1.3.2.2  elad 	int	(*bus_triplet)(void *, int);
     36  1.3.2.2  elad };
     37  1.3.2.2  elad 
     38  1.3.2.2  elad /* Bus methods */
     39  1.3.2.2  elad int		onewire_lock(void *, int);
     40  1.3.2.2  elad void		onewire_unlock(void *);
     41  1.3.2.2  elad int		onewire_reset(void *);
     42  1.3.2.2  elad int		onewire_bit(void *, int);
     43  1.3.2.2  elad int		onewire_read_byte(void *);
     44  1.3.2.2  elad void		onewire_write_byte(void *, int);
     45  1.3.2.2  elad int		onewire_triplet(void *, int);
     46  1.3.2.2  elad void		onewire_read_block(void *, void *, int);
     47  1.3.2.2  elad void		onewire_write_block(void *, const void *, int);
     48  1.3.2.2  elad void		onewire_matchrom(void *, u_int64_t);
     49  1.3.2.2  elad 
     50  1.3.2.2  elad #define ONEWIRE_NOWAIT		0x0001
     51  1.3.2.2  elad 
     52  1.3.2.2  elad /* Bus attachment */
     53  1.3.2.2  elad struct onewirebus_attach_args {
     54  1.3.2.2  elad 	struct onewire_bus *	oba_bus;
     55  1.3.2.2  elad };
     56  1.3.2.2  elad 
     57  1.3.2.2  elad int	onewirebus_print(void *, const char *);
     58  1.3.2.2  elad 
     59  1.3.2.2  elad /* Device attachment */
     60  1.3.2.2  elad struct onewire_attach_args {
     61  1.3.2.2  elad 	void *			oa_onewire;
     62  1.3.2.2  elad 	u_int64_t		oa_rom;
     63  1.3.2.2  elad };
     64  1.3.2.2  elad 
     65  1.3.2.2  elad /* Family matching */
     66  1.3.2.2  elad struct onewire_matchfam {
     67  1.3.2.2  elad 	int om_type;
     68  1.3.2.2  elad };
     69  1.3.2.2  elad 
     70  1.3.2.2  elad /* Miscellaneous routines */
     71  1.3.2.2  elad int		onewire_crc(const void *, int);
     72  1.3.2.2  elad const char *	onewire_famname(int);
     73  1.3.2.2  elad int		onewire_matchbyfam(struct onewire_attach_args *,
     74  1.3.2.2  elad 		    const struct onewire_matchfam *, int);
     75  1.3.2.2  elad 
     76  1.3.2.2  elad /* Bus bit-banging */
     77  1.3.2.2  elad struct onewire_bbops {
     78  1.3.2.2  elad 	void	(*bb_rx)(void *);
     79  1.3.2.2  elad 	void	(*bb_tx)(void *);
     80  1.3.2.2  elad 	int	(*bb_get)(void *);
     81  1.3.2.2  elad 	void	(*bb_set)(void *, int);
     82  1.3.2.2  elad };
     83  1.3.2.2  elad 
     84  1.3.2.2  elad int		onewire_bb_reset(const struct onewire_bbops *, void *);
     85  1.3.2.2  elad int		onewire_bb_bit(const struct onewire_bbops *, void *, int);
     86  1.3.2.2  elad 
     87  1.3.2.2  elad #endif	/* !_DEV_ONEWIRE_ONEWIREVAR_H_ */
     88