Use DMA polling instead of TC/HT and USART IDLE interrupts for RX buffer updates #44
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.
It seems that using DMA TC/HC interrupts in conjunction with the USART IDLE interrupt for updating RX buffers head positions is a wrong strategy in the case of a USB to UART bridge.
Consider the following scenario: a low-speed device (say 2400, 9600 baud) connected to UART sends a steady stream of bytes. There are no gaps in transmission, so that the USART IDLE interrupt never triggers. On the other hand, since the RX buffers on bluepill-serial-monster are relatively large, the firmware will not send the content of the RX buffer to the host until DMA TC/HC triggers. While it does not lead to data loss, it creates a noticeable delay which can be critical for applications that rely on RX timing.
On the other hand, the firmware can only send the data to the host in the USB polling loop, so it makes perfect sense to update circular buffers there as well.
As a side effect, this change introduces a slight delay in the RTS signal handling. It looks like it should not be a problem, however this requires some additional testing.