SuperHouse / esp-open-rtos

Open source FreeRTOS-based ESP8266 software framework
BSD 3-Clause "New" or "Revised" License
1.52k stars 491 forks source link

i2c: revise timing calculation #582

Closed flannelhead closed 6 years ago

flannelhead commented 6 years ago

Look-up tables were used for determining the delay loop counts before. Based on these hand-tuned values, the loop overhead was estimated for each option -- 80 and 160 MHz, fast and slow GPIO access. Instead of the great number of tunable parameters one now only has to tune the overhead values if the code is changed.

Functions were added to the API which allow setting an arbitrary frequency. API backward compatibility is retained.

Zaltora commented 6 years ago

You tested if frequency signals are good for each option and frequency ? Nice update. I guess, this soft i2c library will be the best of the esp8266 ^^

flannelhead commented 6 years ago

@Zaltora: I tested with some configurations. Probably I should still check all the combinations (80MHz/register access, 80MHz/GPIO API, 160MHz/register access and 160MHz/GPIO API).

However, the formula that was introduced here produces the very same delay values that were hand-tuned and hardcoded before (if not even more precise!) The linear delay formula and coefficients are based on those hand-tuned values but the number of parameters is reduced.

UncleRus commented 6 years ago

Thank you!