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

ESP32 I2C type definitions for hardware abstraction. More...

#include "BaseI2c.h"
#include "EspTypes_Base.h"
#include "HardwareTypes.h"
#include "McuSelect.h"
#include <vector>
#include "driver/i2c.h"
Include dependency graph for EspTypes_I2C.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hf_i2c_async_result_t
 Asynchronous operation result structure. More...
 
struct  hf_i2c_master_bus_config_t
 I2C master bus configuration structure. More...
 
struct  hf_i2c_device_config_t
 I2C device configuration structure. More...
 
struct  hf_i2c_slave_config_t
 I2C slave configuration structure. More...
 
struct  hf_i2c_transaction_buffer_t
 I2C transaction buffer structure. More...
 
struct  hf_i2c_multi_buffer_transaction_t
 Multi-buffer I2C transaction structure. More...
 
struct  hf_i2c_custom_command_t
 Custom I2C command for non-standard protocols. More...
 

Typedefs

using hf_i2c_async_callback_t
 Callback function signature for asynchronous I2C operations.
 
using hf_i2c_event_callback_t
 Callback function signature for I2C event notifications.
 

Enumerations

enum class  hf_i2c_clock_source_t : uint8_t { HF_I2C_CLK_SRC_DEFAULT = I2C_CLK_SRC_DEFAULT , HF_I2C_CLK_SRC_XTAL = I2C_CLK_SRC_XTAL , HF_I2C_CLK_SRC_RC_FAST = I2C_CLK_SRC_RC_FAST }
 ESP32 I2C clock source selection. More...
 
enum class  hf_i2c_address_bits_t : uint8_t { HF_I2C_ADDR_7_BIT = I2C_ADDR_BIT_LEN_7 , HF_I2C_ADDR_10_BIT = I2C_ADDR_BIT_LEN_10 }
 ESP32 I2C address bit length. More...
 
enum class  hf_i2c_power_mode_t : uint8_t { HF_I2C_POWER_MODE_NORMAL = 0 , HF_I2C_POWER_MODE_LOW = 1 , HF_I2C_POWER_MODE_SLEEP = 2 }
 ESP32 I2C power mode configuration. More...
 
enum class  hf_i2c_transaction_type_t : uint8_t { HF_I2C_TRANS_WRITE = 0 , HF_I2C_TRANS_READ = 1 , HF_I2C_TRANS_WRITE_READ = 2 }
 ESP32 I2C transaction types. More...
 
enum class  hf_i2c_event_type_t : int {
  HF_I2C_EVENT_MASTER_START = 0 , HF_I2C_EVENT_MASTER_STOP = 1 , HF_I2C_EVENT_MASTER_WRITE = 2 , HF_I2C_EVENT_MASTER_READ = 3 ,
  HF_I2C_EVENT_SLAVE_START = 4 , HF_I2C_EVENT_SLAVE_STOP = 5 , HF_I2C_EVENT_SLAVE_WRITE = 6 , HF_I2C_EVENT_SLAVE_READ = 7 ,
  HF_I2C_EVENT_ERROR = 8
}
 ESP32 I2C event types. More...
 
enum class  hf_i2c_glitch_filter_t : uint8_t {
  HF_I2C_GLITCH_FILTER_0_CYCLES = 0 , HF_I2C_GLITCH_FILTER_1_CYCLES = 1 , HF_I2C_GLITCH_FILTER_2_CYCLES = 2 , HF_I2C_GLITCH_FILTER_3_CYCLES = 3 ,
  HF_I2C_GLITCH_FILTER_4_CYCLES = 4 , HF_I2C_GLITCH_FILTER_5_CYCLES = 5 , HF_I2C_GLITCH_FILTER_6_CYCLES = 6 , HF_I2C_GLITCH_FILTER_7_CYCLES = 7
}
 ESP32 I2C glitch filter configuration. More...
 
enum class  hf_i2c_command_type_t : uint8_t {
  HF_I2C_CMD_START = 0 , HF_I2C_CMD_STOP = 1 , HF_I2C_CMD_WRITE = 2 , HF_I2C_CMD_READ = 3 ,
  HF_I2C_CMD_WRITE_READ = 4 , HF_I2C_CMD_DELAY = 5
}
 ESP32 I2C custom command types. More...
 
enum class  hf_i2c_mode_t : uint8_t { HF_I2C_MODE_SYNC = 0 , HF_I2C_MODE_ASYNC = 1 }
 I2C operation mode - determines available APIs. More...
 

Variables

static constexpr uint8_t HF_I2C_MAX_PORTS = 2
 
static constexpr uint32_t HF_I2C_MAX_FREQ_HZ = 1000000
 
static constexpr uint32_t HF_I2C_MIN_FREQ_HZ = 1000
 
static constexpr uint32_t HF_I2C_DEFAULT_FREQ_HZ = 100000
 
static constexpr uint32_t HF_I2C_FAST_FREQ_HZ = 400000
 
static constexpr uint32_t HF_I2C_FAST_PLUS_FREQ_HZ = 1000000
 
static constexpr uint32_t HF_I2C_MAX_TRANSFER_BYTES = 1024
 
static constexpr uint32_t HF_I2C_FIFO_SIZE = 32
 
static constexpr uint32_t HF_I2C_DEFAULT_TIMEOUT_MS = 1000
 
static constexpr uint32_t HF_I2C_MAX_TIMEOUT_MS = 10000
 
static constexpr uint8_t HF_I2C_MAX_RETRY_COUNT = 3
 

Detailed Description

ESP32 I2C type definitions for hardware abstraction.

This header defines only the essential I2C-specific types used by the EspI2c implementation. Clean and minimal approach.

Author
Nebiyu Tadesse
Date
2025

Typedef Documentation

◆ hf_i2c_async_callback_t

Initial value:
void(*)(hf_i2c_err_t result, size_t bytes_transferred, void* user_data)
hf_i2c_err_t
Definition BaseI2c.h:85

Callback function signature for asynchronous I2C operations.

Parameters
resultOperation result code
bytes_transferredNumber of bytes successfully transferred
user_dataUser-provided data pointer
Note
This callback is executed in interrupt context - keep it minimal and fast!
Avoid blocking operations, heap allocation, or complex computations.
Use FreeRTOS queue/semaphore mechanisms to communicate with tasks.

◆ hf_i2c_event_callback_t

Initial value:
void(*)(hf_i2c_event_type_t event_type, void* event_data, void* user_data)
hf_i2c_event_type_t
ESP32 I2C event types.
Definition EspTypes_I2C.h:98

Callback function signature for I2C event notifications.

Parameters
event_typeType of event that occurred
event_dataEvent-specific data (if any)
user_dataUser-provided data pointer
Note
This callback is executed in interrupt context - keep it minimal and fast!
Avoid blocking operations, heap allocation, or complex computations.
Use FreeRTOS queue/semaphore mechanisms to communicate with tasks.

Enumeration Type Documentation

◆ hf_i2c_address_bits_t

enum class hf_i2c_address_bits_t : uint8_t
strong

ESP32 I2C address bit length.

Enumerator
HF_I2C_ADDR_7_BIT 

7-bit address

HF_I2C_ADDR_10_BIT 

10-bit address

◆ hf_i2c_clock_source_t

enum class hf_i2c_clock_source_t : uint8_t
strong

ESP32 I2C clock source selection.

Enumerator
HF_I2C_CLK_SRC_DEFAULT 

Default clock source (APB for ESP32-C6)

HF_I2C_CLK_SRC_XTAL 

External crystal oscillator clock.

HF_I2C_CLK_SRC_RC_FAST 

RC_FAST clock (ESP32-C6 SOC_MOD_CLK_RC_FAST)

◆ hf_i2c_command_type_t

enum class hf_i2c_command_type_t : uint8_t
strong

ESP32 I2C custom command types.

Enumerator
HF_I2C_CMD_START 

Start condition.

HF_I2C_CMD_STOP 

Stop condition.

HF_I2C_CMD_WRITE 

Write data.

HF_I2C_CMD_READ 

Read data.

HF_I2C_CMD_WRITE_READ 

Write then read in one transaction.

HF_I2C_CMD_DELAY 

Delay.

◆ hf_i2c_event_type_t

enum class hf_i2c_event_type_t : int
strong

ESP32 I2C event types.

Enumerator
HF_I2C_EVENT_MASTER_START 

Master start event.

HF_I2C_EVENT_MASTER_STOP 

Master stop event.

HF_I2C_EVENT_MASTER_WRITE 

Master write event.

HF_I2C_EVENT_MASTER_READ 

Master read event.

HF_I2C_EVENT_SLAVE_START 

Slave start event.

HF_I2C_EVENT_SLAVE_STOP 

Slave stop event.

HF_I2C_EVENT_SLAVE_WRITE 

Slave write event.

HF_I2C_EVENT_SLAVE_READ 

Slave read event.

HF_I2C_EVENT_ERROR 

Error event.

◆ hf_i2c_glitch_filter_t

enum class hf_i2c_glitch_filter_t : uint8_t
strong

ESP32 I2C glitch filter configuration.

Enumerator
HF_I2C_GLITCH_FILTER_0_CYCLES 

No glitch filter.

HF_I2C_GLITCH_FILTER_1_CYCLES 

1 cycle filter

HF_I2C_GLITCH_FILTER_2_CYCLES 

2 cycle filter

HF_I2C_GLITCH_FILTER_3_CYCLES 

3 cycle filter

HF_I2C_GLITCH_FILTER_4_CYCLES 

4 cycle filter

HF_I2C_GLITCH_FILTER_5_CYCLES 

5 cycle filter

HF_I2C_GLITCH_FILTER_6_CYCLES 

6 cycle filter

HF_I2C_GLITCH_FILTER_7_CYCLES 

7 cycle filter

◆ hf_i2c_mode_t

enum class hf_i2c_mode_t : uint8_t
strong

I2C operation mode - determines available APIs.

Note
ESP-IDF v5.5+ enforces strict separation between sync/async modes
Enumerator
HF_I2C_MODE_SYNC 

Sync mode: blocking operations only, no queue.

HF_I2C_MODE_ASYNC 

Async mode: non-blocking operations only, with queue.

◆ hf_i2c_power_mode_t

enum class hf_i2c_power_mode_t : uint8_t
strong

ESP32 I2C power mode configuration.

Enumerator
HF_I2C_POWER_MODE_NORMAL 

Normal power mode.

HF_I2C_POWER_MODE_LOW 

Low power mode.

HF_I2C_POWER_MODE_SLEEP 

Sleep mode.

◆ hf_i2c_transaction_type_t

enum class hf_i2c_transaction_type_t : uint8_t
strong

ESP32 I2C transaction types.

Enumerator
HF_I2C_TRANS_WRITE 

Write transaction.

HF_I2C_TRANS_READ 

Read transaction.

HF_I2C_TRANS_WRITE_READ 

Write-then-read transaction.

Variable Documentation

◆ HF_I2C_DEFAULT_FREQ_HZ

constexpr uint32_t HF_I2C_DEFAULT_FREQ_HZ = 100000
staticconstexpr

◆ HF_I2C_DEFAULT_TIMEOUT_MS

constexpr uint32_t HF_I2C_DEFAULT_TIMEOUT_MS = 1000
staticconstexpr

◆ HF_I2C_FAST_FREQ_HZ

constexpr uint32_t HF_I2C_FAST_FREQ_HZ = 400000
staticconstexpr

◆ HF_I2C_FAST_PLUS_FREQ_HZ

constexpr uint32_t HF_I2C_FAST_PLUS_FREQ_HZ = 1000000
staticconstexpr

◆ HF_I2C_FIFO_SIZE

constexpr uint32_t HF_I2C_FIFO_SIZE = 32
staticconstexpr

◆ HF_I2C_MAX_FREQ_HZ

constexpr uint32_t HF_I2C_MAX_FREQ_HZ = 1000000
staticconstexpr

◆ HF_I2C_MAX_PORTS

constexpr uint8_t HF_I2C_MAX_PORTS = 2
staticconstexpr

◆ HF_I2C_MAX_RETRY_COUNT

constexpr uint8_t HF_I2C_MAX_RETRY_COUNT = 3
staticconstexpr

◆ HF_I2C_MAX_TIMEOUT_MS

constexpr uint32_t HF_I2C_MAX_TIMEOUT_MS = 10000
staticconstexpr

◆ HF_I2C_MAX_TRANSFER_BYTES

constexpr uint32_t HF_I2C_MAX_TRANSFER_BYTES = 1024
staticconstexpr

◆ HF_I2C_MIN_FREQ_HZ

constexpr uint32_t HF_I2C_MIN_FREQ_HZ = 1000
staticconstexpr