drv_wm8994.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-07-02 thread-liu first version
  9. */
  10. #ifndef __DRV_WM8994_H__
  11. #define __DRV_WM8994_H__
  12. #include "board.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. enum{
  17. GET_ID,
  18. SET_FREQUENCE,
  19. SET_VOLUME,
  20. GET_VOLUME,
  21. SET_MUTE,
  22. SET_RESET,
  23. START_PLAY,
  24. SET_PLAY_TYPE,
  25. };
  26. /* codec device play type */
  27. #define DEVICE_NONE ((uint16_t)0x0000)
  28. #define OUTPUT_DEVICE_SPEAKER ((uint16_t)0x0001)
  29. #define OUTPUT_DEVICE_HEADPHONE ((uint16_t)0x0002)
  30. #define OUTPUT_DEVICE_BOTH ((uint16_t)0x0004)
  31. #define OUTPUT_DEVICE_AUTO ((uint16_t)0x0008)
  32. #define INPUT_DEVICE_DIGITAL_MICROPHONE_1 ((uint16_t)0x0010)
  33. #define INPUT_DEVICE_DIGITAL_MICROPHONE_2 ((uint16_t)0x0020)
  34. #define INPUT_DEVICE_INPUT_LINE_1 ((uint16_t)0x0040)
  35. #define INPUT_DEVICE_INPUT_LINE_2 ((uint16_t)0x0080)
  36. #define INPUT_DEVICE_DIGITAL_MIC1_MIC2 ((uint16_t)0x0100)
  37. /* volume levels values */
  38. #define DEFAULT_VOLMIN 0x00
  39. #define DEFAULT_VOLMAX 0xFF
  40. #define DEFAULT_VOLSTEP 0x04
  41. #define AUDIO_PAUSE 0
  42. #define AUDIO_RESUME 1
  43. /* Codec POWER DOWN modes */
  44. #define CODEC_PDWN_HW 1
  45. #define CODEC_PDWN_SW 2
  46. /* MUTE commands */
  47. #define AUDIO_MUTE_ON 1
  48. #define AUDIO_MUTE_OFF 0
  49. /* AUDIO FREQUENCY */
  50. #define AUDIO_FREQUENCY_192K ((uint32_t)192000)
  51. #define AUDIO_FREQUENCY_96K ((uint32_t)96000)
  52. #define AUDIO_FREQUENCY_48K ((uint32_t)48000)
  53. #define AUDIO_FREQUENCY_44K ((uint32_t)44100)
  54. #define AUDIO_FREQUENCY_32K ((uint32_t)32000)
  55. #define AUDIO_FREQUENCY_22K ((uint32_t)22050)
  56. #define AUDIO_FREQUENCY_16K ((uint32_t)16000)
  57. #define AUDIO_FREQUENCY_11K ((uint32_t)11025)
  58. #define AUDIO_FREQUENCY_8K ((uint32_t)8000)
  59. #define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 63) / 100)))
  60. #define VOLUME_IN_CONVERT(Volume) (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 240) / 100)))
  61. #define WM8994_ID 0x8994
  62. #define WM8994_CHIPID_ADDR 0x00
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif