Reduce jitter for CRSF RC packets on the receiver #2943
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.

This PR is built on top of #2931 and should be merged after that.
Problem
As part of the serial framework refactor that happened some time ago... the sending of CRSF RC packets was moved to the main loop rather than after the packet was received. This move fixed an issue where ESP32 based receivers would crash because the UART was being accessed in the loop and in the interrupt handler.
The downside of moving the sending of the RC packet sending to the main loop is that it has created a bit of jitter in the timing.
Solution
noInterrupts()/interrupts().Funky Images
Before
This is an ESP8285 receiver sending the RC packets to the FC in the main loop.

The scope has been set to 5-second persistence to show the jitter.
This is an ESP32 receiver doing the same thing. The jitter is less but it's still there.

After
These images are after allowing the CRSF driver to send the RC packets in the "tock" interrupt.


As can be seen in these images, the jitter is significantly reduced as shown by the "Dev:" deviation value in the result panel at around 5us.
ESP8285 after
ESP32 after
Bonus Images
These images show the relationship of the interrupt "DIO" to the sending of CRSF RC packets after the PR is applied.




Also, in these images the result panel to the right shows the delay from receiving the interrupt to sending the RC data which is approx. 220us and the deviation "Dev:" which is approx 3us.
ESP8285 1000Hz
ESP32 1000Hz
ESP8285 150Hz
ESP32 150Hz