Library to communicate with Maxim OneWire protocol devices Modified timings and IRQ overrides
Fork of Onewire by
Diff: Onewire.cpp
- Revision:
- 4:b678c7c8203c
- Parent:
- 3:712bf8967b68
- Child:
- 5:45b6a39002f1
--- a/Onewire.cpp Sat Feb 21 17:54:33 2015 +0000 +++ b/Onewire.cpp Sat Feb 21 18:01:10 2015 +0000 @@ -66,7 +66,7 @@ { int result = 0; - for (int loop = 0; loop < 8; loop++) { + for (int loop = 0; loop < ONEWIRE_ADDR_BYTES; loop++) { // shift the result to get it ready for the next bit result >>= 1; @@ -80,7 +80,7 @@ void Onewire::writeByte(char data) { // Loop to write each bit in the byte, LS-bit first - for (int loop = 0; loop < 8; loop++) { + for (int loop = 0; loop < ONEWIRE_ADDR_BYTES; loop++) { writeBit(data & 0x01); // shift the data byte for the next bit @@ -95,7 +95,7 @@ for (i = 0; i < len; i++) { unsigned char inbyte = addr[i]; - for (j = 0; j < 8; j++) { + for (j = 0; j < ONEWIRE_ADDR_BYTES; j++) { unsigned char mix = (crc ^ inbyte) & 0x01; crc >>= 1; if (mix) crc ^= 0x8C; @@ -115,7 +115,7 @@ _search_LastDiscrepancy = 0; _search_LastDeviceFlag = false; _search_LastFamilyDiscrepancy = 0; - for(int i = 7; i >= 0; i--) + for(int i = ONEWIRE_ADDR_BYTES-1; i >= 0; i--) _search_ROM_NO[i] = 0; } @@ -220,7 +220,7 @@ } } } - while(rom_byte_number < 8); // loop until through all ROM bytes 0-7 + while(rom_byte_number < ONEWIRE_ADDR_BYTES); // loop until through all ROM bytes 0-7 // if the search was successful then if (!(id_bit_number < 65)) @@ -244,7 +244,7 @@ _search_LastFamilyDiscrepancy = 0; search_result = false; } - for (int i = 0; i < 8; i++) + for (int i = 0; i < ONEWIRE_ADDR_BYTES; i++) newAddr[i] = _search_ROM_NO[i]; return search_result; }