Skip to content

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

Merged
merged 2 commits into from Apr 17, 2018
Merged

Improve SPI block write #6607

merged 2 commits into from Apr 17, 2018

Conversation

khariya
Copy link
Contributor

@khariya khariya commented Apr 11, 2018

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

req.rx_data = (uint8_t *)(rx_buffer + tx_length);
req.len = rx_length - tx_length;
SPIM_Trans(obj->spi, &req);
}
Copy link
Contributor

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

Copy link
Contributor Author

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@0xc0170 0xc0170 Apr 13, 2018

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)

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments

0xc0170
0xc0170 previously approved these changes Apr 13, 2018
Copy link
Contributor

@0xc0170 0xc0170 left a 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.

Keyur Hariya added 2 commits April 13, 2018 15:14
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.
@khariya
Copy link
Contributor Author

khariya commented Apr 13, 2018

Commit message updated for spi block write.

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 16, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Apr 16, 2018

Build : SUCCESS

Build number : 1755
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6607/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Apr 16, 2018

@mbed-ci
Copy link

mbed-ci commented Apr 16, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 17, 2018

/morph mbed2-build

@cmonr cmonr merged commit df51196 into ARMmbed:master Apr 17, 2018
@khariya khariya deleted the max32630-fix-spi branch April 18, 2018 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants