-
Notifications
You must be signed in to change notification settings - Fork 3k
Improve SPI block write #6607
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
Improve SPI block write #6607
Conversation
req.rx_data = (uint8_t *)(rx_buffer + tx_length); | ||
req.len = rx_length - tx_length; | ||
SPIM_Trans(obj->spi, &req); | ||
} |
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.
can you fix alignment for }
. this should be 4 spaces right. Line 180 should be 4 spaces right
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.
Indentation fixed at line 204.
char in = spi_master_write(obj, out); | ||
if (i < rx_length) { | ||
rx_buffer[i] = in; | ||
core_util_critical_section_enter(); |
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.
Why is this in critical section?
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.
Hardware limitation may cause data corruption if the TX fifo is allowed to run empty. The critical section ensures a transaction will complete without interruption.
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.
Hardware limitation may cause data corruption if the TX fifo is allowed to run empty. The critical section ensures a transaction will complete without interruption.
these type of details are worth in the commit msg. I imagine coming over and removing it like as the upper layer should take care of synchronization (this is however hw protection)
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.
See my comments
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.
LGTM
If you can add the detail to the commit msg about adding critical section to the spi block write.
Replace looping construct with actual block writes. Transaction in spi_master_block_write funtion is protected by critical section to ensure it is completed without interruption. A hardware limitation may cause data corruption if the TX fifo is allowed to run empty.
Commit message updated for spi block write. |
/morph build |
Build : SUCCESSBuild number : 1755 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1392 |
Test : SUCCESSBuild number : 1561 |
/morph mbed2-build |
Description
Improve SPI block write by replacing byte write loop with hardware assisted block transaction.
Tested all supported toolchains with MAX32630FTHR.
Pull request type
[X] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change