'\" t .\" Title: w1_search .\" Author: .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: June 2017 .\" Manual: W1 API internal to the kernel .\" Source: Kernel Hackers Manual 4.11.3 .\" Language: English .\" .TH "W1_SEARCH" "9" "June 2017" "Kernel Hackers Manual 4\&.11\&" "W1 API internal to the kernel" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" w1_search \- Performs a ROM Search & registers any devices found\&. .SH "SYNOPSIS" .HP \w'void\ w1_search('u .BI "void w1_search(struct\ w1_master\ *\ " "dev" ", u8\ " "search_type" ", w1_slave_found_callback\ " "cb" ");" .SH "ARGUMENTS" .PP \fIstruct w1_master * dev\fR .RS 4 The master device to search .RE .PP \fIu8 search_type\fR .RS 4 W1_SEARCH to search all devices, or W1_ALARM_SEARCH to return only devices in the alarmed state .RE .PP \fIw1_slave_found_callback cb\fR .RS 4 Function to call when a device is found .RE .SH "DESCRIPTION" .PP The 1\-wire search is a simple binary tree search\&. For each bit of the address, we read two bits and write one bit\&. The bit written will put to sleep all devies that don\*(Aqt match that bit\&. When the two reads differ, the direction choice is obvious\&. When both bits are 0, we must choose a path to take\&. When we can scan all 64 bits without having to choose a path, we are done\&. .PP See \(lqApplication note 187 1\-wire search algorithm\(rq at www\&.maxim\-ic\&.com .SH "AUTHOR" .PP \fBDavid Fries\fR <\&David@Fries.net\&> .RS 4 Author. .RE .SH "COPYRIGHT" .br