3.16. owi — One-Wire Interface

Source code: src/drivers/owi.h, src/drivers/owi.c

Test code: tst/drivers/owi/main.c


Defines

OWI_SEARCH_ROM 0xf0
OWI_READ_ROM 0x33
OWI_MATCH_ROM 0x55
OWI_SKIP_ROM 0xcc

Functions

int owi_init(struct owi_driver_t *self_p, struct pin_device_t *dev_p, struct owi_device_t *devices_p, size_t nmemb)

Initialize driver object.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to be initialized.
  • dev_p: Pin device to use.
  • devices_p: Storage for devices found when searching.
  • nmemb: Number of members in devices.

int owi_reset(struct owi_driver_t *self_p)

Send reset on one wire bus.

Return
true(1) if one or more devices are connected to the bus, false(0) if no devices were found, otherwise negative error code.
Parameters
  • self_p: Driver object.

int owi_search(struct owi_driver_t *self_p)

Search for devices on given one wire bus. The device id of all found devices are stored in the devices array passed to owi_init().

Return
Number of devices found or negative error code.
Parameters
  • self_p: Driver object.

ssize_t owi_read(struct owi_driver_t *self_p, void *buf_p, size_t size)

Read into buffer from one wire bus.

Return
Number of bits read or negative error code.
Parameters
  • self_p: Driver object.
  • buf_p: Buffer to read into.
  • size: Number of bits to read.

ssize_t owi_write(struct owi_driver_t *self_p, const void *buf_p, size_t size)

Write buffer to given one wire bus.

Return
Number of bits written or negative error code.
Parameters
  • self_p: Driver object.
  • buf_p: Buffer to write.
  • size: Number of bits to write.

struct owi_device_t

Public Members

uint8_t id[8]
struct owi_driver_t

Public Members

struct pin_driver_t pin
struct owi_device_t *devices_p
size_t nmemb
size_t len