changeset 39:969bb070b181

- Remove superfluous debug message. - Remove unecessary indent.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 01 Apr 2013 19:45:38 +1030
parents 38869c474104
children a38003b97de6
files 1wire.c
diffstat 1 files changed, 38 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/1wire.c	Mon Apr 01 19:45:19 2013 +1030
+++ b/1wire.c	Mon Apr 01 19:45:38 2013 +1030
@@ -307,57 +307,54 @@
 	    OWPRINTFP(PSTR("bit_test = %d\r\n"), bit_test);
 
 	    /* check for no devices on 1-wire */
-	    if (bit_test == 3) {
-		OWPRINTFP(PSTR("bit_test = %d\r\n"), bit_test);
+	    if (bit_test == 3)
 		return(OW_BADWIRE);
-	    }
+
+	    /* all devices coupled have 0 or 1 */
+	    if (bit_test > 0)
+		search_direction = !(bit_test & 0x01);  /* bit write value for search */
 	    else {
-		/* all devices coupled have 0 or 1 */
-		if (bit_test > 0)
-		    search_direction = !(bit_test & 0x01);  /* bit write value for search */
-		else {
-		    /* if this discrepancy is before the Last Discrepancy
-		     * on a previous OWNext then pick the same as last time */
-		    if (bit_number < OW_LastDiscrepancy)
-			search_direction = ((ROM[rom_byte_number] & rom_byte_mask) > 0);
-		    else
-			/* if equal to last pick 1, if not then pick 0 */
-			search_direction = (bit_number == OW_LastDiscrepancy);
+		/* if this discrepancy is before the Last Discrepancy
+		 * on a previous OWNext then pick the same as last time */
+		if (bit_number < OW_LastDiscrepancy)
+		    search_direction = ((ROM[rom_byte_number] & rom_byte_mask) > 0);
+		else
+		    /* if equal to last pick 1, if not then pick 0 */
+		    search_direction = (bit_number == OW_LastDiscrepancy);
 
-		    /* if 0 was picked then record its position in LastZero */
-		    if (search_direction == 0) {
-			last_zero = bit_number;
+		/* if 0 was picked then record its position in LastZero */
+		if (search_direction == 0) {
+		    last_zero = bit_number;
 
-			/* check for Last discrepancy in family */
-			if (last_zero < 9)
-			    OW_LastFamilyDiscrepancy = last_zero;
-		    }
+		    /* check for Last discrepancy in family */
+		    if (last_zero < 9)
+			OW_LastFamilyDiscrepancy = last_zero;
 		}
+	    }
 
-		/* set or clear the bit in the ROM byte rom_byte_number
-		 * with mask rom_byte_mask */
-		if (search_direction == 1)
-		    ROM[rom_byte_number] |= rom_byte_mask;
-		else
-		    ROM[rom_byte_number] &= ~rom_byte_mask;
+	    /* set or clear the bit in the ROM byte rom_byte_number
+	     * with mask rom_byte_mask */
+	    if (search_direction == 1)
+		ROM[rom_byte_number] |= rom_byte_mask;
+	    else
+		ROM[rom_byte_number] &= ~rom_byte_mask;
 
-		/* serial number search direction write bit */
-		OWWriteBit(search_direction);
+	    /* serial number search direction write bit */
+	    OWWriteBit(search_direction);
 
-		/* increment the byte counter bit_number
-		 * and shift the mask rom_byte_mask */
-		bit_number++;
-		rom_byte_mask <<= 1;
+	    /* increment the byte counter bit_number
+	     * and shift the mask rom_byte_mask */
+	    bit_number++;
+	    rom_byte_mask <<= 1;
 
-		/* if the mask is 0 then go to new ROM byte rom_byte_number
-		 * and reset mask */
-		if (rom_byte_mask == 0) {
-		    OWCRC(ROM[rom_byte_number], &crcaccum);  /* accumulate the CRC */
-		    lastcrc8 = crcaccum;
+	    /* if the mask is 0 then go to new ROM byte rom_byte_number
+	     * and reset mask */
+	    if (rom_byte_mask == 0) {
+		OWCRC(ROM[rom_byte_number], &crcaccum);  /* accumulate the CRC */
+		lastcrc8 = crcaccum;
 		  
-		    rom_byte_number++;
-		    rom_byte_mask = 1;
-		}
+		rom_byte_number++;
+		rom_byte_mask = 1;
 	    }
 	} while (rom_byte_number < 8);  /* loop until through all ROM bytes 0-7 */