refactor(i2c): clean up i2c driver header file

remove unnecessary dependencies
This commit is contained in:
morris
2025-08-05 15:11:07 +08:00
parent 8a3aef7542
commit b8a5ebfa01
2 changed files with 9 additions and 20 deletions

View File

@@ -1,29 +1,20 @@
/* /*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#ifndef _DRIVER_I2C_H_ #pragma once
#define _DRIVER_I2C_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <esp_types.h>
#include "esp_err.h"
#include "esp_intr_alloc.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/semphr.h" #include "esp_types.h"
#include "freertos/task.h" #include "esp_err.h"
#include "freertos/queue.h" #include "esp_intr_alloc.h" // for intr_alloc_flags
#include "driver/gpio.h"
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "hal/i2c_types.h" #include "hal/i2c_types.h"
#if SOC_I2C_SUPPORT_APB #ifdef __cplusplus
#define I2C_APB_CLK_FREQ _Pragma ("GCC warning \"'I2C_APB_CLK_FREQ' macro is deprecated\"") (APB_CLK_FREQ) /*!< I2C source clock is APB clock, 80MHz, deprecated */ extern "C" {
#endif #endif
// I2C clk flags for users to use, can be expanded in the future. // I2C clk flags for users to use, can be expanded in the future.
@@ -630,5 +621,3 @@ esp_err_t i2c_get_data_mode(i2c_port_t i2c_num, i2c_trans_mode_t *tx_trans_mode,
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /*_DRIVER_I2C_H_*/

View File

@@ -106,9 +106,9 @@ static esp_err_t i2c_master_init(void)
i2c_config_t conf_master = { i2c_config_t conf_master = {
.mode = I2C_MODE_MASTER, .mode = I2C_MODE_MASTER,
.sda_io_num = I2C_SDA_GPIO, .sda_io_num = I2C_SDA_GPIO,
.sda_pullup_en = GPIO_PULLUP_ENABLE, .sda_pullup_en = true,
.scl_io_num = I2C_SCL_GPIO, .scl_io_num = I2C_SCL_GPIO,
.scl_pullup_en = GPIO_PULLUP_ENABLE, .scl_pullup_en = true,
.master.clk_speed = I2C_CLK_FREQUENCY, .master.clk_speed = I2C_CLK_FREQUENCY,
}; };