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.
This PR review I2C speed for series requiring I2C timing calculation
Currently:
Previously, I2C timing value for the
TIMINGRregister was hard coded for a specific I2C clock source configuration which was wrong for several target.This PR provides dynamic calculation of this value depending of the I2C clock sources.
As this calculation of all timing values can consume huge time. By default, only the first 8 valid timing will be computed:
It can be redefined thanks the
variant.horbuild_opt.horhal_conf_extra.husing:I2C_VALID_TIMING_NBRHigher number ensure lowest clock error but require more time to compute depending of the board.
Moreover, to avoid time spent to compute the I2C timing, it can be defined in the
variant.horbuild_opt.horhal_conf_extra.hwith:I2C_TIMING_SMfor Standard Mode (100kHz)I2C_TIMING_FMfor Fast Mode (400kHz)I2C_TIMING_FMPfor Fast Mode Plus (1000kHz)Example
For a STM32F0xx using
HSIclock as I2C clock source, in variant.h:Tests results:
One board per series was tested.
Hardware:
The CI test shield was used to test I2C speed.
It includes two I2C components:
Software:
Sketch performs an I2C scan at 100kHz and 400kHz, Read/write on EEPROM at 400kHz and Read temperature at 100kHz and 400kHz for all possible I2C clock source.
Fix #507
Wiki:
https://github.com/stm32duino/wiki/wiki/Custom-definitions#i2c-timing
/CC @geosmall