---
name: "struct_w1_bus_master"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/struct_w1_bus_master"
---

# struct\_w1\_bus\_master(9)

operations available on a bus master

## NAME

struct\_w1\_bus\_master - operations available on a bus master

## SYNOPSIS

```
struct w1_bus_master {
  void * data;
  u8 (* read_bit) (void *);
  void (* write_bit) (void *, u8);
  u8 (* touch_bit) (void *, u8);
  u8 (* read_byte) (void *);
  void (* write_byte) (void *, u8);
  u8 (* read_block) (void *, u8 *, int);
  void (* write_block) (void *, const u8 *, int);
  u8 (* triplet) (void *, u8);
  u8 (* reset_bus) (void *);
  u8 (* set_pullup) (void *, int);
  void (* search) (void *, struct w1_master *,u8, w1_slave_found_callback);
};
```

## MEMBERS

data

the first parameter in all the functions below

read\_bit

Sample the line level *return* the level read (0 or 1)

write\_bit

Sets the line level

touch\_bit

the lowest-level function for devices that really support the 1-wire protocol. touch\_bit(0) = write-0 cycle touch\_bit(1) = write-1 / read cycle *return* the bit read (0 or 1)

read\_byte

Reads a bytes. Same as 8 touch\_bit(1) calls. *return* the byte read

write\_byte

Writes a byte. Same as 8 touch\_bit(x) calls.

read\_block

Same as a series of **read\_byte** calls *return* the number of bytes read

write\_block

Same as a series of **write\_byte** calls

triplet

Combines two reads and a smart write for ROM searches *return* bit0=Id bit1=comp\_id bit2=dir\_taken

reset\_bus

long write-0 with a read for the presence pulse detection *return* -1=Error, 0=Device present, 1=No device present

set\_pullup

Put out a strong pull-up pulse of the specified duration. *return* -1=Error, 0=completed

search

Really nice hardware can handles the different types of ROM search w1\_master\* is passed to the slave found callback. u8 is search\_type, W1\_SEARCH or W1\_ALARM\_SEARCH

## NOTE

read\_bit and write\_bit are very low level functions and should only be used with hardware that doesn't really support 1-wire operations, like a parallel/serial port. Either define read\_bit and write\_bit OR define, at minimum, touch\_bit and reset\_bus.

## AUTHOR

**David Fries** \<David@Fries.net\>

Author.

## COPYRIGHT
