37 #ifndef ONE_WIRE_BUS_H
38 #define ONE_WIRE_BUS_H
43 #include "driver/gpio.h"
51 #define OWB_ROM_SEARCH 0xF0
52 #define OWB_ROM_READ 0x33
53 #define OWB_ROM_MATCH 0x55
54 #define OWB_ROM_SKIP 0xCC
55 #define OWB_ROM_SEARCH_ALARM 0xEC
57 #define OWB_ROM_CODE_STRING_LENGTH (17)
60 # define GPIO_NUM_NC (-1)
70 const struct _OneWireBus_Timing *
timing;
88 uint8_t serial_number[6];
145 #define container_of(ptr, type, member) ({ \
146 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
147 (type *)( (char *)__mptr - offsetof(type,member) );})
285 uint8_t
owb_crc8_bytes(uint8_t crc,
const uint8_t * data,
size_t len);
336 #endif // ONE_WIRE_BUS_H
uint8_t owb_crc8_byte(uint8_t crc, uint8_t data)
1-Wire 8-bit CRC lookup.
Definition: owb.c:648
owb_status owb_search_next(const OneWireBus *bus, OneWireBus_SearchState *state, bool *found_device)
Locates the next device on the 1-Wire bus, if present, starting from the provided state...
Definition: owb.c:686
owb_status owb_read_bytes(const OneWireBus *bus, uint8_t *buffer, unsigned int len)
Read a number of bytes from the 1-Wire bus.
Definition: owb.c:525
owb_status owb_search_first(const OneWireBus *bus, OneWireBus_SearchState *state, bool *found_device)
Locates the first device on the 1-Wire bus, if present.
Definition: owb.c:658
A hardware error occurred.
Definition: owb.h:122
owb_status owb_write_byte(const OneWireBus *bus, uint8_t data)
Write a single byte to the 1-Wire bus.
Definition: owb.c:577
int last_family_discrepancy
Bit index that identifies the last discrepancy within the first 8-bit family code of the ROM code...
Definition: owb.h:106
Interface definitions for ESP32 RMT driver used to communicate with devices on the One Wire Bus...
owb_status owb_set_strong_pullup(const OneWireBus *bus, bool enable)
Enable or disable the strong-pullup GPIO, if configured.
Definition: owb.c:720
int last_device_flag
Flag to indicate previous search was the last device detected.
Definition: owb.h:107
owb_status owb_read_byte(const OneWireBus *bus, uint8_t *out)
Read a single byte from the 1-Wire bus.
Definition: owb.c:503
owb_status(* write_bits)(const OneWireBus *bus, uint8_t out, int number_of_bits_to_write)
Definition: owb.h:138
owb_status owb_write_bytes(const OneWireBus *bus, const uint8_t *buffer, size_t len)
Write a number of bytes to the 1-Wire bus.
Definition: owb.c:599
owb_status owb_write_bit(const OneWireBus *bus, uint8_t bit)
Write a bit to the 1-Wire bus.
Definition: owb.c:555
gpio_num_t strong_pullup_gpio
Set if an external strong pull-up circuit is required.
Definition: owb.h:73
A status value has not been set.
Definition: owb.h:115
owb_status owb_read_rom(const OneWireBus *bus, OneWireBus_ROMCode *rom_code)
Read ROM code from device - only works when there is a single device on the bus.
Definition: owb.c:362
Attempt to write an incorrect number of bits to the One Wire Bus.
Definition: owb.h:121
const struct _OneWireBus_Timing * timing
Pointer to timing information.
Definition: owb.h:70
Provides access via field names.
Definition: owb.h:85
const struct owb_driver * driver
Pointer to hardware driver instance.
Definition: owb.h:74
owb_status(* reset)(const OneWireBus *bus, bool *is_present)
Definition: owb.h:135
char * owb_string_from_rom_code(OneWireBus_ROMCode rom_code, char *buffer, size_t len)
Create a string representation of a ROM code, most significant byte (CRC8) first. ...
Definition: owb.c:710
Structure containing 1-Wire bus information relevant to a single instance.
Definition: owb.h:68
int last_discrepancy
Bit index that identifies from which bit the next search discrepancy check should start...
Definition: owb.h:105
bool use_crc
True if CRC checks are to be used when retrieving information from a device on the bus...
Definition: owb.h:71
OneWireBus_ROMCode rom_code
Device ROM code.
Definition: owb.h:104
owb_status owb_use_crc(OneWireBus *bus, bool use_crc)
Enable or disable use of CRC checks on device communications.
Definition: owb.c:279
owb_status
Represents the result of OWB API functions.
Definition: owb.h:113
Represents the state of a device search on the 1-Wire bus.
Definition: owb.h:102
Represents a 1-Wire ROM Code. This is a sequence of eight bytes, where the first byte is the family n...
Definition: owb.h:82
Operation succeeded.
Definition: owb.h:116
uint8_t owb_crc8_bytes(uint8_t crc, const uint8_t *data, size_t len)
1-Wire 8-bit CRC lookup with accumulation over a block of bytes.
Definition: owb.c:653
owb_status owb_uninitialize(OneWireBus *bus)
call to release resources after completing use of the OneWireBus
Definition: owb.c:262
owb_status owb_use_parasitic_power(OneWireBus *bus, bool use_parasitic_power)
Enable or disable use of parasitic power on the One Wire Bus. This affects how devices signal on the ...
Definition: owb.c:302
owb_status owb_verify_rom(const OneWireBus *bus, OneWireBus_ROMCode rom_code, bool *is_present)
Verify the device specified by ROM code is present.
Definition: owb.c:417
CRC failed on data received from a device or devices.
Definition: owb.h:120
Function was passed an uninitialised variable.
Definition: owb.h:117
owb_status(* read_bits)(const OneWireBus *bus, uint8_t *in, int number_of_bits_to_read)
Definition: owb.h:141
No response received from the addressed device or devices.
Definition: owb.h:119
Interface definitions for the ESP32 GPIO driver used to communicate with devices on the One Wire Bus...
owb_status owb_use_strong_pullup_gpio(OneWireBus *bus, gpio_num_t gpio)
Enable or disable use of extra GPIO to activate strong pull-up circuit. This only has effect if paras...
Definition: owb.c:325
const char * name
Definition: owb.h:129
owb_status owb_reset(const OneWireBus *bus, bool *is_present)
Reset the 1-Wire bus.
Definition: owb.c:461
owb_status(* uninitialize)(const OneWireBus *bus)
Definition: owb.h:132
bool use_parasitic_power
True if parasitic-powered devices are expected on the bus.
Definition: owb.h:72
owb_status owb_write_rom_code(const OneWireBus *bus, OneWireBus_ROMCode rom_code)
Write a ROM code to the 1-Wire bus ensuring LSB is sent first.
Definition: owb.c:627
owb_status owb_read_bit(const OneWireBus *bus, uint8_t *out)
Read a single bit from the 1-Wire bus.
Definition: owb.c:481
Function was passed a null pointer.
Definition: owb.h:118