mcu/stm32: Calculate I2C timing register #3112
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
STM32 F1,F4,L1 do have ClockSpeed filed in I2C initialization API, so it easy to specify requested clock speed for I2C. For all other devices ST HAL does not provide such field and expect that TIMINGR register value is precomputed. This value is specified in each BSP and is likely incorrect for some of them.
This change introduces hic_speed to MCUs that has timing register and function that computes timing register base on requested speed and system clock.
If timing register is specified in settings it is still being used to to configure I2C. If timing register setting is 0 hic_speed is used.