20 lines
727 B
C
20 lines
727 B
C
#include "ds18b20_ds2480.h"
|
|
|
|
/* board_port supplies the four callbacks documented in ds2480.h.
|
|
* Blocking example: includes bridge reset, scan and 750 ms conversion.
|
|
*/
|
|
ds2480_status ds18b20_example_read_first(const ds2480_port *board_port, int16_t *raw)
|
|
{
|
|
ds2480 bus;
|
|
ds2480_search search = {{0}, 0, 0};
|
|
ds2480_status status;
|
|
if (!raw) return DS2480_ARGUMENT;
|
|
status = ds2480_init(&bus, board_port, 20);
|
|
if (status != DS2480_OK) return status;
|
|
status = ds18b20_ds2480_next(&bus, &search);
|
|
if (status != DS2480_OK) return status;
|
|
status = ds18b20_ds2480_convert(&bus, search.rom);
|
|
if (status != DS2480_OK) return status;
|
|
return ds18b20_ds2480_temperature(&bus, search.rom, raw);
|
|
}
|