1/**
2 * @file hi_i2s.h
3 *
4 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/**
19 * @defgroup iot_i2s I2S
20 * @ingroup drivers
21 */
22#ifndef __HI_I2S_H__
23#define __HI_I2S_H__
24
25/**
26* @ingroup iot_i2s
27*
28* sample rate.
29*/
30typedef enum {
31    HI_I2S_SAMPLE_RATE_8K = 8,
32    HI_I2S_SAMPLE_RATE_16K = 16,
33    HI_I2S_SAMPLE_RATE_32K = 32,
34    HI_I2S_SAMPLE_RATE_48K = 48,
35} hi_i2s_sample_rate;
36
37/**
38* @ingroup iot_i2s
39*
40* resolution.
41*/
42typedef enum {
43    HI_I2S_RESOLUTION_16BIT = 16,
44    HI_I2S_RESOLUTION_24BIT = 24,
45} hi_i2s_resolution;
46
47/**
48* @ingroup iot_i2s
49*
50* I2S attributes.
51*/
52typedef struct {
53    hi_i2s_sample_rate sample_rate;  /**< i2s sample rate, type hi_i2s_sample_rate.CNcomment:采样率,类型为
54                                          hi_i2s_sample_rate。CNend */
55    hi_i2s_resolution resolution;   /**< i2s resolution, type hi_i2s_resolution.CNcomment:解析度,类型为
56                                          hi_i2s_resolution。CNend */
57} hi_i2s_attribute;
58
59/**
60* @ingroup  iot_i2s
61* @brief  I2S initialization. CNcomment:I2S初始化。CNend
62*
63* @par 描述:
64*           Set I2S with configuration. CNcomment:根据参数配置I2S。CNend
65*
66* @attention Should init DMA driver before using I2S. CNcomment:使用I2S驱动前,需要初始化DMA驱动。CNend
67*
68* @param  i2s_attribute   [IN] type #hi_i2s_attribute*,I2S configuration parameter. CNcomment:I2S配置参数。CNend
69*
70* @retval #HI_ERR_SUCCESS  Success.
71* @retval #Other           Failure. For details, see hi_errno.h.
72* @par 依赖:
73*            @li hi_i2s.h:Describes I2S APIs.CNcomment:I2S相关接口。CNend
74* @see  hi_i2s_deinit。
75*/
76hi_u32 hi_i2s_init(const hi_i2s_attribute *i2s_attribute);
77
78/**
79* @ingroup  iot_i2s
80* @brief  Deinitializes I2S.CNcomment:去初始化I2S。CNend
81*
82* @par 描述:
83*           Deinitializes I2S.CNcomment:去初始化I2S。CNend
84*
85* @attention This API is used together with hi_i2s_init.CNcomment:与hi_i2s_init成对使用。CNend
86* @param  None
87*
88* @retval #HI_ERR_SUCCESS  Success.
89* @retval #Other           Failure. For details, see hi_errno.h.
90* @par 依赖:
91*            @li hi_i2s.h:Describes I2S APIs.CNcomment:I2S相关接口。CNend
92* @see  hi_i2s_deinit。
93*/
94hi_u32 hi_i2s_deinit(hi_void);
95
96/**
97* @ingroup  iot_i2s
98* @brief TX interface for the I2S.CNcomment:I2S发送接口。CNend
99*
100* @par 描述:
101*           TX interface for the I2S.CNcomment:I2S发送接口。CNend
102*
103* @attention None
104*
105* @param  wr_data         [OUT] type #hi_u8*,TX data pointer.CNcomment:接收数据指针。CNend
106* @param  wr_len          [IN]  type #hi_u32,length of the target data to be send (unit: byte).
107CNcomment:发送数据长度(单位:byte)。CNend
108* @param  time_out_ms     [IN]  type #hi_u32,wait timeout period.CNcomment:超时时间。CNend
109*
110* @retval #HI_ERR_SUCCESS  Success.
111* @retval #Other           Failure. For details, see hi_errno.h.
112* @par 依赖:
113*            @li hi_i2s.h:Describes I2S APIs.CNcomment:I2S相关接口。CNend
114* @see  hi_i2s_read。
115*/
116hi_u32 hi_i2s_write(hi_u8 *wr_data, hi_u32 wr_len, hi_u32 time_out_ms);
117
118/**
119* @ingroup  iot_i2s
120* @brief Read interface for the I2S.CNcomment:I2S接收接口。CNend
121*
122* @par 描述:
123*           Read interface for the I2S.CNcomment:I2S接收接口。CNend
124*
125* @attention None
126*
127* @param  rd_data         [OUT] type #hi_u8*,RX data pointer.CNcomment:接收数据指针。CNend
128* @param  rd_len          [IN]  type #hi_u32,length of the target data to be received (unit: byte).
129CNcomment:接收数据长度(单位:byte)。CNend
130* @param  time_out_ms     [IN]  type #hi_u32,wait timeout period.CNcomment:超时时间。CNend
131*
132* @retval #HI_ERR_SUCCESS  Success.
133* @retval #Other           Failure. For details, see hi_errno.h.
134* @par 依赖:
135*            @li hi_i2s.h:Describes I2S APIs.CNcomment:I2S相关接口。CNend
136* @see  hi_i2s_write。
137*/
138hi_u32 hi_i2s_read(hi_u8 *rd_data, hi_u32 rd_len, hi_u32 time_out_ms);
139
140#endif
141