esp32-warm-water
esp32 based project for the control of a heating element based on temperature
|
Interface definitions for the 1-Wire bus component. More...
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "driver/gpio.h"
#include "owb_gpio.h"
#include "owb_rmt.h"
Go to the source code of this file.
Data Structures | |
struct | OneWireBus |
Structure containing 1-Wire bus information relevant to a single instance. More... | |
union | OneWireBus_ROMCode |
Represents a 1-Wire ROM Code. This is a sequence of eight bytes, where the first byte is the family number, then the following 6 bytes form the serial number. The final byte is the CRC8 check byte. More... | |
struct | OneWireBus_ROMCode::fields |
Provides access via field names. More... | |
struct | OneWireBus_SearchState |
Represents the state of a device search on the 1-Wire bus. More... | |
struct | owb_driver |
Macros | |
#define | OWB_ROM_SEARCH 0xF0 |
Perform Search ROM cycle to identify devices on the bus. More... | |
#define | OWB_ROM_READ 0x33 |
Read device ROM (single device on bus only) More... | |
#define | OWB_ROM_MATCH 0x55 |
Address a specific device on the bus by ROM. More... | |
#define | OWB_ROM_SKIP 0xCC |
Address all devices on the bus simultaneously. More... | |
#define | OWB_ROM_SEARCH_ALARM 0xEC |
Address all devices on the bus with a set alarm flag. More... | |
#define | OWB_ROM_CODE_STRING_LENGTH (17) |
Typical length of OneWire bus ROM ID as ASCII hex string, including null terminator. More... | |
#define | GPIO_NUM_NC (-1) |
ESP-IDF prior to v4.x does not define GPIO_NUM_NC. More... | |
Enumerations | |
enum | owb_status { OWB_STATUS_NOT_SET = -1 , OWB_STATUS_OK = 0 , OWB_STATUS_NOT_INITIALIZED , OWB_STATUS_PARAMETER_NULL , OWB_STATUS_DEVICE_NOT_RESPONDING , OWB_STATUS_CRC_FAILED , OWB_STATUS_TOO_MANY_BITS , OWB_STATUS_HW_ERROR } |
Represents the result of OWB API functions. More... | |
Functions | |
owb_status | owb_uninitialize (OneWireBus *bus) |
call to release resources after completing use of the OneWireBus More... | |
owb_status | owb_use_crc (OneWireBus *bus, bool use_crc) |
Enable or disable use of CRC checks on device communications. More... | |
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 bus, as devices cannot signal by pulling the bus low when it is pulled high. More... | |
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 parasitic power mode is enabled. signal by pulling the bus low when it is pulled high. More... | |
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. More... | |
owb_status | owb_verify_rom (const OneWireBus *bus, OneWireBus_ROMCode rom_code, bool *is_present) |
Verify the device specified by ROM code is present. More... | |
owb_status | owb_reset (const OneWireBus *bus, bool *is_present) |
Reset the 1-Wire bus. More... | |
owb_status | owb_read_bit (const OneWireBus *bus, uint8_t *out) |
Read a single bit from the 1-Wire bus. More... | |
owb_status | owb_read_byte (const OneWireBus *bus, uint8_t *out) |
Read a single byte from the 1-Wire bus. More... | |
owb_status | owb_read_bytes (const OneWireBus *bus, uint8_t *buffer, unsigned int len) |
Read a number of bytes from the 1-Wire bus. More... | |
owb_status | owb_write_bit (const OneWireBus *bus, uint8_t bit) |
Write a bit to the 1-Wire bus. More... | |
owb_status | owb_write_byte (const OneWireBus *bus, uint8_t data) |
Write a single byte to the 1-Wire bus. More... | |
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. More... | |
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. More... | |
uint8_t | owb_crc8_byte (uint8_t crc, uint8_t data) |
1-Wire 8-bit CRC lookup. More... | |
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. More... | |
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. More... | |
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. Further calls will yield additional devices, if present. More... | |
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. More... | |
owb_status | owb_set_strong_pullup (const OneWireBus *bus, bool enable) |
Enable or disable the strong-pullup GPIO, if configured. More... | |
Interface definitions for the 1-Wire bus component.
This component provides structures and functions that are useful for communicating with devices connected to a Maxim Integrated 1-Wire® bus via a single GPIO.
Externally powered and "parasite-powered" devices are supported. Please consult your device's datasheet for power requirements.
Definition in file owb.h.
#define GPIO_NUM_NC (-1) |
#define OWB_ROM_CODE_STRING_LENGTH (17) |
#define OWB_ROM_MATCH 0x55 |
#define OWB_ROM_READ 0x33 |
#define OWB_ROM_SEARCH 0xF0 |
#define OWB_ROM_SEARCH_ALARM 0xEC |
#define OWB_ROM_SKIP 0xCC |
enum owb_status |
Represents the result of OWB API functions.
uint8_t owb_crc8_byte | ( | uint8_t | crc, |
uint8_t | data | ||
) |
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.
[in] | crc | Starting CRC value. Pass in prior CRC to accumulate. |
[in] | data | Array of bytes to feed into CRC. |
[in] | len | Length of data array in bytes. |
owb_status owb_read_bit | ( | const OneWireBus * | bus, |
uint8_t * | out | ||
) |
owb_status owb_read_byte | ( | const OneWireBus * | bus, |
uint8_t * | out | ||
) |
owb_status owb_read_bytes | ( | const OneWireBus * | bus, |
uint8_t * | buffer, | ||
unsigned int | len | ||
) |
owb_status owb_read_rom | ( | const OneWireBus * | bus, |
OneWireBus_ROMCode * | rom_code | ||
) |
owb_status owb_reset | ( | const OneWireBus * | bus, |
bool * | is_present | ||
) |
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.
[in] | bus | Pointer to initialised bus instance. |
[in,out] | state | Pointer to an existing search state structure. |
[out] | found_device | True if a device is found, false if no devices are found. If a device is found, the ROM Code can be obtained from the state. |
Definition at line 657 of file owb.c.
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. Further calls will yield additional devices, if present.
[in] | bus | Pointer to initialised bus instance. |
[in,out] | state | Pointer to an existing search state structure. |
[out] | found_device | True if a device is found, false if no devices are found. If a device is found, the ROM Code can be obtained from the state. |
Definition at line 685 of file owb.c.
owb_status owb_set_strong_pullup | ( | const OneWireBus * | bus, |
bool | enable | ||
) |
Enable or disable the strong-pullup GPIO, if configured.
[in] | bus | Pointer to initialised bus instance. |
[in] | enable | If true, enable the external strong pull-up by setting the GPIO high. If false, disable the external strong pull-up by setting the GPIO low. |
Definition at line 719 of file owb.c.
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.
[in] | rom_code | The ROM code to convert to string representation. |
[out] | buffer | The destination for the string representation. It will be null terminated. |
[in] | len | The length of the buffer in bytes. 64-bit ROM codes require 16 characters to represent as a string, plus a null terminator, for 17 bytes. See OWB_ROM_CODE_STRING_LENGTH. |
Definition at line 709 of file owb.c.
owb_status owb_uninitialize | ( | OneWireBus * | bus | ) |
call to release resources after completing use of the OneWireBus
[in] | bus | Pointer to initialised bus instance. |
Definition at line 259 of file owb.c.
owb_status owb_use_crc | ( | OneWireBus * | bus, |
bool | use_crc | ||
) |
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 bus, as devices cannot signal by pulling the bus low when it is pulled high.
[in] | bus | Pointer to initialised bus instance. |
[in] | use_parasitic_power | True to enable parasitic power, false to disable. |
Definition at line 299 of file owb.c.
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 parasitic power mode is enabled. signal by pulling the bus low when it is pulled high.
[in] | bus | Pointer to initialised bus instance. |
[in] | gpio | Set to GPIO number to use, or GPIO_NUM_NC to disable. |
Definition at line 322 of file owb.c.
owb_status owb_verify_rom | ( | const OneWireBus * | bus, |
OneWireBus_ROMCode | rom_code, | ||
bool * | is_present | ||
) |
owb_status owb_write_bit | ( | const OneWireBus * | bus, |
uint8_t | bit | ||
) |
owb_status owb_write_byte | ( | const OneWireBus * | bus, |
uint8_t | data | ||
) |
owb_status owb_write_bytes | ( | const OneWireBus * | bus, |
const uint8_t * | buffer, | ||
size_t | len | ||
) |
owb_status owb_write_rom_code | ( | const OneWireBus * | bus, |
OneWireBus_ROMCode | rom_code | ||
) |