10 #define TWR_ONEWIRE_DEVICE_NUMBER_SKIP_ROM 0
20 bool (*init)(
void *ctx);
21 bool (*enable)(
void *ctx);
22 bool (*disable)(
void *ctx);
23 bool (*reset)(
void *ctx);
24 void (*write_bit)(
void *ctx, uint8_t bit);
25 uint8_t (*read_bit)(
void *ctx);
26 void (*write_byte)(
void *ctx, uint8_t byte);
27 uint8_t (*read_byte)(
void *ctx);
28 bool (*search_next)(
void *ctx,
twr_onewire_t *onewire, uint64_t *device_number);
30 } twr_onewire_driver_t;
34 uint8_t _last_discrepancy;
35 uint8_t _last_family_discrepancy;
36 bool _last_device_flag;
37 uint8_t _last_rom_no[8];
41 const twr_onewire_driver_t *_driver;
42 bool _auto_ds28e17_sleep_mode;
twr_gpio_channel_t
GPIO channels.
void twr_onewire_write(twr_onewire_t *self, const void *buffer, size_t length)
Select device.
void twr_onewire_write_byte(twr_onewire_t *self, uint8_t data)
Select device.
void twr_onewire_search_start(twr_onewire_t *self, uint8_t family_code)
Start of manual search, see also twr_onewire_search_next.
struct twr_onewire_t twr_onewire_t
1-Wire instance
void twr_onewire_skip_rom(twr_onewire_t *self)
Skip ROM.
bool twr_onewire_is_transaction(twr_onewire_t *self)
Is transaction run.
bool twr_onewire_transaction_start(twr_onewire_t *self)
Start transaction, enable pll and run timer.
bool twr_onewire_reset(twr_onewire_t *self)
Reset the 1-Wire bus and return the presence of any device.
int twr_onewire_search_all(twr_onewire_t *self, uint64_t *device_list, size_t device_list_size)
Search for all devices on 1-Wire.
bool twr_onewire_init(twr_onewire_t *self, const twr_onewire_driver_t *driver, void *driver_ctx)
Initialize 1-Wire.
int twr_onewire_search_family(twr_onewire_t *self, uint8_t family_code, uint64_t *device_list, size_t device_list_size)
Search for all devices on 1-Wire with family code.
void twr_onewire_read(twr_onewire_t *self, void *buffer, size_t length)
Select device.
uint8_t twr_onewire_crc8(const void *buffer, size_t length, uint8_t crc)
Calculate 8-bit CRC.
void twr_onewire_select(twr_onewire_t *self, uint64_t *device_number)
Select device.
uint8_t twr_onewire_read_byte(twr_onewire_t *self)
Select device.
uint16_t twr_onewire_crc16(const void *buffer, size_t length, uint16_t crc)
Calculate 16-bit CRC, polynomial 0x8005.
int twr_onewire_read_bit(twr_onewire_t *self)
Select device.
bool twr_onewire_transaction_stop(twr_onewire_t *self)
Stop transaction.
void twr_onewire_write_bit(twr_onewire_t *self, int bit)
Select device.
void twr_onewire_auto_ds28e17_sleep_mode(twr_onewire_t *self, bool on)
Enable call sleep mode for all ds28e17 after transaction.
bool twr_onewire_search_next(twr_onewire_t *self, uint64_t *device_number)
Manual search of next device.