ESP32 Family: Add multiple transctions to SPI for improved efficency #7686
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.
While doing some other work with my Saleae, I noticed large SPI transfers had a gap every 4Kb for about 300 microseconds. Over larger transfers this delay adds up and becomes more apparent the faster the SPI frequency as the delay is constant vs frequency.
This PR adds multiple transaction queuing. The current implementation sends 1 transaction at a time. In the linked IDF example it shows how to include multiple transactions. This basically eliminates the delay (it drops to 14 microseconds).
The only downside I have found is you go from one SPI transaction in memory to 10, each transaction is 34 bytes so not a large increase.
For example:
At 80Mhz for a 100 KB transfer the ideal transfer time is 10 milliseconds. The current 300 microsecond delay every 4KB results in a total delay of ~7.2 milliseconds resulting in a total time of 17.2 milliseconds. Almost double the expected time.
At 10Mhz for a 100KB transfer the ideal transfer time is 80 milliseconds. The added 7.2 milliseconds delay for 100KB results in 87.2 milliseconds, almost 10% more then expected.
The most obvious example of the speedup having a positive effect will be in SPI graphic displays (including displayio), But any large SPI transfer will see a speedup, and the faster the frequency the more apparent.
The current transaction buffer size of 10 was arbitrarily chosen.