Skip to content

Commit 92b68d5

Browse files
committed
feat(i2c_bus): support software i2c
1 parent 1d05c79 commit 92b68d5

File tree

14 files changed

+963
-156
lines changed

14 files changed

+963
-156
lines changed

.gitlab/ci/rules.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,8 @@
10771077
changes: *patterns-components_motor_esp_simplefoc
10781078
- <<: *if-dev-push
10791079
changes: *patterns-example_motor_foc_openloop_control
1080+
- <<: *if-dev-push
1081+
changes: *patterns-components_i2c_bus
10801082

10811083
.rules:build:example_motor_foc_velocity_control:
10821084
rules:
@@ -2041,6 +2043,8 @@
20412043
changes: *patterns-build_system
20422044
- <<: *if-dev-push
20432045
changes: *patterns-components_sensors_gesture_apds9960
2046+
- <<: *if-dev-push
2047+
changes: *patterns-components_i2c_bus
20442048

20452049
.rules:build:components_sensors_humiture_hdc2010_test_apps:
20462050
rules:
@@ -2052,6 +2056,8 @@
20522056
changes: *patterns-build_system
20532057
- <<: *if-dev-push
20542058
changes: *patterns-components_sensors_humiture_hdc2010
2059+
- <<: *if-dev-push
2060+
changes: *patterns-components_i2c_bus
20552061

20562062
.rules:build:components_sensors_humiture_hts221_test:
20572063
rules:
@@ -2074,6 +2080,8 @@
20742080
changes: *patterns-build_system
20752081
- <<: *if-dev-push
20762082
changes: *patterns-components_sensors_humiture_mvh3004d
2083+
- <<: *if-dev-push
2084+
changes: *patterns-components_i2c_bus
20772085

20782086
.rules:build:components_sensors_humiture_sht3x_test_apps:
20792087
rules:
@@ -2085,6 +2093,8 @@
20852093
changes: *patterns-build_system
20862094
- <<: *if-dev-push
20872095
changes: *patterns-components_sensors_humiture_sht3x
2096+
- <<: *if-dev-push
2097+
changes: *patterns-components_i2c_bus
20882098

20892099
.rules:build:components_sensors_imu_lis2dh12_test_apps:
20902100
rules:
@@ -2096,6 +2106,8 @@
20962106
changes: *patterns-build_system
20972107
- <<: *if-dev-push
20982108
changes: *patterns-components_sensors_imu_lis2dh12
2109+
- <<: *if-dev-push
2110+
changes: *patterns-components_i2c_bus
20992111

21002112
.rules:build:components_sensors_imu_mpu6050_test:
21012113
rules:
@@ -2129,6 +2141,8 @@
21292141
changes: *patterns-build_system
21302142
- <<: *if-dev-push
21312143
changes: *patterns-components_sensors_light_sensor_veml6040
2144+
- <<: *if-dev-push
2145+
changes: *patterns-components_i2c_bus
21322146

21332147
.rules:build:components_sensors_light_sensor_veml6075_test_apps:
21342148
rules:
@@ -2140,6 +2154,8 @@
21402154
changes: *patterns-build_system
21412155
- <<: *if-dev-push
21422156
changes: *patterns-components_sensors_light_sensor_veml6075
2157+
- <<: *if-dev-push
2158+
changes: *patterns-components_i2c_bus
21432159

21442160
.rules:build:components_sensors_pressure_bme280_test_apps:
21452161
rules:
@@ -2151,6 +2167,8 @@
21512167
changes: *patterns-build_system
21522168
- <<: *if-dev-push
21532169
changes: *patterns-components_sensors_pressure_bme280
2170+
- <<: *if-dev-push
2171+
changes: *patterns-components_i2c_bus
21542172

21552173
.rules:build:components_sensors_sensor_hub_test_apps:
21562174
rules:
@@ -2162,6 +2180,8 @@
21622180
changes: *patterns-build_system
21632181
- <<: *if-dev-push
21642182
changes: *patterns-components_sensors_sensor_hub
2183+
- <<: *if-dev-push
2184+
changes: *patterns-components_i2c_bus
21652185

21662186
.rules:build:components_spi_bus_test_apps:
21672187
rules:
@@ -2320,6 +2340,8 @@
23202340
changes: *patterns-components_sensors_power_monitor_ina236
23212341
- <<: *if-dev-push
23222342
changes: *patterns-components_bus
2343+
- <<: *if-dev-push
2344+
changes: *patterns-components_i2c_bus
23232345

23242346
.rules:build:components_i2c_bus_test_apps:
23252347
rules:

components/i2c_bus/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog
22

3+
## v1.2.0 - 2025-1-14
4+
5+
### Enhancements:
6+
7+
- Support enabling software I2C to extend the number of I2C ports.
8+
39
## v1.1.0 - 2024-11-22
410

511
### Enhancements:

components/i2c_bus/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ else()
66
set(REQ esp_driver_i2c driver)
77
endif()
88

9+
if (CONFIG_I2C_BUS_SUPPORT_SOFTWARE)
10+
list(APPEND SRC_FILE "i2c_bus_soft.c")
11+
endif()
12+
913
idf_component_register(SRCS ${SRC_FILE}
1014
INCLUDE_DIRS "include"
15+
PRIV_INCLUDE_DIRS "private_include"
1116
REQUIRES ${REQ})
17+
1218
include(package_manager)
1319
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})

components/i2c_bus/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ menu "Bus Options"
2525
depends on ESP_IDF_VERSION >= 5.3
2626
help
2727
Enable this option for backward compatibility with the old I2C driver
28+
29+
config I2C_BUS_SUPPORT_SOFTWARE
30+
bool "Enable software I2C support"
31+
default n
32+
help
33+
Enable this option to use a software-implemented I2C driver. This can be useful for scenarios where
34+
hardware I2C is unavailable or additional I2C buses are needed beyond the hardware support.
35+
36+
config I2C_BUS_SOFTWARE_MAX_PORT
37+
int "Maximum number of software I2C ports"
38+
default 2
39+
range 1 5
40+
depends on I2C_BUS_SUPPORT_SOFTWARE
41+
help
42+
Set the maximum number of software I2C ports that can be used. This option is only applicable when
43+
software I2C support is enabled.
2844
endmenu
2945

3046
endmenu

components/i2c_bus/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The I2C bus component (Bus) is a set of application-layer code built on top of t
66
1. Simplified peripheral initialization processes
77
2. Thread-safe device operations
88
3. Simple and flexible RW operations
9+
4. Compatible with `driver/i2c` and `esp_driver_i2c`
10+
5. Supports additional software I2C
911

1012
This component abstracts the following concepts:
1113

0 commit comments

Comments
 (0)