adac.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Squeezelite for esp32
  3. *
  4. * (c) Sebastien 2019
  5. * Philippe G. 2019, philippe_44@outlook.com
  6. *
  7. * This software is released under the MIT License.
  8. * https://opensource.org/licenses/MIT
  9. *
  10. */
  11. #include "freertos/FreeRTOS.h"
  12. #include "driver/i2s.h"
  13. #include "driver/i2c.h"
  14. typedef enum { ADAC_ON = 0, ADAC_STANDBY, ADAC_OFF } adac_power_e;
  15. struct adac_s {
  16. char *model;
  17. bool (*init)(char *config, int i2c_port_num, i2s_config_t *i2s_config, bool *mck);
  18. void (*deinit)(void);
  19. void (*power)(adac_power_e mode);
  20. void (*speaker)(bool active);
  21. void (*headset)(bool active);
  22. bool (*volume)(unsigned left, unsigned right);
  23. };
  24. extern const struct adac_s dac_tas57xx;
  25. extern const struct adac_s dac_tas5713;
  26. extern const struct adac_s dac_ac101;
  27. extern const struct adac_s dac_wm8978;
  28. extern const struct adac_s dac_external;
  29. int adac_init(char *config, int i2c_port);
  30. void adac_deinit(void);
  31. esp_err_t adac_write(int i2c_addr, uint8_t reg, uint8_t *data, size_t count);
  32. esp_err_t adac_write_byte(int i2c_addr, uint8_t reg, uint8_t val);
  33. esp_err_t adac_write_word(int i2c_addr, uint8_t reg, uint16_t val);
  34. uint8_t adac_read_byte(int i2c_addr, uint8_t reg);
  35. uint16_t adac_read_word(int i2c_addr, uint8_t reg);