diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/components/codec/ak4497/fsl_ak4497.h')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/components/codec/ak4497/fsl_ak4497.h | 447 |
1 files changed, 447 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/codec/ak4497/fsl_ak4497.h b/lib/chibios-contrib/ext/mcux-sdk/components/codec/ak4497/fsl_ak4497.h new file mode 100644 index 000000000..fc5a28b76 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/components/codec/ak4497/fsl_ak4497.h | |||
@@ -0,0 +1,447 @@ | |||
1 | /* | ||
2 | * Copyright 2018-2019 NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * SPDX-License-Identifier: BSD-3-Clause | ||
6 | */ | ||
7 | |||
8 | #ifndef _FSL_AK4497_H_ | ||
9 | #define _FSL_AK4497_H_ | ||
10 | |||
11 | #include "fsl_common.h" | ||
12 | #include "fsl_codec_i2c.h" | ||
13 | /*! | ||
14 | * @addtogroup ak4497 | ||
15 | * @{ | ||
16 | */ | ||
17 | |||
18 | /******************************************************************************* | ||
19 | * Definitions | ||
20 | ******************************************************************************/ | ||
21 | /*! @name Driver version */ | ||
22 | /*@{*/ | ||
23 | /*! @brief CLOCK driver version 2.1.2 */ | ||
24 | #define FSL_AK4497_DRIVER_VERSION (MAKE_VERSION(2, 1, 2)) | ||
25 | /*@}*/ | ||
26 | |||
27 | /*! @brief ak4497 handle size */ | ||
28 | #ifndef AK4497_I2C_HANDLER_SIZE | ||
29 | #define AK4497_I2C_HANDLER_SIZE CODEC_I2C_MASTER_HANDLER_SIZE | ||
30 | #endif | ||
31 | |||
32 | /*! @brief define the registers offset of AK4497. */ | ||
33 | #define AK4497_CONTROL1 (0x00U) | ||
34 | #define AK4497_CONTROL2 (0x01U) | ||
35 | #define AK4497_CONTROL3 (0x02U) | ||
36 | #define AK4497_LCHATT (0x03U) | ||
37 | #define AK4497_RCHATT (0x04U) | ||
38 | #define AK4497_CONTROL4 (0x05U) | ||
39 | #define AK4497_DSD1 (0x06U) | ||
40 | #define AK4497_CONTROL5 (0x07U) | ||
41 | #define AK4497_SOUNDCONTROL (0x08U) | ||
42 | #define AK4497_DSD2 (0x09U) | ||
43 | #define AK4497_CONTROL7 (0x0AU) | ||
44 | #define AK4497_CONTROL8 (0x0BU) | ||
45 | #define AK4497_DFSREAD (0x15U) | ||
46 | /*! @brief define BIT info of AK4497. */ | ||
47 | #define AK4497_CONTROL1_RSTN_MASK (0x1U) | ||
48 | #define AK4497_CONTROL1_RSTN_SHIFT (0U) | ||
49 | #define AK4497_CONTROL1_DIF0_MASK (0x2U) | ||
50 | #define AK4497_CONTROL1_DIF0_SHIFT (1U) | ||
51 | #define AK4497_CONTROL1_DIF1_MASK (0x4U) | ||
52 | #define AK4497_CONTROL1_DIF1_SHIFT (2U) | ||
53 | #define AK4497_CONTROL1_DIF2_MASK (0x8U) | ||
54 | #define AK4497_CONTROL1_DIF2_SHIFT (3U) | ||
55 | #define AK4497_CONTROL1_AFSD_MASK (0x10U) | ||
56 | #define AK4497_CONTROL1_AFSD_SHIFT (4U) | ||
57 | #define AK4497_CONTROL1_ECS_MASK (0x20U) | ||
58 | #define AK4497_CONTROL1_ECS_SHIFT (5U) | ||
59 | #define AK4497_CONTROL1_EXDF_MASK (0x40U) | ||
60 | #define AK4497_CONTROL1_EXDF_SHIFT (6U) | ||
61 | #define AK4497_CONTROL1_ACKS_MASK (0x80U) | ||
62 | #define AK4497_CONTROL1_ACKS_SHIFT (7U) | ||
63 | |||
64 | #define AK4497_CONTROL2_SMUTE_MASK (0x1U) | ||
65 | #define AK4497_CONTROL2_SMUTE_SHIFT (0U) | ||
66 | #define AK4497_CONTROL2_DEM0_MASK (0x2U) | ||
67 | #define AK4497_CONTROL2_DEM0_SHIFT (1U) | ||
68 | #define AK4497_CONTROL2_DEM1_MASK (0x4U) | ||
69 | #define AK4497_CONTROL2_DEM1_SHIFT (2U) | ||
70 | #define AK4497_CONTROL2_DFS0_MASK (0x8U) | ||
71 | #define AK4497_CONTROL2_DFS0_SHIFT (3U) | ||
72 | #define AK4497_CONTROL2_DFS1_MASK (0x10U) | ||
73 | #define AK4497_CONTROL2_DFS1_SHIFT (4U) | ||
74 | #define AK4497_CONTROL2_SD_MASK (0x20U) | ||
75 | #define AK4497_CONTROL2_SD_SHIFT (5U) | ||
76 | #define AK4497_CONTROL2_DZFM_MASK (0x40U) | ||
77 | #define AK4497_CONTROL2_DZFM_SHIFT (6U) | ||
78 | #define AK4497_CONTROL2_DZFE_MASK (0x80U) | ||
79 | #define AK4497_CONTROL2_DZFE_SHIFT (7U) | ||
80 | |||
81 | #define AK4497_CONTROL3_SLOW_MASK (0x1U) | ||
82 | #define AK4497_CONTROL3_SLOW_SHIFT (0U) | ||
83 | #define AK4497_CONTROL3_SELLR_MASK (0x2U) | ||
84 | #define AK4497_CONTROL3_SELLR_SHIFT (1U) | ||
85 | #define AK4497_CONTROL3_DZFB_MASK (0x4U) | ||
86 | #define AK4497_CONTROL3_DZFB_SHIFT (2U) | ||
87 | #define AK4497_CONTROL3_MONO_MASK (0x8U) | ||
88 | #define AK4497_CONTROL3_MONO_SHIFT (3U) | ||
89 | #define AK4497_CONTROL3_DCKB_MASK (0x10U) | ||
90 | #define AK4497_CONTROL3_DCKB_SHIFT (4U) | ||
91 | #define AK4497_CONTROL3_DCKS_MASK (0x20U) | ||
92 | #define AK4497_CONTROL3_DCKS_SHIFT (5U) | ||
93 | #define AK4497_CONTROL3_DP_MASK (0x80U) | ||
94 | #define AK4497_CONTROL3_DP_SHIFT (7U) | ||
95 | |||
96 | #define AK4497_CONTROL4_SSLOW_MASK (0x1U) | ||
97 | #define AK4497_CONTROL4_SSLOW_SHIFT (0U) | ||
98 | #define AK4497_CONTROL4_DFS2_MASK (0x2U) | ||
99 | #define AK4497_CONTROL4_DFS2_SHIFT (1U) | ||
100 | #define AK4497_CONTROL4_INVR_MASK (0x40U) | ||
101 | #define AK4497_CONTROL4_INVR_SHIFT (6U) | ||
102 | #define AK4497_CONTROL4_INVL_MASK (0x80U) | ||
103 | #define AK4497_CONTROL4_INVL_SHIFT (7U) | ||
104 | |||
105 | #define AK4497_DSD1_DSDSEL0_MASK (0x1U) | ||
106 | #define AK4497_DSD1_DSDSEL0_SHIFT (0U) | ||
107 | #define AK4497_DSD1_DSDD_MASK (0x2U) | ||
108 | #define AK4497_DSD1_DSDD_SHIFT (1U) | ||
109 | #define AK4497_DSD1_DMRE_MASK (0x8U) | ||
110 | #define AK4497_DSD1_DMRE_SHIFT (3U) | ||
111 | #define AK4497_DSD1_DMC_MASK (0x10U) | ||
112 | #define AK4497_DSD1_DMC_SHIFT (4U) | ||
113 | #define AK4497_DSD1_DMR_MASK (0x20U) | ||
114 | #define AK4497_DSD1_DMR_SHIFT (5U) | ||
115 | #define AK4497_DSD1_DML_MASK (0x40U) | ||
116 | #define AK4497_DSD1_DML_SHIFT (6U) | ||
117 | #define AK4497_DSD1_DDM_MASK (0x80U) | ||
118 | #define AK4497_DSD1_DDM_SHIFT (7U) | ||
119 | |||
120 | #define AK4497_CONTROL5_SYNCE_MASK (0x1U) | ||
121 | #define AK4497_CONTROL5_SYNCE_SHIFT (0U) | ||
122 | #define AK4497_CONTROL5_GC0_MASK (0x2U) | ||
123 | #define AK4497_CONTROL5_GC0_SHIFT (1U) | ||
124 | #define AK4497_CONTROL5_GC1_MASK (0x4U) | ||
125 | #define AK4497_CONTROL5_GC1_SHIFT (2U) | ||
126 | #define AK4497_CONTROL5_GC2_MASK (0x8U) | ||
127 | #define AK4497_CONTROL5_GC2_SHIFT (3U) | ||
128 | |||
129 | #define AK4497_SOUNDCONTROL_SC0_MASK (0x1U) | ||
130 | #define AK4497_SOUNDCONTROL_SC0_SHIFT (0U) | ||
131 | #define AK4497_SOUNDCONTROL_SC1_MASK (0x2U) | ||
132 | #define AK4497_SOUNDCONTROL_SC1_SHIFT (1U) | ||
133 | #define AK4497_SOUNDCONTROL_SC2_MASK (0x4U) | ||
134 | #define AK4497_SOUNDCONTROL_SC2_SHIFT (2U) | ||
135 | #define AK4497_SOUNDCONTROL_HLOAD_MASK (0x8U) | ||
136 | #define AK4497_SOUNDCONTROL_HLOAD_SHIFT (3U) | ||
137 | |||
138 | #define AK4497_DSD2_DSDSEL1_MASK (0x1U) | ||
139 | #define AK4497_DSD2_DSDSEL1_SHIFT (0U) | ||
140 | #define AK4497_DSD2_DSDF_MASK (0x2U) | ||
141 | #define AK4497_DSD2_DSDF_SHIFT (1U) | ||
142 | #define AK4497_DSD2_DSDPATH_MASK (0x4U) | ||
143 | #define AK4497_DSD2_DSDPATH_SHIFT (2U) | ||
144 | |||
145 | #define AK4497_CONTROL7_PW_MASK (0x4U) | ||
146 | #define AK4497_CONTROL7_PW_SHIFT (2U) | ||
147 | #define AK4497_CONTROL7_SDS2_MASK (0x10U) | ||
148 | #define AK4497_CONTROL7_SDS2_SHIFT (4U) | ||
149 | #define AK4497_CONTROL7_SDS1_MASK (0x20U) | ||
150 | #define AK4497_CONTROL7_SDS1_SHIFT (5U) | ||
151 | #define AK4497_CONTROL7_TDM0_MASK (0x40U) | ||
152 | #define AK4497_CONTROL7_TDM0_SHIFT (6U) | ||
153 | #define AK4497_CONTROL7_TDM1_MASK (0x80U) | ||
154 | #define AK4497_CONTROL7_TDM1_SHIFT (7U) | ||
155 | |||
156 | #define AK4497_CONTROL8_TSET_MASK (0x1U) | ||
157 | #define AK4497_CONTROL8_TSET_SHIFT (0U) | ||
158 | #define AK4497_CONTROL8_DCHAIN_MASK (0x2U) | ||
159 | #define AK4497_CONTROL8_DCHAIN_SHIFT (1U) | ||
160 | #define AK4497_CONTROL8_SDS0_MASK (0x10U) | ||
161 | #define AK4497_CONTROL8_SDS0_SHIFT (4U) | ||
162 | #define AK4497_CONTROL8_ATS0_MASK (0x40U) | ||
163 | #define AK4497_CONTROL8_ATS0_SHIFT (6U) | ||
164 | #define AK4497_CONTROL8_ATS1_MASK (0x80U) | ||
165 | #define AK4497_CONTROL8_ATS1_SHIFT (7U) | ||
166 | |||
167 | /*! @brief AK4497 I2C address. */ | ||
168 | #define AK4497_I2C_ADDR (0x11U) | ||
169 | /*! @brief AK4497 i2c baudrate */ | ||
170 | #define AK4497_I2C_BITRATE (100000U) | ||
171 | /*! @brief The AK4497 playback mode */ | ||
172 | typedef enum _ak4497_mode | ||
173 | { | ||
174 | kAK4497_PcmMode = 0x0, | ||
175 | kAK4497_DsdMode = 0x1, | ||
176 | kAK4497_ExdfMode = 0x2, | ||
177 | } ak4497_mode_t; | ||
178 | |||
179 | /*! @brief The Data selection of L-channel and R-channel for DSD mode, defined by SELLR bit */ | ||
180 | typedef enum _ak4497_data_channel_mode | ||
181 | { | ||
182 | kAK4497_NormalMode = 0x0, /*!< L-channel output L-channel data, R-channel output R-channel data. */ | ||
183 | kAK4497_ExchangeMode = 0x1, /*!< L-channel output R-channel data, R-channel output L-channel data. */ | ||
184 | } ak4497_data_channel_mode_t; | ||
185 | |||
186 | /*! @brief The data path select for DSD mode */ | ||
187 | typedef enum _ak4497_dsd_input_path | ||
188 | { | ||
189 | kAK4497_Path0 = 0x0, /*!< Pin 16,17,19 used. */ | ||
190 | kAK4497_Path1 = 0x1, /*!< Pin 3,4,5 used. */ | ||
191 | } ak4497_dsd_input_path_t; | ||
192 | |||
193 | /*! @brief The MCLK select for DSD mode, defined by DCKS bit */ | ||
194 | typedef enum _ak4497_dsd_mclk | ||
195 | { | ||
196 | kAK4497_mclk512fs = 0x0, /*!< MCLK equals 512fs. */ | ||
197 | kAK4497_mclk768fs = 0x1, /*!< MCLK equals 768fs. */ | ||
198 | } ak4497_dsd_mclk_t; | ||
199 | |||
200 | /*! @brief The DCLK select for DSD mode, defined by DSDSEL[1:0] */ | ||
201 | typedef enum _ak4497_dsd_dclk | ||
202 | { | ||
203 | kAK4497_dclk64fs = 0x0, /*!< DCLK equals 64fs. */ | ||
204 | kAK4497_dclk128fs = 0x1, /*!< DCLK equals 128fs. */ | ||
205 | kAK4497_dclk256fs = 0x2, /*!< DCLK equals 256fs. */ | ||
206 | kAK4497_dclk512fs = 0x3, /*!< DCLK equals 512fs. */ | ||
207 | } ak4497_dsd_dclk_t; | ||
208 | |||
209 | /*! @brief DSD playback path */ | ||
210 | typedef enum _ak4497_dsd_playback_path | ||
211 | { | ||
212 | kAK4497_NormalPath = 0x0, /*!< Normal path mode. */ | ||
213 | kAK4497_VolumeBypass = 0x1, /*!< Volume Bypass mode. */ | ||
214 | } ak4497_dsd_playback_path_t; | ||
215 | |||
216 | /*! @brief DSD mute flag */ | ||
217 | typedef enum _ak4497_dsd_data_mute | ||
218 | { | ||
219 | kAK4497_DsdMuteDisable = 0x0, | ||
220 | kAK4497_DsdMuteEnable = 0x1, | ||
221 | } ak4497_dsd_data_mute_t; | ||
222 | |||
223 | /*! @brief DSD bclk polarity */ | ||
224 | typedef enum _ak4497_dsd_dclk_polarity | ||
225 | { | ||
226 | kAK4497_FallingEdge = 0x0, /*!< DSD data is output from DCLK falling edge. */ | ||
227 | kAK4497_RisingEdge = 0x1, /*!< DSD data is output from DCLK rising edge. */ | ||
228 | } ak4497_dsd_dclk_polarity_t; | ||
229 | /*! @brief The sampling frequency mode for PCM and EXDF mode, defined by CR01[AFSD], CR00[ACKS]*/ | ||
230 | typedef enum _ak4497_pcm_samplefreqmode | ||
231 | { | ||
232 | kAK4497_ManualSettingMode = 0x0, /*!< Manual setting mode */ | ||
233 | kAK4497_AutoSettingMode = 0x1, /*!< Auto setting mode */ | ||
234 | kAK4497_FsAutoDetectMode = 0x2, /*!< Auto detect mode */ | ||
235 | } ak4497_pcm_samplefreqmode_t; | ||
236 | /*! @brief The sampling speed select, defined by DFS[2:0]*/ | ||
237 | typedef enum _ak4497_pcm_samplefreqselect | ||
238 | { | ||
239 | kAK4497_NormalSpeed = 0x0, /*!< 8kHZ ~ 54kHZ */ | ||
240 | kAK4497_DoubleSpeed = 0x1, /*!< 54kHZ ~ 108kHZ */ | ||
241 | kAK4497_QuadSpeed = 0x2, /*!< 120kHZ ~ 216kHZ, note that value 3 also stands for Quad Speed Mode */ | ||
242 | kAK4497_OctSpeed = 0x4, /*!< 384kHZ, note that value 6 also stands for Oct Speed Mode */ | ||
243 | kAK4497_HexSpeed = 0x5, /*!< 768kHZ, note that value 7 also stands for Hex Speed Mode */ | ||
244 | } ak4497_pcm_samplefreqselect_t; | ||
245 | |||
246 | /*! @brief The audio data interface modes, defined by DIF[2:0]*/ | ||
247 | typedef enum _ak4497_pcm_sdata_format | ||
248 | { | ||
249 | kAK4497_16BitLSB = 0x0, /*!< 16-bit LSB justified */ | ||
250 | kAK4497_20BitLSB = 0x1, /*!< 20-bit LSB justified */ | ||
251 | kAK4497_24BitMSB = 0x2, /*!< 24-bit MSB justified */ | ||
252 | kAK4497_16_24BitI2S = 0x3, /*!< 16 and 24-bit I2S compatible */ | ||
253 | kAK4497_24BitLSB = 0x4, /*!< 24-bit LSB justified */ | ||
254 | kAK4497_32BitLSB = 0x5, /*!< 32-bit LSB justified */ | ||
255 | kAK4497_32BitMSB = 0x6, /*!< 32-bit MSB justified */ | ||
256 | kAK4497_32BitI2S = 0x7, /*!< 32-bit I2S compatible */ | ||
257 | } ak4497_pcm_sdata_format_t; | ||
258 | |||
259 | /*! @brief The TDM mode select, defined by TDM[1:0]*/ | ||
260 | typedef enum _ak4497_pcm_tdm_mode | ||
261 | { | ||
262 | kAK4497_Normal = 0x0, /*!< Normal mode */ | ||
263 | kAK4497_TDM128 = 0x1, /*!< BCLK is fixed to 128fs */ | ||
264 | kAK4497_TDM256 = 0x2, /*!< BCLK is fixed to 256fs */ | ||
265 | kAK4497_TDM512 = 0x3, /*!< BCLK is fixed to 512fs */ | ||
266 | } ak4497_pcm_tdm_mode_t; | ||
267 | |||
268 | /*! @brief The audio data slot selection, defined by SDS[2:0]*/ | ||
269 | typedef enum _ak4497_pcm_sds_select | ||
270 | { | ||
271 | kAK4497_L1R1 = 0x0, | ||
272 | kAK4497_L2R2 = 0x1, | ||
273 | kAK4497_L3R3 = 0x2, | ||
274 | kAK4497_L4R4 = 0x3, | ||
275 | kAK4497_L5R5 = 0x4, | ||
276 | kAK4497_L6R6 = 0x5, | ||
277 | kAK4497_L7R7 = 0x6, | ||
278 | kAK4497_L8R8 = 0x7, | ||
279 | } ak4497_pcm_sds_select_t; | ||
280 | |||
281 | /*! @brief audio codec module control cmd */ | ||
282 | typedef enum _ak4497_module_ctrl_cmd | ||
283 | { | ||
284 | kAK4497_ModuleSwitchI2SInInterface = 0U, /*!< module digital interface siwtch. */ | ||
285 | } ak4497_module_ctrl_cmd_t; | ||
286 | |||
287 | /*! @brief audio codec module digital interface | ||
288 | * @anchor _ak4497_module_ctrl_i2s_in_interface | ||
289 | */ | ||
290 | enum | ||
291 | { | ||
292 | kAK4497_ModuleI2SInInterfacePCM = 0U, /*!< Pcm interface*/ | ||
293 | kAK4497_ModuleI2SInInterfaceDSD = 1U, /*!< DSD interface */ | ||
294 | }; | ||
295 | |||
296 | /*! @brief Initialize DSD mode structure of AK4497 */ | ||
297 | typedef struct _ak4497_dsd_config | ||
298 | { | ||
299 | ak4497_dsd_input_path_t dsdPath; | ||
300 | ak4497_dsd_mclk_t dsdMclk; | ||
301 | ak4497_dsd_playback_path_t dsdPlaybackPath; | ||
302 | ak4497_dsd_data_mute_t dsdDataMute; | ||
303 | ak4497_dsd_dclk_polarity_t dsdDclkPolarity; | ||
304 | } ak4497_dsd_config_t; | ||
305 | |||
306 | /*! @brief Initialize PCM mode structure of AK4497 */ | ||
307 | typedef struct _ak4497_pcm_config | ||
308 | { | ||
309 | ak4497_pcm_samplefreqmode_t pcmSampleFreqMode; | ||
310 | ak4497_pcm_sdata_format_t pcmSdataFormat; | ||
311 | ak4497_pcm_tdm_mode_t pcmTdmMode; | ||
312 | ak4497_pcm_sds_select_t pcmSdsSlot; | ||
313 | } ak4497_pcm_config_t; | ||
314 | |||
315 | /*! @brief Initialize structure of AK4497 */ | ||
316 | typedef struct _ak4497_config | ||
317 | { | ||
318 | ak4497_mode_t ak4497Mode; | ||
319 | ak4497_data_channel_mode_t dataChannelMode; | ||
320 | ak4497_pcm_config_t pcmConfig; | ||
321 | ak4497_dsd_config_t dsdConfig; | ||
322 | |||
323 | uint8_t slaveAddress; /*!< code device slave address */ | ||
324 | codec_i2c_config_t i2cConfig; /*!< i2c bus configuration */ | ||
325 | } ak4497_config_t; | ||
326 | |||
327 | /*! @brief ak4497 codec handler | ||
328 | */ | ||
329 | typedef struct _ak4497_handle | ||
330 | { | ||
331 | ak4497_config_t *config; /*!< ak4497 config pointer */ | ||
332 | uint8_t i2cHandle[AK4497_I2C_HANDLER_SIZE]; /*!< i2c handle */ | ||
333 | } ak4497_handle_t; | ||
334 | |||
335 | /******************************************************************************* | ||
336 | * API | ||
337 | ******************************************************************************/ | ||
338 | #if defined(__cplusplus) | ||
339 | extern "C" { | ||
340 | #endif | ||
341 | |||
342 | /*! | ||
343 | * @brief Default initializes AK4497. | ||
344 | * | ||
345 | * @param config AK4497 configure structure. | ||
346 | */ | ||
347 | void AK4497_DefaultConfig(ak4497_config_t *config); | ||
348 | /*! | ||
349 | * @brief Initializes AK4497. | ||
350 | * | ||
351 | * @param handle AK4497 handle structure. | ||
352 | * @param config AK4497 configure structure. | ||
353 | */ | ||
354 | status_t AK4497_Init(ak4497_handle_t *handle, ak4497_config_t *config); | ||
355 | /*! | ||
356 | * @brief Set the codec PCM mode or DSD mode based on the format info | ||
357 | * | ||
358 | * This function would configure the codec playback mode. | ||
359 | * | ||
360 | * @param handle AK4497 handle structure pointer. | ||
361 | * @param format info. | ||
362 | */ | ||
363 | status_t AK4497_SetEncoding(ak4497_handle_t *handle, uint8_t format); | ||
364 | /*! | ||
365 | * @brief Configure the data format of audio data. | ||
366 | * | ||
367 | * This function would configure the registers about the sample rate, bit depths. | ||
368 | * | ||
369 | * @param handle AK4497 handle structure pointer. | ||
370 | * @param mclk system clock of the codec which can be generated by MCLK or PLL output. | ||
371 | * @param sampleRate Sample rate of audio file running in AK4497. | ||
372 | * @param bitWidth Bit depth of audio file. | ||
373 | */ | ||
374 | status_t AK4497_ConfigDataFormat(ak4497_handle_t *handle, uint32_t mclk, uint32_t sampleRate, uint32_t bitWidth); | ||
375 | |||
376 | /*! | ||
377 | * @brief Set the volume of different modules in AK4497. | ||
378 | * | ||
379 | * This function would set the volume of AK4497 modules. Users need to appoint the module. | ||
380 | * The function assume that left channel and right channel has the same volume. | ||
381 | * | ||
382 | * @param handle AK4497 handle structure. | ||
383 | * @param value Volume value need to be set. | ||
384 | */ | ||
385 | status_t AK4497_SetVolume(ak4497_handle_t *handle, uint8_t value); | ||
386 | |||
387 | /*! | ||
388 | * @brief Get the volume of different modules in AK4497. | ||
389 | * | ||
390 | * This function gets the volume of AK4497. Users need to appoint the module. | ||
391 | * The function assume that left channel and right channel has the same volume. | ||
392 | * | ||
393 | * @param handle AK4497 handle structure. | ||
394 | * @param value volume value | ||
395 | * @return value value of the module. | ||
396 | */ | ||
397 | status_t AK4497_GetVolume(ak4497_handle_t *handle, uint8_t *value); | ||
398 | |||
399 | /*! | ||
400 | * @brief AK4497 codec module control. | ||
401 | * | ||
402 | * @param handle AK4497 handle structure pointer. | ||
403 | * @param cmd module control command, support cmd kAK4497_ModuleSwitchDigitalInterface. | ||
404 | * @param data control data, support data kCODEC_ModuleDigitalInterfacePCM/kCODEC_ModuleDigitalInterfaceDSD. | ||
405 | */ | ||
406 | status_t AK4497_ModuleControl(ak4497_handle_t *handle, ak4497_module_ctrl_cmd_t cmd, uint32_t data); | ||
407 | |||
408 | /*! | ||
409 | * @brief Deinit the AK4497 codec. | ||
410 | * | ||
411 | * This function close all modules in AK4497 to save power. | ||
412 | * | ||
413 | * @param handle AK4497 handle structure pointer. | ||
414 | */ | ||
415 | status_t AK4497_Deinit(ak4497_handle_t *handle); | ||
416 | /*! | ||
417 | * @brief Write register to AK4497 using I2C. | ||
418 | * | ||
419 | * @param handle AK4497 handle structure. | ||
420 | * @param reg The register address in AK4497. | ||
421 | * @param val Value needs to write into the register. | ||
422 | */ | ||
423 | status_t AK4497_WriteReg(ak4497_handle_t *handle, uint8_t reg, uint8_t val); | ||
424 | |||
425 | /*! | ||
426 | * @brief Read register from AK4497 using I2C. | ||
427 | * @param handle AK4497 handle structure. | ||
428 | * @param reg The register address in AK4497. | ||
429 | * @param val Value written to. | ||
430 | */ | ||
431 | status_t AK4497_ReadReg(ak4497_handle_t *handle, uint8_t reg, uint8_t *val); | ||
432 | |||
433 | /*! | ||
434 | * @brief Modify some bits in the register using I2C. | ||
435 | * @param handle AK4497 handle structure. | ||
436 | * @param reg The register address in AK4497. | ||
437 | * @param mask The mask code for the bits want to write. The bit you want to write should be 0. | ||
438 | * @param val Value needs to write into the register. | ||
439 | */ | ||
440 | status_t AK4497_ModifyReg(ak4497_handle_t *handle, uint8_t reg, uint8_t mask, uint8_t val); | ||
441 | |||
442 | #if defined(__cplusplus) | ||
443 | } | ||
444 | #endif | ||
445 | |||
446 | /*! @} */ | ||
447 | #endif /* _FSL_AK4497_H_ */ | ||