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

feat: nrf52/pdm+saadc: Add zero-copy, dynamic double buffered continuous sampling #2486

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

trueb2
Copy link

@trueb2 trueb2 commented Jan 27, 2024

This adds a pdm_continuous_zero_copy example and fixes documentation in the pdm_continuous example. I left the existing interface because it is easier to use and looks safer despite the timing issues.

I use this with embedded-alloc TlfsHeap to do math that may take longer than the amount of time to fill a buffer. With the Vec interface, I can zero-copy send the owned data to a channel and receive the owned data on a lowest priority executor task.

I could add the embedded-alloc crate and dynamic allocation to this example, but static buffers are sufficient to use the API.

Comment on lines 392 to 397
/// SAFTEY:
/// It is expected that the caller will set the length to non-zero and re-use the same
/// length and capacity for each buffer. Changing buffer sizes is not supported.
///
/// At least one buffer will still be allocated when the function returns. The caller
/// should call free it to prevent leaks.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it makes sense to add some assertions to ensure this invariant is met? (Non-zero at least).

ALso SAFTEY -> SAFETY

@trueb2 trueb2 changed the title feat: nrf52/pdm: Add zero-copy, dynamic double buffered continuous sampling feat: nrf52/pdm+saadc: Add zero-copy, dynamic double buffered continuous sampling Nov 13, 2024
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

Successfully merging this pull request may close these issues.

2 participants