mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-25 09:51:33 +02:00
add toString for i2c errors
This commit is contained in:
@ -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})
|
||||
|
||||
|
@ -28,11 +28,34 @@ extern "C" {
|
||||
#include <inttypes.h>
|
||||
}
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <futurecpp.h>
|
||||
#include <fmt/core.h>
|
||||
|
||||
#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)
|
||||
|
@ -28,12 +28,15 @@
|
||||
#include <esp32-hal.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include <string>
|
||||
|
||||
#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:
|
||||
|
Reference in New Issue
Block a user