This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How can i port this i2s code to the new nrfx i2s api?

https://github.com/takafuminaka/nRF52832/blob/master/i2s_ws2812b_demostration_planB/i2s_ws2812b_drive/i2s_ws2812b_drive.c

I read the documentation, but didn't really grasp how to use nrf_drv_i2s_next_buffers_set() or the approrpriate usage of NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED

  • Take a look at the function data_handler() inside main.c in the i2s example (located in nRF5_SDK_15.3.0_59ac345\examples\peripheral\i2s) where the function nrf_drv_i2s_next_buffers_set(..) is used.

    Best regards,

    Simon

  • I should have mentioned that I already looked at the example code. It's a bit too cluttered in there for me to tell what's going on. I even did a diff between the example from the last sdk version before the change that added nrf_drv_i2s_next_buffers_set.

  • I am not too familiar with the i2s bus interface, and I tried to read up on it. However it was quite complex and I did not grasp it fully enough to give you a satisfying answer. However I would recommend you to use some time and really understand stuff from the bottom up. I would approach it in the following manner:

    • Start by reading about the i2s peripheral and understand how it works in and out
    • Take a look at the irq handler (nrfx_i2s_irq_handler(..)) in nrfx_i2s.c
      • This handler will call the data_handler(..) function in main.c (through m_cb.handler) and the data_handler(..) function calls nrf_drv_i2s_next_buffers_set(..)
      • In this function there is a lot of comments, that explains how it works
    • Look at the explanatory text above nrfx_i2s_next_buffers_set() inside nrfx_i2s.h and the explanatory text below the macro NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED inside nrfx_i2s.h
    • Use a logic analyzer and look at the different signals and compare them to the ones in the i2s peripheral documentation, also you could create a spike using a GPIO whenever nrf_drv_i2s_next_buffers_set() is called and check when this happens

    If you've done all this and are still confused, please inform me about what you understand so far and what you're confused about, and I will put off some time to read up, and see if I can help you progress.

    Best regards,

    Simon

  • I ended up adopting a different approach, since I only needed the first transfer.

Related