Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implement readRect to avoid RX FIFO overflow #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mudaltsov
Copy link

This fixes #29

The implementation of readRect had an issue where it would not correctly read
the last pixel from the screen. This was caused by an overflow in the RX FIFO
while waiting for the EOQ flag in the last transmitted byte. The loop only
counted transmitted bytes, so it would fill up the TX FIFO and not wait until
the transfer actually happened. Waiting for EOQ competed the queued transfers
and overflowed the RX FIFO since nothing was reading from it.

The new implementation explicitly tracks the number of RX and TX bytes to
ensure that all bytes are correctly transmitted and received. A few ideas
have been borrowed from KurtE/ILI9341_t3n as well:

  • Each byte is received independently and stored in a 3-byte array, which is
    converted and written to the buffer once all 3 colors have been received.
  • The TX FIFO is kept full throughout the function to avoid the delay between
    the dummy byte and the first pixel byte. Instead of using EOQ for the dummy
    byte, the results from queued commands and the dummy byte are skipped.

This fixes PaulStoffregen#29

The implementation of readRect had an issue where it would not correctly read
the last pixel from the screen. This was caused by an overflow in the RX FIFO
while waiting for the EOQ flag in the last transmitted byte. The loop only
counted transmitted bytes, so it would fill up the TX FIFO and not wait until
the transfer actually happened. Waiting for EOQ competed the queued transfers
and overflowed the RX FIFO since nothing was reading from it.

The new implementation explicitly tracks the number of RX and TX bytes to
ensure that all bytes are correctly transmitted and received. A few ideas
have been borrowed from KurtE/ILI9341_t3n as well:
* Each byte is received independently and stored in a 3-byte array, which is
  converted and written to the buffer once all 3 colors have been received.
* The TX FIFO is kept full throughout the function to avoid the delay between
  the dummy byte and the first pixel byte. Instead of using EOQ for the dummy
  byte, the results from queued commands and the dummy byte are skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Off-by-one bug in readRect
2 participants