mirror of
https://github.com/PaulStoffregen/OneWire.git
synced 2026-07-27 19:57:07 +00:00
Support conditional search
This commit is contained in:
+6
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user