Support conditional search

This commit is contained in:
PaulStoffregen
2015-12-06 01:36:33 -08:00
parent 27a383b0b7
commit 6af633895c
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -344,7 +344,7 @@ void OneWire::target_search(uint8_t family_code)
// Return TRUE : device found, ROM number in ROM_NO buffer
// FALSE : device not found, end of search
//
uint8_t OneWire::search(uint8_t *newAddr)
uint8_t OneWire::search(uint8_t *newAddr, bool search_mode /* = true */)
{
uint8_t id_bit_number;
uint8_t last_zero, rom_byte_number, search_result;
@@ -373,7 +373,11 @@ uint8_t OneWire::search(uint8_t *newAddr)
}
// issue the search command
write(0xF0);
if (search_mode == true) {
write(0xF0); // NORMAL SEARCH
} else {
write(0xEC); // CONDITIONAL SEARCH
}
// loop to do the search
do
+1 -1
View File
@@ -210,7 +210,7 @@ class OneWire
// might be a good idea to check the CRC to make sure you didn't
// get garbage. The order is deterministic. You will always get
// the same devices in the same order.
uint8_t search(uint8_t *newAddr);
uint8_t search(uint8_t *newAddr, bool search_mode = true);
#endif
#if ONEWIRE_CRC