diff options
Diffstat (limited to 'src/stm32/stm32f0_i2c.c')
-rw-r--r-- | src/stm32/stm32f0_i2c.c | 29 |
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 }; |