aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/stm32f0_i2c.c
diff options
context:
space:
mode:
authorMatt Baker <baker.matt.j@gmail.com>2021-04-22 13:44:39 -0700
committerKevinOConnor <kevin@koconnor.net>2022-09-15 11:51:26 -0400
commitd9c917b95099617b32dfaca4ae90c9e2dd641fff (patch)
treea6a7adb3fec7d84a5fa0bbb75432a229b1ee7699 /src/stm32/stm32f0_i2c.c
parent57b0eb5d43e4324c2c52282925ddc63fc36df783 (diff)
downloadkutter-d9c917b95099617b32dfaca4ae90c9e2dd641fff.tar.gz
kutter-d9c917b95099617b32dfaca4ae90c9e2dd641fff.tar.xz
kutter-d9c917b95099617b32dfaca4ae90c9e2dd641fff.zip
stm32l4: add stm32l412 support with adc,i2c,spi,usb
Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
Diffstat (limited to 'src/stm32/stm32f0_i2c.c')
-rw-r--r--src/stm32/stm32f0_i2c.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/stm32/stm32f0_i2c.c b/src/stm32/stm32f0_i2c.c
index 4c68779d..418e1c1e 100644
--- a/src/stm32/stm32f0_i2c.c
+++ b/src/stm32/stm32f0_i2c.c
@@ -27,13 +27,21 @@ DECL_ENUMERATION("i2c_bus", "i2c1", 0);
DECL_CONSTANT_STR("BUS_PINS_i2c1", "PB6,PB7");
DECL_ENUMERATION("i2c_bus", "i2c1a", 1);
DECL_CONSTANT_STR("BUS_PINS_i2c1a", "PF1,PF0");
-#elif CONFIG_MACH_STM32G0
+
+#elif CONFIG_MACH_STM32G0 || CONFIG_MACH_STM32L4
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");
+#if CONFIG_MACH_STM32G0
+#define GPIO_AF_INDEX 6
DECL_ENUMERATION("i2c_bus", "i2c3_PB3_PB4", 2);
DECL_CONSTANT_STR("BUS_PINS_i2c3_PB3_PB4", "PB3,PB4");
+#elif CONFIG_MACH_STM32L4
+#define GPIO_AF_INDEX 4
+DECL_ENUMERATION("i2c_bus", "i2c3_PA7_PB4", 2);
+DECL_CONSTANT_STR("BUS_PINS_i2c3_PA7_PB4", "PA7,PB4");
+#endif
DECL_ENUMERATION("i2c_bus", "i2c2_PB10_PB11", 3);
DECL_CONSTANT_STR("BUS_PINS_i2c2_PB10_PB11", "PB10,PB11");
DECL_ENUMERATION("i2c_bus", "i2c2_PB13_PB14", 4);
@@ -47,13 +55,18 @@ static const struct i2c_info i2c_bus[] = {
{ I2C1, GPIO('B', 6), GPIO('B', 7), GPIO_FUNCTION(1) },
{ I2C1, GPIO('F', 1), GPIO('F', 0), GPIO_FUNCTION(1) },
{ I2C1, GPIO('B', 8), GPIO('B', 9), GPIO_FUNCTION(1) },
-#elif CONFIG_MACH_STM32G0
- { I2C1, GPIO('B', 6), GPIO('B', 7), GPIO_FUNCTION(6) },
- { I2C1, GPIO('B', 8), GPIO('B', 9), GPIO_FUNCTION(6) },
- { I2C3, GPIO('B', 3), GPIO('B', 4), GPIO_FUNCTION(6) },
- { I2C2, GPIO('B', 10), GPIO('B', 11), GPIO_FUNCTION(6) },
- { I2C2, GPIO('B', 13), GPIO('B', 14), GPIO_FUNCTION(6) },
- { I2C1, GPIO('A', 9), GPIO('A', 10), GPIO_FUNCTION(6) },
+
+#elif CONFIG_MACH_STM32G0 || CONFIG_MACH_STM32L4
+ { I2C1, GPIO('B', 6), GPIO('B', 7), GPIO_FUNCTION(GPIO_AF_INDEX) },
+ { I2C1, GPIO('B', 8), GPIO('B', 9), GPIO_FUNCTION(GPIO_AF_INDEX) },
+#if CONFIG_MACH_STM32G0
+ { I2C3, GPIO('B', 3), GPIO('B', 4), GPIO_FUNCTION(GPIO_AF_INDEX) },
+#elif CONFIG_MACH_STM32L4
+ { I2C3, GPIO('A', 7), GPIO('B', 4), GPIO_FUNCTION(GPIO_AF_INDEX) },
+#endif
+ { I2C2, GPIO('B', 10), GPIO('B', 11), GPIO_FUNCTION(GPIO_AF_INDEX) },
+ { I2C2, GPIO('B', 13), GPIO('B', 14), GPIO_FUNCTION(GPIO_AF_INDEX) },
+ { I2C1, GPIO('A', 9), GPIO('A', 10), GPIO_FUNCTION(GPIO_AF_INDEX) },
#endif
};