diff --git a/CMakeLists.txt b/CMakeLists.txt index 23ed46d7..5bc61ed6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ set(includedirs set(srcs ${CORE_SRCS} ${LIBRARY_SRCS} ${BLE_SRCS}) set(requires spi_flash mbedtls esp_adc_cal wifi_provisioning) -set(priv_requires nvs_flash spiffs bootloader_support openssl tinyusb main) +set(priv_requires nvs_flash spiffs bootloader_support openssl tinyusb espcpputils fmt) idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index 5cdf5349..82355225 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -28,11 +28,34 @@ extern "C" { #include } +#include +#include +#include + #include "esp32-hal-i2c.h" #include "esp32-hal-log.h" #include "Wire.h" #include "Arduino.h" +std::string toString(i2c_err_t val) +{ + switch (val) + { + case I2C_ERROR_OK: return "I2C_ERROR_OK"; + case I2C_ERROR_DEV: return "I2C_ERROR_DEV"; + case I2C_ERROR_ACK: return "I2C_ERROR_ACK"; + case I2C_ERROR_TIMEOUT: return "I2C_ERROR_TIMEOUT"; + case I2C_ERROR_BUS: return "I2C_ERROR_BUS"; + case I2C_ERROR_BUSY: return "I2C_ERROR_BUSY"; + case I2C_ERROR_MEMORY: return "I2C_ERROR_MEMORY"; + case I2C_ERROR_CONTINUE: return "I2C_ERROR_CONTINUE"; + case I2C_ERROR_NO_BEGIN: return "I2C_ERROR_NO_BEGIN"; + default: + ESP_LOGW("WIRE", "unknown i2c_err_t(%i)", std::to_underlying(val)); + return fmt::format("Unknown i2c_err_t({})", std::to_underlying(val)); + } +} + TwoWire::TwoWire(uint8_t bus_num) :num(bus_num & 1) ,sda(-1) diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h index 9a100a57..acfbfc48 100644 --- a/libraries/Wire/src/Wire.h +++ b/libraries/Wire/src/Wire.h @@ -28,12 +28,15 @@ #include #include "freertos/FreeRTOS.h" #include "freertos/queue.h" +#include #define STICKBREAKER 'V1.1.0' #define I2C_BUFFER_LENGTH 128 typedef void(*user_onRequest)(void); typedef void(*user_onReceive)(uint8_t*, int); +std::string toString(i2c_err_t val); + class TwoWire { protected: