-
Notifications
You must be signed in to change notification settings - Fork 89
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): Fix UART DMA Transactions and Enable Full Duplex #763
Conversation
Initialize state struct
Add MXC_DMA_CH_GET_IRQ for ME14
For readability I've applied these changes for the ME14. Will port after review. The Rev B and C UART drivers may also need these fixes. |
/clang-format-run |
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.
Looks good overall. Just a couple of minor comments we should discuss.
@@ -565,11 +622,24 @@ int MXC_UART_RevA_ReadRXFIFODMA(mxc_uart_reva_regs_t *uart, mxc_dma_regs_t *dma, | |||
return E_NULL_PTR; | |||
} | |||
|
|||
if (states[uart_num].auto_dma_handlers) { | |||
/* Acquire channel */ | |||
#if TARGET_NUM == 32665 |
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'd like to avoid part specific code in the _revX.c files. Can this condition be based on MXC_DMA_INSTANCES instead?
int MXC_UART_RevA_SetAutoDMAHandlers(mxc_uart_reva_regs_t *uart, bool enable) | ||
{ | ||
int n = MXC_UART_GET_IDX((mxc_uart_regs_t *)uart); | ||
if (n < 0) |
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.
These checks could be asserts. They are not really time critical, though, so I'll leave the final decision to you.
Thanks @lorne-maxim, updated in 831c893 |
int MXC_UART_RevA_SetTXDMAChannel(mxc_uart_reva_regs_t *uart, unsigned int channel) | ||
{ | ||
int n = MXC_UART_GET_IDX((mxc_uart_regs_t *)uart); | ||
if (n < 0) |
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.
Here is another place where ASSERT may be better. I see other places (not just in the code this PR touches) that could be ASSERTs also. IMO, anything that checks to see if a valid UART instance was passed in is better as an ASSERT.
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.
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.
@lorne-maxim I ended up purging the asserts except for once in the Init functions. The compiler should catch those cases as type-cast mismatch, so I think the checks for a valid UART instance in every function were overkill anyways...
It reduces our kid size pretty significantly, which is nice
Added API change tag for non-breaking additions of new functions |
Description
Our UART DMA transactions were essentially unusable, and only happened to work if the transaction function happened to acquire DMA channel 0.
This PR fixes #761
It implements 2 features:
DMA Auto Handlers
This behavior is disabled by default... but I would like to make this the default. Please comment.
Users now have the option to enable "auto handlers" for the UART DMA transactions with
When auto handlers are enabled, the drivers will automatically acquire a DMA channel, enable the IRQ, assign an internal handler function, then release the acquired channel when the transaction's finished. This makes UART DMA simpler to set up and use.
New APIs for Assigning DMA Channels
New APIs have been added for managing the UART DMA channels manually. The application code is responsible for acquiring a channel and assigning an appropriate handler. The application is also responsible for releasing the channel when necessary.
Checklist Before Requesting Review