Browse Source

1-wire: stop search when not slave is detected, and mention that code 0 means the data line might not be pulled up

spark_strober
King Kévin 4 years ago
parent
commit
b02e9b172e
  1. 1
      lib/onewire_master.c
  2. 1
      lib/onewire_master.h

1
lib/onewire_master.c

@ -343,6 +343,7 @@ bool onewire_master_rom_search(uint64_t* code, bool alarm) @@ -343,6 +343,7 @@ bool onewire_master_rom_search(uint64_t* code, bool alarm)
*code &= ~(((uint64_t)1)<<bit); // remember valid bit 0
break;
default: // two 1's indicate there is no slave
conflict_current = 64; // remember there was no conflict because there is no slave
goto end; // an error has occurred
}
buffer_size = 1; // to send next bit

1
lib/onewire_master.h

@ -57,6 +57,7 @@ uint64_t onewire_master_rom_read(void); @@ -57,6 +57,7 @@ uint64_t onewire_master_rom_read(void);
* @param[in,out] code use 0 to start search ROM code from scratch, or last know value to search next; writes back next ROM code found, or 0 if error occurred
* @param[in] alarm search only for ROM codes for slaves with an alarm flag set
* @return if an additional slave has been detected
* @warning when the code found is 0 it very probably means that the 1-wire line is not pulled up instead of actually having found a slave with ROM code 0
*/
bool onewire_master_rom_search(uint64_t* code, bool alarm);
/** send SKIP ROM command (all slaves on the bus will be selected)

Loading…
Cancel
Save