#3590·embassy

STM32 ring-buffer enhancement discussion

Author: elagilCreated Nov 28, 2024Updated Sep 28, 2026

This is a follow-up to the discussion in https://github.com/embassy-rs/embassy/pull/3336 by @liarokapisv

Feel free to add further people to the discussion.

Remaining issues/ideas with the current ring-buffer implementation include

  • clear() on overrun causes issues with higher-level drivers that handle data in groups of samples. For example, a SAI driver may handle data in groups of two samples (left/right). The ring-buffer has no concept of grouping, so on clear() it will cause random read/write index offsets - in the case of the SAI example, causing left/right switching. fixed by https://github.com/embassy-rs/embassy/pull/5469
  • Usefulness of write_immediate() is not clear, should it be removed?
  • The ring buffer may pause automatically on overrun. The ring buffer shall then be explicitly restarted by a user when new data is available.