HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
EspI2c.cpp File Reference

Implementation of ESP32-integrated I2C controller with proper bus-device architecture. More...

#include "EspI2c.h"
#include "utils/memory_utils.h"
#include <algorithm>
#include <cstring>
#include "driver/gpio.h"
#include "driver/i2c_master.h"
#include "driver/i2c_types.h"
#include "esp_err.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Include dependency graph for EspI2c.cpp:

Macros

#define USE_CUSTOM_FAST_PROBE   1
 

Functions

const char * HfI2COperationToString (hf_i2c_operation_t op) noexcept
 Convert operation type to string for logging.
 

Variables

static const char * TAG = "EspI2c"
 

Detailed Description

Implementation of ESP32-integrated I2C controller with proper bus-device architecture.

This file provides the implementation for I2C bus communication using the ESP32's built-in I2C peripheral with full ESP-IDF v5.5+ capabilities and proper separation of bus and device management following the same pattern as EspSpi.

Key architectural improvements:

  • Proper bus-device separation matching ESP-IDF v5.5+ API design
  • EspI2cBus manages the I2C bus and device creation
  • EspI2cDevice represents individual devices and inherits from BaseI2c
  • Thread-safe operations with proper resource management
  • Comprehensive error handling with ESP-IDF error conversion
  • Per-device statistics and diagnostics
  • Automatic resource cleanup and lifecycle management

The implementation closely follows ESP-IDF v5.5 I2C Master driver documentation: https://docs.espressif.com/projects/esp-idf/en/release-v5.5/esp32c6/api-reference/peripherals/i2c.html

Author
Nebiyu Tadesse
Date
2025
Note
Fully compliant with ESP-IDF v5.5 I2C Master driver API
Optimized for ESP32C6 hardware capabilities
Thread-safe for multi-device I2C bus management
Follows the same architectural pattern as EspSpi

Macro Definition Documentation

◆ USE_CUSTOM_FAST_PROBE

#define USE_CUSTOM_FAST_PROBE   1

Function Documentation

◆ HfI2COperationToString()

const char * HfI2COperationToString ( hf_i2c_operation_t op)
noexcept

Convert operation type to string for logging.

Parameters
opOperation type
Returns
String representation of operation

Variable Documentation

◆ TAG

const char* TAG = "EspI2c"
static