sensor_ds18b20: fix set precision for single device

This commit is contained in:
King Kévin 2020-12-07 19:07:56 +01:00
parent 58ef5f3d1b
commit c085f2d292
2 changed files with 9 additions and 3 deletions

View File

@ -109,8 +109,14 @@ float sensor_ds18b20_temperature(uint64_t code)
}
// send ROM command to select slave
if (!onewire_master_rom_match(code)) { // select specific slave
return NAN; // ROM command failed
if (0 == code) { // broadcast convert
if (!onewire_master_rom_skip()) { // select all slaves
return false; // ROM command failed
}
} else {
if (!onewire_master_rom_match(code)) { // select specific slave
return false; // ROM command failed
}
}
// read scratchpad to get temperature (on byte 0 and 1)

View File

@ -36,7 +36,7 @@ bool sensor_ds18b20_convert(uint64_t code);
*/
float sensor_ds18b20_temperature(uint64_t code);
/** set conversion precision
* @param[in] code ROM code of sensor to start conversion on (0 for all, if only DS18B20 sensors are on the bus)
* @param[in] code ROM code of sensor to start conversion on (0 for single DS18B20 sensor are on the bus)
* @param[in] precision precision in bits (9-12)
* @return if operation succeeded
*/