-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rx fifo latency fix #4328
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
Merged
Merged
Rx fifo latency fix #4328
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2400e74
Add a new resetmethod_menu_all macro to give the choice of all the re…
mribble 8fe2727
Change reset menu from all to extra. This gets rid of duplicated code
mribble 666de32
Merge with upstream
mribble 0cb9617
Fix boards.txt
mribble a4e1b91
Flush the rx fifo when checking available bytes in fifo. This gives …
mribble 0e04ea3
Merge branch 'master' into rx-fifo-latency-fix
devyte 42d4cb3
Merge branch 'master' of https://github.com/esp8266/Arduino
mribble f23c4b0
Merge branch 'master' of https://github.com/mribble/Arduino-1 into rx…
mribble aa16f80
Merge branch 'rx-fifo-latency-fix' of https://github.com/mribble/Ardu…
mribble d1d17d2
When rx_avaiable is checked return rx_buffer plus rx_fifo. Then duri…
mribble f4a62c0
Clean up early out case.
mribble 7d4f7e0
Merge branch 'master' into rx-fifo-latency-fix
mribble 0d3d43f
Merge branch 'master' of https://github.com/esp8266/Arduino into rx-f…
mribble 001be65
Merge branch 'rx-fifo-latency-fix' of https://github.com/mribble/Ardu…
mribble e97a9fa
Merge branch 'master' of https://github.com/esp8266/Arduino into rx-f…
mribble c527a76
Set the rx full fifo ISR to trigger a little sooner. This makes the …
mribble ff7983f
Merge branch 'master' into rx-fifo-latency-fix
devyte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use inverted logic. Instead, use direct logic to detect an early return or break, and leave the 3 lines of code free-standing after that.
E.g.:
if(nextPos == rpos)
return;
uint8_t data = ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the code would look like this:
'
inline void uart_rx_copy_fifo_to_buffer(uart_t* uart) {
while(uart_rx_fifo_available(uart)){
size_t nextPos = (uart->rx_buffer->wpos + 1) % uart->rx_buffer->size;
if(nextPos == uart->rx_buffer->rpos) {
// Stop copying if rx buffer is full
break;
}
uint8_t data = USF(uart->uart_nr);
uart->rx_buffer->buffer[uart->rx_buffer->wpos] = data;
uart->rx_buffer->wpos = nextPos;
}
}
'
I agree that code looks better, but I do have a concern. The line that initizes data with a value from the fifo also drains the fifo by 1 byte. So that line of code really can't be executed in the case we want to execute the break. I'm not sure if the compiler is allowed to rearrange that line to be before the if. If it can do that with any optimization level then we'd have a bug. So while it isn't quite as clean I'd suggest putting that code in an else (I can keep the current order though so the break is first). However, if you are sure this is legal then I can make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind. It's late and I was overthinking this. Of course a compile can't reorder this if it might affect results. I'll test this change with my test case and if it passes will push the change.