ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
i2c_bus_esp_idf.cpp
Go to the documentation of this file.
1#ifdef USE_ESP_IDF
2
3#include "i2c_bus_esp_idf.h"
4#include <driver/gpio.h>
5#include <cinttypes>
6#include <cstring>
8#include "esphome/core/hal.h"
10#include "esphome/core/log.h"
11
12#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
13#define SOC_HP_I2C_NUM SOC_I2C_NUM
14#endif
15
16namespace esphome {
17namespace i2c {
18
19static const char *const TAG = "i2c.idf";
20
22 static i2c_port_t next_port = I2C_NUM_0;
23 this->port_ = next_port;
24 if (this->port_ == I2C_NUM_MAX) {
25 ESP_LOGE(TAG, "No more than %u buses supported", I2C_NUM_MAX);
26 this->mark_failed();
27 return;
28 }
29
30 if (this->timeout_ > 13000) {
31 ESP_LOGW(TAG, "Using max allowed timeout: 13 ms");
32 this->timeout_ = 13000;
33 }
34
35 this->recover_();
36
37#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
38 next_port = (i2c_port_t) (next_port + 1);
39
40 i2c_master_bus_config_t bus_conf{};
41 memset(&bus_conf, 0, sizeof(bus_conf));
42 bus_conf.sda_io_num = gpio_num_t(sda_pin_);
43 bus_conf.scl_io_num = gpio_num_t(scl_pin_);
44 bus_conf.i2c_port = this->port_;
45 bus_conf.glitch_ignore_cnt = 7;
46#if SOC_LP_I2C_SUPPORTED
47 if (this->port_ < SOC_HP_I2C_NUM) {
48 bus_conf.clk_source = I2C_CLK_SRC_DEFAULT;
49 } else {
50 bus_conf.lp_source_clk = LP_I2C_SCLK_DEFAULT;
51 }
52#else
53 bus_conf.clk_source = I2C_CLK_SRC_DEFAULT;
54#endif
55 bus_conf.flags.enable_internal_pullup = sda_pullup_enabled_ || scl_pullup_enabled_;
56 esp_err_t err = i2c_new_master_bus(&bus_conf, &this->bus_);
57 if (err != ESP_OK) {
58 ESP_LOGW(TAG, "i2c_new_master_bus failed: %s", esp_err_to_name(err));
59 this->mark_failed();
60 return;
61 }
62
63 i2c_device_config_t dev_conf{};
64 memset(&dev_conf, 0, sizeof(dev_conf));
65 dev_conf.dev_addr_length = I2C_ADDR_BIT_LEN_7;
66 dev_conf.device_address = I2C_DEVICE_ADDRESS_NOT_USED;
67 dev_conf.scl_speed_hz = this->frequency_;
68 dev_conf.scl_wait_us = this->timeout_;
69 err = i2c_master_bus_add_device(this->bus_, &dev_conf, &this->dev_);
70 if (err != ESP_OK) {
71 ESP_LOGW(TAG, "i2c_master_bus_add_device failed: %s", esp_err_to_name(err));
72 this->mark_failed();
73 return;
74 }
75
76 this->initialized_ = true;
77
78 if (this->scan_) {
79 ESP_LOGV(TAG, "Scanning for devices");
80 this->i2c_scan();
81 }
82#else
83#if SOC_HP_I2C_NUM > 1
84 next_port = (next_port == I2C_NUM_0) ? I2C_NUM_1 : I2C_NUM_MAX;
85#else
86 next_port = I2C_NUM_MAX;
87#endif
88
89 i2c_config_t conf{};
90 memset(&conf, 0, sizeof(conf));
91 conf.mode = I2C_MODE_MASTER;
92 conf.sda_io_num = sda_pin_;
93 conf.sda_pullup_en = sda_pullup_enabled_;
94 conf.scl_io_num = scl_pin_;
95 conf.scl_pullup_en = scl_pullup_enabled_;
96 conf.master.clk_speed = frequency_;
97#ifdef USE_ESP32_VARIANT_ESP32S2
98 // workaround for https://github.com/esphome/issues/issues/6718
99 conf.clk_flags = I2C_SCLK_SRC_FLAG_AWARE_DFS;
100#endif
101 esp_err_t err = i2c_param_config(port_, &conf);
102 if (err != ESP_OK) {
103 ESP_LOGW(TAG, "i2c_param_config failed: %s", esp_err_to_name(err));
104 this->mark_failed();
105 return;
106 }
107 if (timeout_ > 0) {
108 err = i2c_set_timeout(port_, timeout_ * 80); // unit: APB 80MHz clock cycle
109 if (err != ESP_OK) {
110 ESP_LOGW(TAG, "i2c_set_timeout failed: %s", esp_err_to_name(err));
111 this->mark_failed();
112 return;
113 } else {
114 ESP_LOGV(TAG, "i2c_timeout set to %" PRIu32 " ticks (%" PRIu32 " us)", timeout_ * 80, timeout_);
115 }
116 }
117 err = i2c_driver_install(port_, I2C_MODE_MASTER, 0, 0, 0);
118 if (err != ESP_OK) {
119 ESP_LOGW(TAG, "i2c_driver_install failed: %s", esp_err_to_name(err));
120 this->mark_failed();
121 return;
122 }
123
124 initialized_ = true;
125 if (this->scan_) {
126 ESP_LOGV(TAG, "Scanning bus for active devices");
127 this->i2c_scan();
128 }
129#endif
130}
131
133 ESP_LOGCONFIG(TAG, "I2C Bus:");
134 ESP_LOGCONFIG(TAG,
135 " SDA Pin: GPIO%u\n"
136 " SCL Pin: GPIO%u\n"
137 " Frequency: %" PRIu32 " Hz",
138 this->sda_pin_, this->scl_pin_, this->frequency_);
139 if (timeout_ > 0) {
140 ESP_LOGCONFIG(TAG, " Timeout: %" PRIu32 "us", this->timeout_);
141 }
142 switch (this->recovery_result_) {
144 ESP_LOGCONFIG(TAG, " Recovery: bus successfully recovered");
145 break;
147 ESP_LOGCONFIG(TAG, " Recovery: failed, SCL is held low on the bus");
148 break;
150 ESP_LOGCONFIG(TAG, " Recovery: failed, SDA is held low on the bus");
151 break;
152 }
153 if (this->scan_) {
154 ESP_LOGCONFIG(TAG, "Results from bus scan:");
155 if (scan_results_.empty()) {
156 ESP_LOGCONFIG(TAG, "Found no devices");
157 } else {
158 for (const auto &s : scan_results_) {
159 if (s.second) {
160 ESP_LOGCONFIG(TAG, "Found device at address 0x%02X", s.first);
161 } else {
162 ESP_LOGE(TAG, "Unknown error at address 0x%02X", s.first);
163 }
164 }
165 }
166 }
167}
168
169#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
171 for (uint8_t address = 8; address < 120; address++) {
172 auto err = i2c_master_probe(this->bus_, address, 20);
173 if (err == ESP_OK) {
174 this->scan_results_.emplace_back(address, true);
175 }
176 }
177}
178#endif
179
180ErrorCode IDFI2CBus::readv(uint8_t address, ReadBuffer *buffers, size_t cnt) {
181 // logging is only enabled with vv level, if warnings are shown the caller
182 // should log them
183 if (!initialized_) {
184 ESP_LOGVV(TAG, "i2c bus not initialized!");
186 }
187
188#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
189 i2c_operation_job_t jobs[cnt + 4];
190 uint8_t read = (address << 1) | I2C_MASTER_READ;
191 size_t last = 0, num = 0;
192
193 jobs[num].command = I2C_MASTER_CMD_START;
194 num++;
195
196 jobs[num].command = I2C_MASTER_CMD_WRITE;
197 jobs[num].write.ack_check = true;
198 jobs[num].write.data = &read;
199 jobs[num].write.total_bytes = 1;
200 num++;
201
202 // find the last valid index
203 for (size_t i = 0; i < cnt; i++) {
204 const auto &buf = buffers[i];
205 if (buf.len == 0) {
206 continue;
207 }
208 last = i;
209 }
210
211 for (size_t i = 0; i < cnt; i++) {
212 const auto &buf = buffers[i];
213 if (buf.len == 0) {
214 continue;
215 }
216 if (i == last) {
217 // the last byte read before stop should always be a nack,
218 // split the last read if len is larger than 1
219 if (buf.len > 1) {
220 jobs[num].command = I2C_MASTER_CMD_READ;
221 jobs[num].read.ack_value = I2C_ACK_VAL;
222 jobs[num].read.data = (uint8_t *) buf.data;
223 jobs[num].read.total_bytes = buf.len - 1;
224 num++;
225 }
226 jobs[num].command = I2C_MASTER_CMD_READ;
227 jobs[num].read.ack_value = I2C_NACK_VAL;
228 jobs[num].read.data = (uint8_t *) buf.data + buf.len - 1;
229 jobs[num].read.total_bytes = 1;
230 num++;
231 } else {
232 jobs[num].command = I2C_MASTER_CMD_READ;
233 jobs[num].read.ack_value = I2C_ACK_VAL;
234 jobs[num].read.data = (uint8_t *) buf.data;
235 jobs[num].read.total_bytes = buf.len;
236 num++;
237 }
238 }
239
240 jobs[num].command = I2C_MASTER_CMD_STOP;
241 num++;
242
243 esp_err_t err = i2c_master_execute_defined_operations(this->dev_, jobs, num, 20);
244 if (err == ESP_ERR_INVALID_STATE) {
245 ESP_LOGVV(TAG, "RX from %02X failed: not acked", address);
247 } else if (err == ESP_ERR_TIMEOUT) {
248 ESP_LOGVV(TAG, "RX from %02X failed: timeout", address);
249 return ERROR_TIMEOUT;
250 } else if (err != ESP_OK) {
251 ESP_LOGVV(TAG, "RX from %02X failed: %s", address, esp_err_to_name(err));
252 return ERROR_UNKNOWN;
253 }
254#else
255 i2c_cmd_handle_t cmd = i2c_cmd_link_create();
256 esp_err_t err = i2c_master_start(cmd);
257 if (err != ESP_OK) {
258 ESP_LOGVV(TAG, "RX from %02X master start failed: %s", address, esp_err_to_name(err));
259 i2c_cmd_link_delete(cmd);
260 return ERROR_UNKNOWN;
261 }
262 err = i2c_master_write_byte(cmd, (address << 1) | I2C_MASTER_READ, true);
263 if (err != ESP_OK) {
264 ESP_LOGVV(TAG, "RX from %02X address write failed: %s", address, esp_err_to_name(err));
265 i2c_cmd_link_delete(cmd);
266 return ERROR_UNKNOWN;
267 }
268 for (size_t i = 0; i < cnt; i++) {
269 const auto &buf = buffers[i];
270 if (buf.len == 0)
271 continue;
272 err = i2c_master_read(cmd, buf.data, buf.len, i == cnt - 1 ? I2C_MASTER_LAST_NACK : I2C_MASTER_ACK);
273 if (err != ESP_OK) {
274 ESP_LOGVV(TAG, "RX from %02X data read failed: %s", address, esp_err_to_name(err));
275 i2c_cmd_link_delete(cmd);
276 return ERROR_UNKNOWN;
277 }
278 }
279 err = i2c_master_stop(cmd);
280 if (err != ESP_OK) {
281 ESP_LOGVV(TAG, "RX from %02X stop failed: %s", address, esp_err_to_name(err));
282 i2c_cmd_link_delete(cmd);
283 return ERROR_UNKNOWN;
284 }
285 err = i2c_master_cmd_begin(port_, cmd, 20 / portTICK_PERIOD_MS);
286 // i2c_master_cmd_begin() will block for a whole second if no ack:
287 // https://github.com/espressif/esp-idf/issues/4999
288 i2c_cmd_link_delete(cmd);
289 if (err == ESP_FAIL) {
290 // transfer not acked
291 ESP_LOGVV(TAG, "RX from %02X failed: not acked", address);
293 } else if (err == ESP_ERR_TIMEOUT) {
294 ESP_LOGVV(TAG, "RX from %02X failed: timeout", address);
295 return ERROR_TIMEOUT;
296 } else if (err != ESP_OK) {
297 ESP_LOGVV(TAG, "RX from %02X failed: %s", address, esp_err_to_name(err));
298 return ERROR_UNKNOWN;
299 }
300#endif
301
302#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
303 char debug_buf[4];
304 std::string debug_hex;
305
306 for (size_t i = 0; i < cnt; i++) {
307 const auto &buf = buffers[i];
308 for (size_t j = 0; j < buf.len; j++) {
309 snprintf(debug_buf, sizeof(debug_buf), "%02X", buf.data[j]);
310 debug_hex += debug_buf;
311 }
312 }
313 ESP_LOGVV(TAG, "0x%02X RX %s", address, debug_hex.c_str());
314#endif
315
316 return ERROR_OK;
317}
318
319ErrorCode IDFI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cnt, bool stop) {
320 // logging is only enabled with vv level, if warnings are shown the caller
321 // should log them
322 if (!initialized_) {
323 ESP_LOGVV(TAG, "i2c bus not initialized!");
325 }
326
327#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
328 char debug_buf[4];
329 std::string debug_hex;
330
331 for (size_t i = 0; i < cnt; i++) {
332 const auto &buf = buffers[i];
333 for (size_t j = 0; j < buf.len; j++) {
334 snprintf(debug_buf, sizeof(debug_buf), "%02X", buf.data[j]);
335 debug_hex += debug_buf;
336 }
337 }
338 ESP_LOGVV(TAG, "0x%02X TX %s", address, debug_hex.c_str());
339#endif
340
341#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
342 i2c_operation_job_t jobs[cnt + 3];
343 uint8_t write = (address << 1) | I2C_MASTER_WRITE;
344 size_t num = 0;
345
346 jobs[num].command = I2C_MASTER_CMD_START;
347 num++;
348
349 jobs[num].command = I2C_MASTER_CMD_WRITE;
350 jobs[num].write.ack_check = true;
351 jobs[num].write.data = &write;
352 jobs[num].write.total_bytes = 1;
353 num++;
354
355 for (size_t i = 0; i < cnt; i++) {
356 const auto &buf = buffers[i];
357 if (buf.len == 0) {
358 continue;
359 }
360 jobs[num].command = I2C_MASTER_CMD_WRITE;
361 jobs[num].write.ack_check = true;
362 jobs[num].write.data = (uint8_t *) buf.data;
363 jobs[num].write.total_bytes = buf.len;
364 num++;
365 }
366
367 if (stop) {
368 jobs[num].command = I2C_MASTER_CMD_STOP;
369 num++;
370 }
371
372 esp_err_t err = i2c_master_execute_defined_operations(this->dev_, jobs, num, 20);
373 if (err == ESP_ERR_INVALID_STATE) {
374 ESP_LOGVV(TAG, "TX to %02X failed: not acked", address);
376 } else if (err == ESP_ERR_TIMEOUT) {
377 ESP_LOGVV(TAG, "TX to %02X failed: timeout", address);
378 return ERROR_TIMEOUT;
379 } else if (err != ESP_OK) {
380 ESP_LOGVV(TAG, "TX to %02X failed: %s", address, esp_err_to_name(err));
381 return ERROR_UNKNOWN;
382 }
383#else
384 i2c_cmd_handle_t cmd = i2c_cmd_link_create();
385 esp_err_t err = i2c_master_start(cmd);
386 if (err != ESP_OK) {
387 ESP_LOGVV(TAG, "TX to %02X master start failed: %s", address, esp_err_to_name(err));
388 i2c_cmd_link_delete(cmd);
389 return ERROR_UNKNOWN;
390 }
391 err = i2c_master_write_byte(cmd, (address << 1) | I2C_MASTER_WRITE, true);
392 if (err != ESP_OK) {
393 ESP_LOGVV(TAG, "TX to %02X address write failed: %s", address, esp_err_to_name(err));
394 i2c_cmd_link_delete(cmd);
395 return ERROR_UNKNOWN;
396 }
397 for (size_t i = 0; i < cnt; i++) {
398 const auto &buf = buffers[i];
399 if (buf.len == 0)
400 continue;
401 err = i2c_master_write(cmd, buf.data, buf.len, true);
402 if (err != ESP_OK) {
403 ESP_LOGVV(TAG, "TX to %02X data write failed: %s", address, esp_err_to_name(err));
404 i2c_cmd_link_delete(cmd);
405 return ERROR_UNKNOWN;
406 }
407 }
408 if (stop) {
409 err = i2c_master_stop(cmd);
410 if (err != ESP_OK) {
411 ESP_LOGVV(TAG, "TX to %02X master stop failed: %s", address, esp_err_to_name(err));
412 i2c_cmd_link_delete(cmd);
413 return ERROR_UNKNOWN;
414 }
415 }
416 err = i2c_master_cmd_begin(port_, cmd, 20 / portTICK_PERIOD_MS);
417 i2c_cmd_link_delete(cmd);
418 if (err == ESP_FAIL) {
419 // transfer not acked
420 ESP_LOGVV(TAG, "TX to %02X failed: not acked", address);
422 } else if (err == ESP_ERR_TIMEOUT) {
423 ESP_LOGVV(TAG, "TX to %02X failed: timeout", address);
424 return ERROR_TIMEOUT;
425 } else if (err != ESP_OK) {
426 ESP_LOGVV(TAG, "TX to %02X failed: %s", address, esp_err_to_name(err));
427 return ERROR_UNKNOWN;
428 }
429#endif
430 return ERROR_OK;
431}
432
436void IDFI2CBus::recover_() {
437 ESP_LOGI(TAG, "Performing bus recovery");
438
439 const gpio_num_t scl_pin = static_cast<gpio_num_t>(scl_pin_);
440 const gpio_num_t sda_pin = static_cast<gpio_num_t>(sda_pin_);
441
442 // For the upcoming operations, target for a 60kHz toggle frequency.
443 // 1000kHz is the maximum frequency for I2C running in standard-mode,
444 // but lower frequencies are not a problem.
445 // Note: the timing that is used here is chosen manually, to get
446 // results that are close to the timing that can be archieved by the
447 // implementation for the Arduino framework.
448 const auto half_period_usec = 7;
449
450 // Configure SCL pin for open drain input/output, with a pull up resistor.
451 gpio_set_level(scl_pin, 1);
452 gpio_config_t scl_config{};
453 scl_config.pin_bit_mask = 1ULL << scl_pin_;
454 scl_config.mode = GPIO_MODE_INPUT_OUTPUT_OD;
455 scl_config.pull_up_en = GPIO_PULLUP_ENABLE;
456 scl_config.pull_down_en = GPIO_PULLDOWN_DISABLE;
457 scl_config.intr_type = GPIO_INTR_DISABLE;
458 gpio_config(&scl_config);
459
460 // Configure SDA pin for open drain input/output, with a pull up resistor.
461 gpio_set_level(sda_pin, 1);
462 gpio_config_t sda_conf{};
463 sda_conf.pin_bit_mask = 1ULL << sda_pin_;
464 sda_conf.mode = GPIO_MODE_INPUT_OUTPUT_OD;
465 sda_conf.pull_up_en = GPIO_PULLUP_ENABLE;
466 sda_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
467 sda_conf.intr_type = GPIO_INTR_DISABLE;
468 gpio_config(&sda_conf);
469
470 // If SCL is pulled low on the I2C bus, then some device is interfering
471 // with the SCL line. In that case, the I2C bus cannot be recovered.
472 delayMicroseconds(half_period_usec);
473 if (gpio_get_level(scl_pin) == 0) {
474 ESP_LOGE(TAG, "Recovery failed: SCL is held LOW on the bus");
475 recovery_result_ = RECOVERY_FAILED_SCL_LOW;
476 return;
477 }
478
479 // From the specification:
480 // "If the data line (SDA) is stuck LOW, send nine clock pulses. The
481 // device that held the bus LOW should release it sometime within
482 // those nine clocks."
483 // We don't really have to detect if SDA is stuck low. We'll simply send
484 // nine clock pulses here, just in case SDA is stuck. Actual checks on
485 // the SDA line status will be done after the clock pulses.
486 for (auto i = 0; i < 9; i++) {
487 gpio_set_level(scl_pin, 0);
488 delayMicroseconds(half_period_usec);
489 gpio_set_level(scl_pin, 1);
490 delayMicroseconds(half_period_usec);
491
492 // When SCL is kept LOW at this point, we might be looking at a device
493 // that applies clock stretching. Wait for the release of the SCL line,
494 // but not forever. There is no specification for the maximum allowed
495 // time. We yield and reset the WDT, so as to avoid triggering reset.
496 // No point in trying to recover the bus by forcing a uC reset. Bus
497 // should recover in a few ms or less else not likely to recovery at
498 // all.
499 auto wait = 250;
500 while (wait-- && gpio_get_level(scl_pin) == 0) {
501 App.feed_wdt();
502 delayMicroseconds(half_period_usec * 2);
503 }
504 if (gpio_get_level(scl_pin) == 0) {
505 ESP_LOGE(TAG, "Recovery failed: SCL is held LOW during clock pulse cycle");
506 recovery_result_ = RECOVERY_FAILED_SCL_LOW;
507 return;
508 }
509 }
510
511 // By now, any stuck device ought to have sent all remaining bits of its
512 // transaction, meaning that it should have freed up the SDA line, resulting
513 // in SDA being pulled up.
514 if (gpio_get_level(sda_pin) == 0) {
515 ESP_LOGE(TAG, "Recovery failed: SDA is held LOW after clock pulse cycle");
516 recovery_result_ = RECOVERY_FAILED_SDA_LOW;
517 return;
518 }
519
520 // From the specification:
521 // "I2C-bus compatible devices must reset their bus logic on receipt of
522 // a START or repeated START condition such that they all anticipate
523 // the sending of a target address, even if these START conditions are
524 // not positioned according to the proper format."
525 // While the 9 clock pulses from above might have drained all bits of a
526 // single byte within a transaction, a device might have more bytes to
527 // transmit. So here we'll generate a START condition to snap the device
528 // out of this state.
529 // SCL and SDA are already high at this point, so we can generate a START
530 // condition by making the SDA signal LOW.
531 delayMicroseconds(half_period_usec);
532 gpio_set_level(sda_pin, 0);
533
534 // From the specification:
535 // "A START condition immediately followed by a STOP condition (void
536 // message) is an illegal format. Many devices however are designed to
537 // operate properly under this condition."
538 // Finally, we'll bring the I2C bus into a starting state by generating
539 // a STOP condition.
540 delayMicroseconds(half_period_usec);
541 gpio_set_level(sda_pin, 1);
542
543 recovery_result_ = RECOVERY_COMPLETED;
544}
545
546} // namespace i2c
547} // namespace esphome
548
549#endif // USE_ESP_IDF
uint8_t address
Definition bl0906.h:4
void feed_wdt(uint32_t time=0)
virtual void mark_failed()
Mark this component as failed.
bool scan_
Should we scan ? Can be set in the yaml.
Definition i2c_bus.h:108
std::vector< std::pair< uint8_t, bool > > scan_results_
array containing scan results
Definition i2c_bus.h:107
virtual ErrorCode read(uint8_t address, uint8_t *buffer, size_t len)
Creates a ReadBuffer and calls the virtual readv() method to read bytes into this buffer.
Definition i2c_bus.h:47
virtual ErrorCode write(uint8_t address, const uint8_t *buffer, size_t len)
Definition i2c_bus.h:62
ErrorCode readv(uint8_t address, ReadBuffer *buffers, size_t cnt) override
i2c_master_bus_handle_t bus_
ErrorCode writev(uint8_t address, WriteBuffer *buffers, size_t cnt, bool stop) override
i2c_master_dev_handle_t dev_
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
Definition i2c_bus.h:11
@ ERROR_OK
No error found during execution of method.
Definition i2c_bus.h:13
@ ERROR_TIMEOUT
timeout while waiting to receive bytes
Definition i2c_bus.h:16
@ ERROR_NOT_ACKNOWLEDGED
I2C bus acknowledgment not received.
Definition i2c_bus.h:15
@ ERROR_NOT_INITIALIZED
call method to a not initialized bus
Definition i2c_bus.h:17
@ ERROR_UNKNOWN
miscellaneous I2C error during execution
Definition i2c_bus.h:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
Definition core.cpp:31
Application App
Global storage of Application pointer - only one Application can exist.
the ReadBuffer structure stores a pointer to a read buffer and its length
Definition i2c_bus.h:24
the WriteBuffer structure stores a pointer to a write buffer and its length
Definition i2c_bus.h:30
const uint8_t * data
pointer to the write buffer
Definition i2c_bus.h:31