feat(i2s): support asynchronous read write via callback

Split the TX DMA buffer `auto_clear` into `auto_clear_after_cb` and `auto_clear_before_cb`,
so that allow user to update the DMA buffer directly in the `on_sent` callback
This commit is contained in:
laokaiyao
2024-03-27 11:37:51 +08:00
parent fcd1f1c808
commit fd27cef045
4 changed files with 119 additions and 18 deletions

View File

@@ -97,7 +97,8 @@ typedef struct {
uint32_t desc_num; /*!< I2S DMA buffer number, it is also the number of DMA descriptor */
uint32_t frame_num; /*!< I2S frame number in one DMA buffer. One frame means one-time sample data in all slots */
uint32_t buf_size; /*!< dma buffer size */
bool auto_clear; /*!< Set to auto clear DMA TX descriptor, i2s will always send zero automatically if no data to send */
bool auto_clear_after_cb; /*!< Set to auto clear DMA TX descriptor after callback, i2s will always send zero automatically if no data to send */
bool auto_clear_before_cb; /*!< Set to auto clear DMA TX descriptor before callback, i2s will always send zero automatically if no data to send */
uint32_t rw_pos; /*!< reading/writing pointer position */
void *curr_ptr; /*!< Pointer to current dma buffer */
void *curr_desc; /*!< Pointer to current dma descriptor used for pre-load */