|
| typedef float | i2c_freq_t |
| | Type for I²C clock frequency in Hz.
|
| |
| typedef uint8_t | i2c_sda_t |
| | Type for I²C SDA pin number.
|
| |
| typedef uint8_t | i2c_scl_t |
| | Type for I²C SCL pin number.
|
| |
- Copyright
- Copyright (c) 2026 Adrien Chevrier. Under AGPL-3.0-or-later license.
ESP-IDF wrapper for default I²C master bus management.
Uses the new ESP-IDF I²C interface.
◆ I2C_MASTER_FREQ_HZ
| #define I2C_MASTER_FREQ_HZ (100000) |
I²C clock frequency in Hz.
◆ I2C_MASTER_NUM
| #define I2C_MASTER_NUM I2C_NUM_0 |
◆ I2C_MASTER_SCL_IO
| #define I2C_MASTER_SCL_IO (8) |
◆ I2C_MASTER_SDA_IO
| #define I2C_MASTER_SDA_IO (7) |
◆ i2c_freq_t
Type for I²C clock frequency in Hz.
◆ i2c_scl_t
Type for I²C SCL pin number.
◆ i2c_sda_t
Type for I²C SDA pin number.
◆ i2c_master_bus_deinit()
| void i2c_master_bus_deinit |
( |
i2c_bus_handle_t | bus | ) |
|
Deinitialize the I²C master bus.
Releases resources and frees memory associated with the bus handle.
- Parameters
-
| [in,out] | bus | Handle to the I²C bus to deinitialize. |
- Warning
- This function must run inside a critical section.
◆ i2c_master_bus_init()
Initialize an I²C master bus.
Configures the I²C controller with the given pins, port, and clock frequency.
- Parameters
-
| [in] | p | I²C port number. |
| [in] | d | SDA pin number. |
| [in] | c | SCL pin number. |
| [in] | f | Clock frequency. |
- Return values
-
| i2c_bus_handle_t | Handle to the initialized I²C bus. |
| NULL | On failure. |
- Note
- Must call
i2c_master_bus_deinit() to free resources later.
- Warning
- This function must run inside a critical section.
◆ i2c_master_bus_scan()
| esp_err_t i2c_master_bus_scan |
( |
i2c_bus_handle_t | bus | ) |
|
Scan for devices on the given I²C bus.
Logs detected device addresses.
- Parameters
-
| [in] | bus | Handle to the I²C bus. |
- Return values
-
| ESP_OK | On success. |
| ESP_ERR_INVALID_ARG | If any parameter is NULL. |