-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix(PeriphDrivers): Resolve incorrect DMA request in DMA-based SPI transactions for all parts #1059
fix(PeriphDrivers): Resolve incorrect DMA request in DMA-based SPI transactions for all parts #1059
Conversation
…sterTransactionDMA
…aveTransactionDMA
…laveTransactionDMA
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.
Thank you for your very nice PR.
Can confirm you've caught some copy/paste typos on the mismatched reqsel values.
The AI87 values are also swapped if you wouldn't mind fixing that as well.
} | ||
switch (spi_num) { | ||
case 0: | ||
reqselTx = MXC_DMA_REQUEST_SPI1TX; |
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.
AI87 implementation has SPI0/SPI1 swapped as well. Should be reqselTx = MXC_DMA_REQUEST_SPI0TX;
here.
Not your fault, this was there before your fix.
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.
I believe the original implementation was correct. SPI0 and SPI1 are swapped in several places as an unfortunate result of incorrect documentation, and it's been stuck like that ever since to prevent breaking projects... It's why we have messes like this for the ME17, AI85, and AI87.
I say we fix this even if it might break existing projects. Usually, instance 0 is mapped to the lowest peripheral address, and then everything goes in ascending order:
- SPI0 (APB) - 0x40046000
- SPI1 (APB) - 0x40047000
- SPI[n] (APB) - 0x4004m000
- SPI[n+1] (AHB) - 0x400BE000
- SPI[n+2] (AHB) - 0x400BE400
However, the ME17, AI85, and AI87 doesn't follow this:
- SPI0 (AHB) - 0x400BE000
- SPI1 (APB) - 0x40046000
This has caused confusion, but it'll be a major breaking change to swap the SPI instance names. Instead, we can fix the MXC_SPI_GET_*
definitions in the {device}.h file where SPI0 would be associated with index 0, and SPI1 with index 1. This would still be a breaking change, but it would at least help keep all the indexing aligned with the correct SPI names.
What do you think? @Jake-Carter & @lorne-maxim
…d SPI transaction
Thanks for the review! |
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.
Thanks @JeonChangmin, no this is good. Looks like the same mistake got copy/pasted across the drivers since the ME12.
Description
This pull request addresses an issue in the DMA-based SPI transaction implementation where the DMA request would not be executed under specific conditions.
Problem Details
Issue: When
MXC_SPI_MasterTransactionDMA
is called withtxData == NULL
andrxData != NULL
inSPI_WIDTH_STANDARD
(full duplex) mode, the function setsreqselTx
to-1
. However, inMXC_SPI_RevA1_MasterTransactionDMA
,MXC_SPI_RevA1_TransSetup
may additionally settxData
based on the request. This leads to the use of an invalid request selector, causing the DMA to not be executed and resulting in an infinite wait state.Call Stack:
reqselTx
andreqselRx
based on the device and data presence.MXC_SPI_RevA1_TransSetup
to configure the request, potentially modifyingreq
to include both Tx and Rx data.Solution
reqselRx
andreqselTx
values fromMXC_SPI_MasterTransactionDMA
.MXC_SPI_RevA1_MasterTransactionDMA
after executingMXC_SPI_RevA1_TransSetup
.Additional Fixes
MXC_SPI_SlaveTransactionDMA
.reqselRx
andreqselTx
values in spi_me11.c and spi_me18.c files. Please confirm if this change was intended. (fix in this PR)Tests
spi_me17.c
as a basis.Checklist Before Requesting Review