1 /*
2  * Copyright 2017-2020 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef _FSL_WM8524_H_
9 #define _FSL_WM8524_H_
10 
11 #include "fsl_common.h"
12 
13 /*!
14  * @addtogroup wm8524
15  * @ingroup codec
16  * @{
17  */
18 
19 /*******************************************************************************
20  * Definitions
21  ******************************************************************************/
22 /*! @name Driver version */
23 /*@{*/
24 /*! @brief WM8524 driver version 2.1.1. */
25 #define FSL_WM8524_DRIVER_VERSION (MAKE_VERSION(2, 1, 1))
26 /*@}*/
27 
28 /*!< mute control io function pointer */
29 typedef void (*wm8524_setMuteIO)(uint32_t output);
30 /*!< format control io function pointer */
31 typedef void (*wm8524_setProtocolIO)(uint32_t output);
32 
33 /*! @brief The audio data transfer protocol. */
34 typedef enum _wm8524_protocol
35 {
36     kWM8524_ProtocolLeftJustified  = 0x0, /*!< Left justified mode */
37     kWM8524_ProtocolI2S            = 0x1, /*!< I2S mode */
38     kWM8524_ProtocolRightJustified = 0x2, /*!< Right justified mode */
39 } wm8524_protocol_t;
40 
41 /*! @brief wm8524 mute operation */
42 enum _wm8524_mute_control
43 {
44     kWM8524_Mute   = 0U, /*!< mute left and right channel DAC */
45     kWM8524_Unmute = 1U, /*!< unmute left and right channel DAC */
46 };
47 
48 /*!< @brief WM8524 configurations */
49 typedef struct _wm8524_config
50 {
51     wm8524_setMuteIO setMute;         /*!< mute io control function pointer */
52     wm8524_setProtocolIO setProtocol; /*!< format io control function pointer */
53     wm8524_protocol_t protocol;       /*!< Protocol of the codec */
54 } wm8524_config_t;
55 
56 /*!@brief WM8524 handler */
57 typedef struct _wm8524_handle_t
58 {
59     wm8524_config_t *config; /*!< wm8524 config pointer */
60 } wm8524_handle_t;
61 /*******************************************************************************
62  * API
63  ******************************************************************************/
64 #if defined(__cplusplus)
65 extern "C" {
66 #endif
67 
68 /*!
69  * @brief Initializes WM8524.
70  *
71  * @param handle WM8524 handle structure.
72  * @param config WM8524 configure structure.
73  * @return kStatus_Success.
74  */
75 status_t WM8524_Init(wm8524_handle_t *handle, wm8524_config_t *config);
76 
77 /*!
78  * @brief Configure WM8524 audio protocol.
79  *
80  * @param handle WM8524 handle structure.
81  * @param protocol WM8524 configuration structure.
82  */
83 void WM8524_ConfigFormat(wm8524_handle_t *handle, wm8524_protocol_t protocol);
84 
85 /*!
86  * @brief Sets the codec mute state.
87  *
88  * @param handle WM8524 handle structure.
89  * @param isMute true means mute, false means normal.
90  */
91 void WM8524_SetMute(wm8524_handle_t *handle, bool isMute);
92 
93 #if defined(__cplusplus)
94 }
95 #endif
96 
97 /*! @} */
98 #endif /* _FSL_WM8524_H_ */
99