BlueI2S.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. I2SIn and I2SOut for Raspberry Pi Pico
  3. Implements one or more I2S interfaces using DMA
  4. Copyright (c) 2022 Earle F. Philhower, III <earlephilhower@yahoo.com>
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library 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 GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. */
  17. #pragma once
  18. class I2S {
  19. public:
  20. I2S();
  21. virtual ~I2S();
  22. bool setBCLK(pin_size_t pin);
  23. bool setDATA(pin_size_t pin);
  24. bool setBitsPerSample(int bps);
  25. bool setDivider(uint16_t div_int, uint8_t div_frac);
  26. uint getPioDreq();
  27. volatile void *getPioFIFOAddr();
  28. bool begin(PIO pio, uint sm);
  29. void end();
  30. private:
  31. pin_size_t _pinBCLK;
  32. pin_size_t _pinDOUT;
  33. uint16_t _div_int;
  34. uint8_t _div_frac;
  35. int _bps;
  36. bool _running;
  37. PIOProgram *_i2s;
  38. PIO _pio;
  39. int _sm;
  40. };