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