From ae27344fe9a45d49ef5e1e0b83e9d0e14bb18715 Mon Sep 17 00:00:00 2001 From: Adam Kaliszan Date: Sat, 11 Jan 2025 20:46:59 +0100 Subject: [PATCH] BSP optional I2C pull up --- bsp/esp_bsp_generic/Kconfig | 5 +++++ bsp/esp_bsp_generic/include/bsp/esp_bsp_generic.h | 2 ++ bsp/esp_bsp_generic/src/esp_bsp_generic.c | 1 + 3 files changed, 8 insertions(+) diff --git a/bsp/esp_bsp_generic/Kconfig b/bsp/esp_bsp_generic/Kconfig index 16146a84..1a73d0e7 100644 --- a/bsp/esp_bsp_generic/Kconfig +++ b/bsp/esp_bsp_generic/Kconfig @@ -20,6 +20,11 @@ menu "Board Support Package (generic)" range -1 ENV_GPIO_OUT_RANGE_MAX help The GPIO pin for I2C SDA. + config BSP_I2C_GPIO_PULLUP + bool "I2C GPIO PULL UP" + default n + help + Enable I2C bus pull up. endmenu config BSP_I2C_NUM int "I2C peripheral index" diff --git a/bsp/esp_bsp_generic/include/bsp/esp_bsp_generic.h b/bsp/esp_bsp_generic/include/bsp/esp_bsp_generic.h index c213333a..fc3639f1 100644 --- a/bsp/esp_bsp_generic/include/bsp/esp_bsp_generic.h +++ b/bsp/esp_bsp_generic/include/bsp/esp_bsp_generic.h @@ -50,6 +50,8 @@ /* I2C */ #define BSP_I2C_SCL (CONFIG_BSP_I2C_GPIO_SCL) #define BSP_I2C_SDA (CONFIG_BSP_I2C_GPIO_SDA) +#define BSP_I2C_PULLUP (CONFIG_BSP_I2C_GPIO_PULLUP) + /* SD card */ #define BSP_SD_CMD (CONFIG_BSP_SD_CMD) diff --git a/bsp/esp_bsp_generic/src/esp_bsp_generic.c b/bsp/esp_bsp_generic/src/esp_bsp_generic.c index 50d464a8..6609df1b 100644 --- a/bsp/esp_bsp_generic/src/esp_bsp_generic.c +++ b/bsp/esp_bsp_generic/src/esp_bsp_generic.c @@ -324,6 +324,7 @@ esp_err_t bsp_i2c_init(void) .sda_io_num = BSP_I2C_SDA, .scl_io_num = BSP_I2C_SCL, .clk_source = I2C_CLK_SRC_DEFAULT, + .flags.enable_internal_pullup = BSP_I2C_PULLUP, }; BSP_ERROR_CHECK_RETURN_ERR(i2c_new_master_bus(&i2c_config, &i2c_handle));