audio_i2s.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (C) 2023 saybur
  3. * Copyright (C) 2024-2025 Rabbit Hole Computing™
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  16. **/
  17. #pragma once
  18. #ifdef ENABLE_AUDIO_OUTPUT_I2S
  19. #include <stdint.h>
  20. // i2s PIO settings
  21. #define I2S_PIO_HW pio2_hw
  22. #define I2S_PIO_SM 0
  23. // audio subsystem DMA channels
  24. #define SOUND_DMA_CHA 6
  25. #define SOUND_DMA_CHB 7
  26. // size of the two audio sample buffers, in bytes
  27. // #define AUDIO_BUFFER_SIZE 8192 // reduce memory usage
  28. #define AUDIO_BUFFER_SIZE 2352 * 12
  29. /**
  30. * Indicates if the audio subsystem is actively streaming, including if it is
  31. * sending silent data during sample stall events.
  32. *
  33. * \return true if audio streaming is active, false otherwise.
  34. */
  35. bool audio_is_active();
  36. /**
  37. * Initializes the audio subsystem. Should be called only once, toward the end
  38. * of platform_late_init().
  39. */
  40. void audio_setup();
  41. /**
  42. * Called from platform_poll() to fill sample buffer(s) if needed.
  43. */
  44. void audio_poll();
  45. extern "C" void audio_dma_irq();
  46. #endif // ENABLE_AUDIO_OUTPUT_SPDIF