boards/stm32: introduce and use shared i2c config with I2C1 on PB6/PB7#12141
Conversation
This configuration corresponds to I2C1 connected to PB6 (SCL) and PB7 (SDA)
|
Is this really an improvement with the need for those |
Regarding code readability, you are certainly right that ifdef are not the best. But regarding future boards addition that would need the same config, it makes things as simple as adding a single line in the peripheral configuration. |
|
Is I2C on PB6 & PB7 a common thing on nucleo boards/stm32l MCUs? I also see PB7 & PB8 used in e.g. |
I could see 2 for now + the iotlab boards. #12144 is also using the same. |
|
I think PB6/PB7 work due to the Arduino-compatibility of the L432KC/L412KB/L031K6/... boards. However, I found STM documentation on the I2C pins very confusing, there might be another setup that could work. However, I'm running I2C devices on these boards (with the L412KB being implemented as we're writing here) and they work with this config. Hence I didn't feel the need to investigate further. |
benpicco
left a comment
There was a problem hiding this comment.
Seeing now that we already have common/stm32/include/cfg_i2c1_pb8_pb9.h it makes sense to also include this.
I'm not particularly fond of this since it makes adding more interfaces to i2c_config harder, but as there precedent for it, I think it makes sense to add this for consistency.
Note that this file is just a default. If someone wants to use a different configuration on his nucleo, he can still copy the peripheral configuration file and modify it in the application directory. |
|
Just updated to master and found out that the I2C config I implemented was replaced by this PR. Could anyone explain to me how PB8 and PB9 is supposed to be used on the L432KC/L031K6? To put it simple: Where would I connect SCL and SDA? The config that was included as I2C config for these boards has the following connections defined: |

Contribution description
Following #12025 and #12068, this PR is factorizing the configuration for those boards since they are very similar.
iotlab-m3 could also use the new common file but that would first require to provide a shared clock configuration.
@mrusme has the hardware so maybe he could test and report his results here.
Testing procedure
Test an I2C device on nucleo-l031k6 and nucleo-l432kc
Issues/PRs references
Factorization of configurations introduced in #12025 and #12068.