#ifndef __ONE_WIRE_H
#define __ONE_WIRE_H

#include <stdint.h>

typedef enum {
    OW_OK,
    OW_ERROR
} onewire_ret_t;

typedef struct {
    onewire_ret_t (*delay_usec)(void *handle, uint32_t usec);
    onewire_ret_t (*drive_dq)(void *handle, uint8_t value);
    uint8_t       (*read_dq)(void *handle);
} onewire_cb_t;

typedef struct {
    void *user_data;
    onewire_cb_t cb;
} onewire_t;

uint8_t onewire_bus_reset(onewire_t *ow);
onewire_ret_t onewire_bus_write_byte(onewire_t *ow, uint8_t byte);
uint8_t onewire_bus_read_byte(onewire_t *ow);
onewire_ret_t onewire_bus_search_devices(onewire_t *ow);

#endif
