components/esp32-owb/include/owb.h

Mon, 24 Jun 2024 17:09:07 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 24 Jun 2024 17:09:07 +0200
branch
idf 5.1
changeset 130
96ee5cb45b37
parent 129
31f9d3e4a85f
permissions
-rw-r--r--

Added new files and remove obsolete.

0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * MIT License
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Copyright (c) 2017 David Antliff
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * Copyright (c) 2017 Chris Morgan <chmorgan@gmail.com>
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 *
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * of this software and associated documentation files (the "Software"), to deal
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * in the Software without restriction, including without limitation the rights
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * copies of the Software, and to permit persons to whom the Software is
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * furnished to do so, subject to the following conditions:
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * The above copyright notice and this permission notice shall be included in all
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * copies or substantial portions of the Software.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 *
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 * SOFTWARE.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 * @file
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 * @brief Interface definitions for the 1-Wire bus component.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 *
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 * This component provides structures and functions that are useful for communicating
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 * with devices connected to a Maxim Integrated 1-Wire® bus via a single GPIO.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 *
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
33 * Externally powered and "parasite-powered" devices are supported.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
34 * Please consult your device's datasheet for power requirements.
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 #ifndef ONE_WIRE_BUS_H
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 #define ONE_WIRE_BUS_H
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 #include <stdint.h>
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 #include <stdbool.h>
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 #include <stddef.h>
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
43 #include "driver/gpio.h"
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 #ifdef __cplusplus
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 extern "C" {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 #endif
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 // ROM commands
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
51 #define OWB_ROM_SEARCH 0xF0 ///< Perform Search ROM cycle to identify devices on the bus
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
52 #define OWB_ROM_READ 0x33 ///< Read device ROM (single device on bus only)
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
53 #define OWB_ROM_MATCH 0x55 ///< Address a specific device on the bus by ROM
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
54 #define OWB_ROM_SKIP 0xCC ///< Address all devices on the bus simultaneously
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
55 #define OWB_ROM_SEARCH_ALARM 0xEC ///< Address all devices on the bus with a set alarm flag
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 #define OWB_ROM_CODE_STRING_LENGTH (17) ///< Typical length of OneWire bus ROM ID as ASCII hex string, including null terminator
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
59 #ifndef GPIO_NUM_NC
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
60 # define GPIO_NUM_NC (-1) ///< ESP-IDF prior to v4.x does not define GPIO_NUM_NC
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
61 #endif
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
62
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 struct owb_driver;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 * @brief Structure containing 1-Wire bus information relevant to a single instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 typedef struct
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 const struct _OneWireBus_Timing * timing; ///< Pointer to timing information
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 bool use_crc; ///< True if CRC checks are to be used when retrieving information from a device on the bus
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
72 bool use_parasitic_power; ///< True if parasitic-powered devices are expected on the bus
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
73 gpio_num_t strong_pullup_gpio; ///< Set if an external strong pull-up circuit is required
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
74 const struct owb_driver * driver; ///< Pointer to hardware driver instance
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 } OneWireBus;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 * @brief Represents a 1-Wire ROM Code. This is a sequence of eight bytes, where
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 * the first byte is the family number, then the following 6 bytes form the
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 * serial number. The final byte is the CRC8 check byte.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 typedef union
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 /// Provides access via field names
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 struct fields
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 uint8_t family[1]; ///< family identifier (1 byte, LSB - read/write first)
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 uint8_t serial_number[6]; ///< serial number (6 bytes)
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 uint8_t crc[1]; ///< CRC check byte (1 byte, MSB - read/write last)
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 } fields; ///< Provides access via field names
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 uint8_t bytes[8]; ///< Provides raw byte access
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 } OneWireBus_ROMCode;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 * @brief Represents the state of a device search on the 1-Wire bus.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 *
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 * Pass a pointer to this structure to owb_search_first() and
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 * owb_search_next() to iterate through detected devices on the bus.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 typedef struct
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 {
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
104 OneWireBus_ROMCode rom_code; ///< Device ROM code
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
105 int last_discrepancy; ///< Bit index that identifies from which bit the next search discrepancy check should start
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
106 int last_family_discrepancy; ///< Bit index that identifies the last discrepancy within the first 8-bit family code of the ROM code
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
107 int last_device_flag; ///< Flag to indicate previous search was the last device detected
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 } OneWireBus_SearchState;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109
29
45647136ec95 Updates for doxygen
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
110 /**
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
111 * @brief Represents the result of OWB API functions.
29
45647136ec95 Updates for doxygen
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
112 */
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 typedef enum
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 {
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
115 OWB_STATUS_NOT_SET = -1, ///< A status value has not been set
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
116 OWB_STATUS_OK = 0, ///< Operation succeeded
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
117 OWB_STATUS_NOT_INITIALIZED, ///< Function was passed an uninitialised variable
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
118 OWB_STATUS_PARAMETER_NULL, ///< Function was passed a null pointer
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
119 OWB_STATUS_DEVICE_NOT_RESPONDING, ///< No response received from the addressed device or devices
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
120 OWB_STATUS_CRC_FAILED, ///< CRC failed on data received from a device or devices
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
121 OWB_STATUS_TOO_MANY_BITS, ///< Attempt to write an incorrect number of bits to the One Wire Bus
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
122 OWB_STATUS_HW_ERROR ///< A hardware error occurred
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 } owb_status;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 /** NOTE: Driver assumes that (*init) was called prior to any other methods */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 struct owb_driver
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 const char* name;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 owb_status (*uninitialize)(const OneWireBus * bus);
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
130 owb_status (*reset)(const OneWireBus *bus, bool *is_present);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 owb_status (*write_bits)(const OneWireBus *bus, uint8_t out, int number_of_bits_to_write);
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
132 owb_status (*write_bytes)(const OneWireBus *bus, uint8_t *bytes, int number_of_bytes_to_write);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 owb_status (*read_bits)(const OneWireBus *bus, uint8_t *in, int number_of_bits_to_read);
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
134 owb_status (*read_bytes)(const OneWireBus *bus, uint64_t *in, int number_of_bytes_to_read);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 };
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
137 /// @cond ignore
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
138 // note: the new owb_rmt driver uses the ESP-IDF's built-in `__containerof()` macro instead of this
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 #define container_of(ptr, type, member) ({ \
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 (type *)( (char *)__mptr - offsetof(type,member) );})
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
142 /// @endcond
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 * @brief call to release resources after completing use of the OneWireBus
29
45647136ec95 Updates for doxygen
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
146 * @param[in] bus Pointer to initialised bus instance.
45647136ec95 Updates for doxygen
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
147 * @return status
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 owb_status owb_uninitialize(OneWireBus * bus);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 * @brief Enable or disable use of CRC checks on device communications.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 * @param[in] bus Pointer to initialised bus instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 * @param[in] use_crc True to enable CRC checks, false to disable.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 owb_status owb_use_crc(OneWireBus * bus, bool use_crc);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 /**
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
160 * @brief Enable or disable use of parasitic power on the One Wire Bus.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
161 * This affects how devices signal on the bus, as devices cannot
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
162 * signal by pulling the bus low when it is pulled high.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
163 * @param[in] bus Pointer to initialised bus instance.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
164 * @param[in] use_parasitic_power True to enable parasitic power, false to disable.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
165 * @return status
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
166 */
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
167 owb_status owb_use_parasitic_power(OneWireBus * bus, bool use_parasitic_power);
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
168
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
169 /**
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
170 * @brief Enable or disable use of extra GPIO to activate strong pull-up circuit.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
171 * This only has effect if parasitic power mode is enabled.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
172 * signal by pulling the bus low when it is pulled high.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
173 * @param[in] bus Pointer to initialised bus instance.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
174 * @param[in] gpio Set to GPIO number to use, or GPIO_NUM_NC to disable.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
175 * @return status
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
176 */
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
177 owb_status owb_use_strong_pullup_gpio(OneWireBus * bus, gpio_num_t gpio);
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
178
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
179 /**
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 * @brief Read ROM code from device - only works when there is a single device on the bus.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 * @param[in] bus Pointer to initialised bus instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 * @param[out] rom_code the value read from the device's rom
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 */
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
185 owb_status owb_read_rom(const OneWireBus * bus, OneWireBus_ROMCode * rom_code);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 * @brief Verify the device specified by ROM code is present.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 * @param[in] bus Pointer to initialised bus instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 * @param[in] rom_code ROM code to verify.
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
191 * @param[out] is_present Set to true if a device is present, false if not
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 */
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
194 owb_status owb_verify_rom(const OneWireBus * bus, OneWireBus_ROMCode rom_code, bool * is_present);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 * @brief Reset the 1-Wire bus.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 * @param[in] bus Pointer to initialised bus instance.
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
199 * @param[out] is_present set to true if at least one device is present on the bus
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
200 * @return status
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
201 */
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
202 owb_status owb_reset(const OneWireBus * bus, bool * is_present);
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
203
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
204 /**
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
205 * @brief Read a single bit from the 1-Wire bus.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
206 * @param[in] bus Pointer to initialised bus instance.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
207 * @param[out] out The bit value read from the bus.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
208 * @return status
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
209 */
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
210 owb_status owb_read_bit(const OneWireBus * bus, uint8_t * out);
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
211
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
212 /**
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
213 * @brief Read a single byte from the 1-Wire bus.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
214 * @param[in] bus Pointer to initialised bus instance.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
215 * @param[out] out The byte value read from the bus (lsb only).
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 */
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
218 owb_status owb_read_byte(const OneWireBus * bus, uint8_t * out);
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
219
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
220 /**
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
221 * @brief Read a number of bytes from the 1-Wire bus.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
222 * @param[in] bus Pointer to initialised bus instance.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
223 * @param[in, out] buffer Pointer to buffer to receive read data.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
224 * @param[in] len Number of bytes to read, must not exceed length of receive buffer.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
225 * @return status.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
226 */
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
227 owb_status owb_read_bytes(const OneWireBus * bus, uint8_t * buffer, unsigned int len);
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
228
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
229 /**
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
230 * @brief Write a bit to the 1-Wire bus.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
231 * @param[in] bus Pointer to initialised bus instance.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
232 * @param[in] bit Value to write (lsb only).
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
233 * @return status
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
234 */
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
235 owb_status owb_write_bit(const OneWireBus * bus, uint8_t bit);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 * @brief Write a single byte to the 1-Wire bus.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 * @param[in] bus Pointer to initialised bus instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 * @param[in] data Byte value to write to bus.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 owb_status owb_write_byte(const OneWireBus * bus, uint8_t data);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 * @brief Write a number of bytes to the 1-Wire bus.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 * @param[in] bus Pointer to initialised bus instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 * @param[in] buffer Pointer to buffer to write data from.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 * @param[in] len Number of bytes to write.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 owb_status owb_write_bytes(const OneWireBus * bus, const uint8_t * buffer, size_t len);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 * @brief Write a ROM code to the 1-Wire bus ensuring LSB is sent first.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 * @param[in] bus Pointer to initialised bus instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 * @param[in] rom_code ROM code to write to bus.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 owb_status owb_write_rom_code(const OneWireBus * bus, OneWireBus_ROMCode rom_code);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 * @brief 1-Wire 8-bit CRC lookup.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 * @param[in] crc Starting CRC value. Pass in prior CRC to accumulate.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 * @param[in] data Byte to feed into CRC.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266 * @return Resultant CRC value.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 * Should be zero if last byte was the CRC byte and the CRC matches.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 uint8_t owb_crc8_byte(uint8_t crc, uint8_t data);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 * @brief 1-Wire 8-bit CRC lookup with accumulation over a block of bytes.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 * @param[in] crc Starting CRC value. Pass in prior CRC to accumulate.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 * @param[in] data Array of bytes to feed into CRC.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 * @param[in] len Length of data array in bytes.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 * @return Resultant CRC value.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 * Should be zero if last byte was the CRC byte and the CRC matches.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 uint8_t owb_crc8_bytes(uint8_t crc, const uint8_t * data, size_t len);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 * @brief Locates the first device on the 1-Wire bus, if present.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 * @param[in] bus Pointer to initialised bus instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 * @param[in,out] state Pointer to an existing search state structure.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 * @param[out] found_device True if a device is found, false if no devices are found.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 * If a device is found, the ROM Code can be obtained from the state.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 owb_status owb_search_first(const OneWireBus * bus, OneWireBus_SearchState * state, bool *found_device);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 * @brief Locates the next device on the 1-Wire bus, if present, starting from
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 * the provided state. Further calls will yield additional devices, if present.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 * @param[in] bus Pointer to initialised bus instance.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 * @param[in,out] state Pointer to an existing search state structure.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 * @param[out] found_device True if a device is found, false if no devices are found.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 * If a device is found, the ROM Code can be obtained from the state.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 * @return status
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 owb_status owb_search_next(const OneWireBus * bus, OneWireBus_SearchState * state, bool *found_device);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 * @brief Create a string representation of a ROM code, most significant byte (CRC8) first.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 * @param[in] rom_code The ROM code to convert to string representation.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 * @param[out] buffer The destination for the string representation. It will be null terminated.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 * @param[in] len The length of the buffer in bytes. 64-bit ROM codes require 16 characters
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 * to represent as a string, plus a null terminator, for 17 bytes.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 * See OWB_ROM_CODE_STRING_LENGTH.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 * @return pointer to the byte beyond the last byte written
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 char * owb_string_from_rom_code(OneWireBus_ROMCode rom_code, char * buffer, size_t len);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312
129
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
313 /**
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
314 * @brief Enable or disable the strong-pullup GPIO, if configured.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
315 * @param[in] bus Pointer to initialised bus instance.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
316 * @param[in] enable If true, enable the external strong pull-up by setting the GPIO high.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
317 * If false, disable the external strong pull-up by setting the GPIO low.
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
318 * @return status
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
319 */
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
320 owb_status owb_set_strong_pullup(const OneWireBus * bus, bool enable);
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
321
31f9d3e4a85f Start migration to IDF 5.1
Michiel Broek <mbroek@mbse.eu>
parents: 29
diff changeset
322
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 #include "owb_gpio.h"
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 #include "owb_rmt.h"
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 #ifdef __cplusplus
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 #endif
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 #endif // ONE_WIRE_BUS_H

mercurial