I'm looking at the SDK15 I2S example project using DMA. My dev set up is 52840/Keil.
The project is under: \nRF5_SDK_15.0.0_a53641a\examples\peripheral\i2s
In the callback function which is called when DMA completes and the new buffer needs to be set, the data structure being set to i2s driver (nrf_drv_i2s_next_buffers_set) is not updated to use the alternating buffer but the same one. Lookes like DMA will keep using the same memory buffer every time. Is that a bug?
static void data_handler(nrf_drv_i2s_buffers_t const * p_released, uint32_t status) { // 'nrf_drv_i2s_next_buffers_set' is called directly from the handler // each time next buffers are requested, so data corruption is not // expected. ASSERT(p_released); // When the handler is called after the transfer has been stopped // (no next buffers are needed, only the used buffers are to be // released), there is nothing to do. if (!(status & NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED)) { return; } // First call of this handler occurs right after the transfer is started. // No data has been transferred yet at this point, so there is nothing to // check. Only the buffers for the next part of the transfer should be // provided. if (!p_released->p_rx_buffer) { nrf_drv_i2s_buffers_t const next_buffers = { .p_rx_buffer = m_buffer_rx[1], .p_tx_buffer = m_buffer_tx[1], }; APP_ERROR_CHECK(nrf_drv_i2s_next_buffers_set(&next_buffers)); mp_block_to_fill = m_buffer_tx[1]; } else { mp_block_to_check = p_released->p_rx_buffer; // The driver has just finished accessing the buffers pointed by // 'p_released'. They can be used for the next part of the transfer // that will be scheduled now. APP_ERROR_CHECK(nrf_drv_i2s_next_buffers_set(p_released)); // The pointer needs to be typecasted here, so that it is possible to // modify the content it is pointing to (it is marked in the structure // as pointing to constant data because the driver is not supposed to // modify the provided data). mp_block_to_fill = (uint32_t *)p_released->p_tx_buffer; } }