Skip to content
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

Async/DMA Peripheral Example Improvements & Doc Updates #1090

Open
BrentK-ADI opened this issue Jul 25, 2024 · 0 comments
Open

Async/DMA Peripheral Example Improvements & Doc Updates #1090

BrentK-ADI opened this issue Jul 25, 2024 · 0 comments

Comments

@BrentK-ADI
Copy link
Contributor

The example projects for many of the peripherals (such as SPI, I2C, UART, etc) which leverage the mxc__req_t struct utilize a single main() to do all of the functionality whether it be Blocking, Async or DMA. In a typical application Async and DMA functionality will typically be done, then function exits and the MCU does other work while the peripheral is running the in the background.

A problem with the examples is the request structure is on the stack for main(). This isn't a problem for the examples since main never exits, but should a user go create a real application, if the request structure is on the stack, once the function exits, there is a high chance the request data is corrupted due to the stack space being reused. The peripherals only store the pointer to the provided request, not make a copy. At a minimum the examples should be modified to move the request struct into global scope to get it off the stack with comments explaining why. Also, the peripheral documentation should be updated to indicate the structure needs to be preserved during the duration of the transaction.

Alternatively, the peripheral could make a copy of the request, but that may or may not be wasted memory usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant