aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBIGTREETECH <38851044+bigtreetech@users.noreply.github.com>2023-03-28 09:32:42 +0800
committerGitHub <noreply@github.com>2023-03-27 21:32:42 -0400
commitd518152ab27637c306eb1a275c5211e5fd5d2a2a (patch)
treee8d4a3801b755f24b00a797da1dce5f808323f56
parent346e3901f6076987bdb8a6ec391f00f07e5c45e2 (diff)
downloadkutter-d518152ab27637c306eb1a275c5211e5fd5d2a2a.tar.gz
kutter-d518152ab27637c306eb1a275c5211e5fd5d2a2a.tar.xz
kutter-d518152ab27637c306eb1a275c5211e5fd5d2a2a.zip
stm32: Enable I2C on stm32h7 (#6130)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
-rw-r--r--src/stm32/Kconfig2
-rw-r--r--src/stm32/Makefile1
-rw-r--r--src/stm32/stm32f0_i2c.c11
3 files changed, 13 insertions, 1 deletions
diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig
index 50db29d2..94384ec3 100644
--- a/src/stm32/Kconfig
+++ b/src/stm32/Kconfig
@@ -7,7 +7,7 @@ config STM32_SELECT
default y
select HAVE_GPIO
select HAVE_GPIO_ADC
- select HAVE_GPIO_I2C if !(MACH_STM32F031 || MACH_STM32H7)
+ select HAVE_GPIO_I2C if !(MACH_STM32F031)
select HAVE_GPIO_SPI if !MACH_STM32F031
select HAVE_GPIO_SDIO if MACH_STM32F4
select HAVE_GPIO_HARD_PWM if MACH_STM32F1 || MACH_STM32F4 || MACH_STM32G0 || MACH_STM32H7
diff --git a/src/stm32/Makefile b/src/stm32/Makefile
index 390ad8d5..fac9ed4a 100644
--- a/src/stm32/Makefile
+++ b/src/stm32/Makefile
@@ -57,6 +57,7 @@ src-$(CONFIG_MACH_STM32G4) += stm32/stm32f0_i2c.c
src-$(CONFIG_MACH_STM32H7) += ../lib/stm32h7/system_stm32h7xx.c
src-$(CONFIG_MACH_STM32H7) += stm32/stm32h7.c generic/armcm_timer.c
src-$(CONFIG_MACH_STM32H7) += stm32/gpioperiph.c stm32/stm32h7_adc.c
+src-$(CONFIG_MACH_STM32H7) += stm32/stm32f0_i2c.c
src-$(CONFIG_MACH_STM32L4) += ../lib/stm32l4/system_stm32l4xx.c
src-$(CONFIG_MACH_STM32L4) += stm32/stm32l4.c generic/armcm_timer.c
src-$(CONFIG_MACH_STM32L4) += stm32/gpioperiph.c
diff --git a/src/stm32/stm32f0_i2c.c b/src/stm32/stm32f0_i2c.c
index a37306e8..48c3ae3e 100644
--- a/src/stm32/stm32f0_i2c.c
+++ b/src/stm32/stm32f0_i2c.c
@@ -72,6 +72,13 @@ struct i2c_info {
DECL_CONSTANT_STR("BUS_PINS_i2c3_PC8_PC9", "PC8,PC9");
DECL_ENUMERATION("i2c_bus", "i2c3_PC8_PC11", 7);
DECL_CONSTANT_STR("BUS_PINS_i2c3_PC8_PC11", "PC8,PC11");
+#elif CONFIG_MACH_STM32H7
+ DECL_ENUMERATION("i2c_bus", "i2c1_PB6_PB7", 0);
+ DECL_CONSTANT_STR("BUS_PINS_i2c1_PB6_PB7", "PB6,PB7");
+ DECL_ENUMERATION("i2c_bus", "i2c1_PB8_PB9", 1);
+ DECL_CONSTANT_STR("BUS_PINS_i2c1_PB8_PB9", "PB8,PB9");
+ DECL_ENUMERATION("i2c_bus", "i2c2_PB10_PB11", 2);
+ DECL_CONSTANT_STR("BUS_PINS_i2c2_PB10_PB11", "PB10,PB11");
#endif
static const struct i2c_info i2c_bus[] = {
@@ -104,6 +111,10 @@ static const struct i2c_info i2c_bus[] = {
{ I2C2, GPIO('C', 4), GPIO('F', 0), GPIO_FUNCTION(4) },
{ I2C3, GPIO('C', 8), GPIO('C', 9), GPIO_FUNCTION(8) },
{ I2C3, GPIO('C', 8), GPIO('C', 11), GPIO_FUNCTION(8) },
+#elif CONFIG_MACH_STM32H7
+ { I2C1, GPIO('B', 6), GPIO('B', 7), GPIO_FUNCTION(4) },
+ { I2C1, GPIO('B', 8), GPIO('B', 9), GPIO_FUNCTION(4) },
+ { I2C2, GPIO('B', 10), GPIO('B', 11), GPIO_FUNCTION(4) },
#endif
};