feat(ds18b20-ds2480): добавь драйвер датчиков через UART-мост
This commit is contained in:
19
c/ds18b20-ds2480/examples/read_first.c
Normal file
19
c/ds18b20-ds2480/examples/read_first.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user