Skip to content

Commit

Permalink
feat(i2c_bus): support software i2c
Browse files Browse the repository at this point in the history
  • Loading branch information
YanKE01 committed Jan 17, 2025
1 parent 1d05c79 commit 92b68d5
Show file tree
Hide file tree
Showing 14 changed files with 963 additions and 156 deletions.
22 changes: 22 additions & 0 deletions .gitlab/ci/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@
changes: *patterns-components_motor_esp_simplefoc
- <<: *if-dev-push
changes: *patterns-example_motor_foc_openloop_control
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:example_motor_foc_velocity_control:
rules:
Expand Down Expand Up @@ -2041,6 +2043,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_gesture_apds9960
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_sensors_humiture_hdc2010_test_apps:
rules:
Expand All @@ -2052,6 +2056,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_humiture_hdc2010
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_sensors_humiture_hts221_test:
rules:
Expand All @@ -2074,6 +2080,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_humiture_mvh3004d
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_sensors_humiture_sht3x_test_apps:
rules:
Expand All @@ -2085,6 +2093,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_humiture_sht3x
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_sensors_imu_lis2dh12_test_apps:
rules:
Expand All @@ -2096,6 +2106,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_imu_lis2dh12
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_sensors_imu_mpu6050_test:
rules:
Expand Down Expand Up @@ -2129,6 +2141,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_light_sensor_veml6040
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_sensors_light_sensor_veml6075_test_apps:
rules:
Expand All @@ -2140,6 +2154,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_light_sensor_veml6075
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_sensors_pressure_bme280_test_apps:
rules:
Expand All @@ -2151,6 +2167,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_pressure_bme280
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_sensors_sensor_hub_test_apps:
rules:
Expand All @@ -2162,6 +2180,8 @@
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-components_sensors_sensor_hub
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_spi_bus_test_apps:
rules:
Expand Down Expand Up @@ -2320,6 +2340,8 @@
changes: *patterns-components_sensors_power_monitor_ina236
- <<: *if-dev-push
changes: *patterns-components_bus
- <<: *if-dev-push
changes: *patterns-components_i2c_bus

.rules:build:components_i2c_bus_test_apps:
rules:
Expand Down
6 changes: 6 additions & 0 deletions components/i2c_bus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ChangeLog

## v1.2.0 - 2025-1-14

### Enhancements:

- Support enabling software I2C to extend the number of I2C ports.

## v1.1.0 - 2024-11-22

### Enhancements:
Expand Down
6 changes: 6 additions & 0 deletions components/i2c_bus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ else()
set(REQ esp_driver_i2c driver)
endif()

if (CONFIG_I2C_BUS_SUPPORT_SOFTWARE)
list(APPEND SRC_FILE "i2c_bus_soft.c")
endif()

idf_component_register(SRCS ${SRC_FILE}
INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "private_include"
REQUIRES ${REQ})

include(package_manager)
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})
16 changes: 16 additions & 0 deletions components/i2c_bus/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ menu "Bus Options"
depends on ESP_IDF_VERSION >= 5.3
help
Enable this option for backward compatibility with the old I2C driver

config I2C_BUS_SUPPORT_SOFTWARE
bool "Enable software I2C support"
default n
help
Enable this option to use a software-implemented I2C driver. This can be useful for scenarios where
hardware I2C is unavailable or additional I2C buses are needed beyond the hardware support.

config I2C_BUS_SOFTWARE_MAX_PORT
int "Maximum number of software I2C ports"
default 2
range 1 5
depends on I2C_BUS_SUPPORT_SOFTWARE
help
Set the maximum number of software I2C ports that can be used. This option is only applicable when
software I2C support is enabled.
endmenu

endmenu
2 changes: 2 additions & 0 deletions components/i2c_bus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The I2C bus component (Bus) is a set of application-layer code built on top of t
1. Simplified peripheral initialization processes
2. Thread-safe device operations
3. Simple and flexible RW operations
4. Compatible with `driver/i2c` and `esp_driver_i2c`
5. Supports additional software I2C

This component abstracts the following concepts:

Expand Down
Loading

0 comments on commit 92b68d5

Please sign in to comment.