drv_es8388.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Date Author Notes
  7. * 2019-07-31 Zero-Free first implementation
  8. */
  9. #ifndef __DRV_ES8388_H__
  10. #define __DRV_ES8388_H__
  11. /* ES8388 register space */
  12. #define ES8388_CONTROL1 0x00
  13. #define ES8388_CONTROL2 0x01
  14. #define ES8388_CHIPPOWER 0x02
  15. #define ES8388_ADCPOWER 0x03
  16. #define ES8388_DACPOWER 0x04
  17. #define ES8388_CHIPLOPOW1 0x05
  18. #define ES8388_CHIPLOPOW2 0x06
  19. #define ES8388_ANAVOLMANAG 0x07
  20. #define ES8388_MASTERMODE 0x08
  21. #define ES8388_ADCCONTROL1 0x09
  22. #define ES8388_ADCCONTROL2 0x0a
  23. #define ES8388_ADCCONTROL3 0x0b
  24. #define ES8388_ADCCONTROL4 0x0c
  25. #define ES8388_ADCCONTROL5 0x0d
  26. #define ES8388_ADCCONTROL6 0x0e
  27. #define ES8388_ADCCONTROL7 0x0f
  28. #define ES8388_ADCCONTROL8 0x10
  29. #define ES8388_ADCCONTROL9 0x11
  30. #define ES8388_ADCCONTROL10 0x12
  31. #define ES8388_ADCCONTROL11 0x13
  32. #define ES8388_ADCCONTROL12 0x14
  33. #define ES8388_ADCCONTROL13 0x15
  34. #define ES8388_ADCCONTROL14 0x16
  35. #define ES8388_DACCONTROL1 0x17
  36. #define ES8388_DACCONTROL2 0x18
  37. #define ES8388_DACCONTROL3 0x19
  38. #define ES8388_DACCONTROL4 0x1a
  39. #define ES8388_DACCONTROL5 0x1b
  40. #define ES8388_DACCONTROL6 0x1c
  41. #define ES8388_DACCONTROL7 0x1d
  42. #define ES8388_DACCONTROL8 0x1e
  43. #define ES8388_DACCONTROL9 0x1f
  44. #define ES8388_DACCONTROL10 0x20
  45. #define ES8388_DACCONTROL11 0x21
  46. #define ES8388_DACCONTROL12 0x22
  47. #define ES8388_DACCONTROL13 0x23
  48. #define ES8388_DACCONTROL14 0x24
  49. #define ES8388_DACCONTROL15 0x25
  50. #define ES8388_DACCONTROL16 0x26
  51. #define ES8388_DACCONTROL17 0x27
  52. #define ES8388_DACCONTROL18 0x28
  53. #define ES8388_DACCONTROL19 0x29
  54. #define ES8388_DACCONTROL20 0x2a
  55. #define ES8388_DACCONTROL21 0x2b
  56. #define ES8388_DACCONTROL22 0x2c
  57. #define ES8388_DACCONTROL23 0x2d
  58. #define ES8388_DACCONTROL24 0x2e
  59. #define ES8388_DACCONTROL25 0x2f
  60. #define ES8388_DACCONTROL26 0x30
  61. #define ES8388_DACCONTROL27 0x31
  62. #define ES8388_DACCONTROL28 0x32
  63. #define ES8388_DACCONTROL29 0x33
  64. #define ES8388_DACCONTROL30 0x34
  65. enum es8388_mode
  66. {
  67. ES_MODE_NONE = 0x00,
  68. ES_MODE_DAC = 0x01,
  69. ES_MODE_ADC = 0x02,
  70. ES_MODE_DAC_ADC = 0x03,
  71. ES_MODE_LINE = 0x04,
  72. ES_MODE_MAX = 0x06,
  73. };
  74. enum es8388_format
  75. {
  76. ES_FMT_NORMAL = 0,
  77. ES_FMT_LEFT = 1,
  78. ES_FMT_RIGHT = 2,
  79. ES_FMT_DSP = 3,
  80. };
  81. rt_err_t es8388_init(const char *i2c_name, rt_uint16_t pin);
  82. rt_err_t es8388_start(enum es8388_mode mode);
  83. rt_err_t es8388_stop(enum es8388_mode mode);
  84. rt_err_t es8388_fmt_set(enum es8388_mode mode, enum es8388_format fmt);
  85. void es8388_volume_set(rt_uint8_t volume);
  86. rt_uint8_t es8388_volume_get(void);
  87. void es8388_pa_power(rt_bool_t enable);
  88. #endif