From 24fbae1a336f99c5999853036176c0a91708f6b5 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 | 8 +++++++- bsp/esp_bsp_generic/include/bsp/esp_bsp_generic.h | 2 ++ bsp/esp_bsp_generic/src/esp_bsp_generic.c | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bsp/esp_bsp_generic/Kconfig b/bsp/esp_bsp_generic/Kconfig index 16146a84..80ac0a27 100644 --- a/bsp/esp_bsp_generic/Kconfig +++ b/bsp/esp_bsp_generic/Kconfig @@ -21,7 +21,13 @@ menu "Board Support Package (generic)" help The GPIO pin for I2C SDA. endmenu - config BSP_I2C_NUM + config BSP_I2C_PULLUP + bool "I2C GPIO PULL UP" + default n + help + Enable I2C bus pull up. + + config BSP_I2C_NUM int "I2C peripheral index" default 1 range 0 1 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..40e3bdc5 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_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));