11bd4fe43Sopenharmony_ci/**
21bd4fe43Sopenharmony_ci * @file hi_i2s.h
31bd4fe43Sopenharmony_ci *
41bd4fe43Sopenharmony_ci * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
51bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
61bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License.
71bd4fe43Sopenharmony_ci * You may obtain a copy of the License at
81bd4fe43Sopenharmony_ci *
91bd4fe43Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
101bd4fe43Sopenharmony_ci *
111bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
121bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
131bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
141bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and
151bd4fe43Sopenharmony_ci * limitations under the License.
161bd4fe43Sopenharmony_ci */
171bd4fe43Sopenharmony_ci
181bd4fe43Sopenharmony_ci/**
191bd4fe43Sopenharmony_ci * @defgroup iot_i2s I2S
201bd4fe43Sopenharmony_ci * @ingroup drivers
211bd4fe43Sopenharmony_ci */
221bd4fe43Sopenharmony_ci#ifndef __HI_I2S_H__
231bd4fe43Sopenharmony_ci#define __HI_I2S_H__
241bd4fe43Sopenharmony_ci
251bd4fe43Sopenharmony_ci/**
261bd4fe43Sopenharmony_ci* @ingroup iot_i2s
271bd4fe43Sopenharmony_ci*
281bd4fe43Sopenharmony_ci* sample rate.
291bd4fe43Sopenharmony_ci*/
301bd4fe43Sopenharmony_citypedef enum {
311bd4fe43Sopenharmony_ci    HI_I2S_SAMPLE_RATE_8K = 8,
321bd4fe43Sopenharmony_ci    HI_I2S_SAMPLE_RATE_16K = 16,
331bd4fe43Sopenharmony_ci    HI_I2S_SAMPLE_RATE_32K = 32,
341bd4fe43Sopenharmony_ci    HI_I2S_SAMPLE_RATE_48K = 48,
351bd4fe43Sopenharmony_ci} hi_i2s_sample_rate;
361bd4fe43Sopenharmony_ci
371bd4fe43Sopenharmony_ci/**
381bd4fe43Sopenharmony_ci* @ingroup iot_i2s
391bd4fe43Sopenharmony_ci*
401bd4fe43Sopenharmony_ci* resolution.
411bd4fe43Sopenharmony_ci*/
421bd4fe43Sopenharmony_citypedef enum {
431bd4fe43Sopenharmony_ci    HI_I2S_RESOLUTION_16BIT = 16,
441bd4fe43Sopenharmony_ci    HI_I2S_RESOLUTION_24BIT = 24,
451bd4fe43Sopenharmony_ci} hi_i2s_resolution;
461bd4fe43Sopenharmony_ci
471bd4fe43Sopenharmony_ci/**
481bd4fe43Sopenharmony_ci* @ingroup iot_i2s
491bd4fe43Sopenharmony_ci*
501bd4fe43Sopenharmony_ci* I2S attributes.
511bd4fe43Sopenharmony_ci*/
521bd4fe43Sopenharmony_citypedef struct {
531bd4fe43Sopenharmony_ci    hi_i2s_sample_rate sample_rate;  /**< i2s sample rate, type hi_i2s_sample_rate.CNcomment:采样率,类型为
541bd4fe43Sopenharmony_ci                                          hi_i2s_sample_rate。CNend */
551bd4fe43Sopenharmony_ci    hi_i2s_resolution resolution;   /**< i2s resolution, type hi_i2s_resolution.CNcomment:解析度,类型为
561bd4fe43Sopenharmony_ci                                          hi_i2s_resolution。CNend */
571bd4fe43Sopenharmony_ci} hi_i2s_attribute;
581bd4fe43Sopenharmony_ci
591bd4fe43Sopenharmony_ci/**
601bd4fe43Sopenharmony_ci* @ingroup  iot_i2s
611bd4fe43Sopenharmony_ci* @brief  I2S initialization. CNcomment:I2S初始化。CNend
621bd4fe43Sopenharmony_ci*
631bd4fe43Sopenharmony_ci* @par 描述:
641bd4fe43Sopenharmony_ci*           Set I2S with configuration. CNcomment:根据参数配置I2S。CNend
651bd4fe43Sopenharmony_ci*
661bd4fe43Sopenharmony_ci* @attention Should init DMA driver before using I2S. CNcomment:使用I2S驱动前,需要初始化DMA驱动。CNend
671bd4fe43Sopenharmony_ci*
681bd4fe43Sopenharmony_ci* @param  i2s_attribute   [IN] type #hi_i2s_attribute*,I2S configuration parameter. CNcomment:I2S配置参数。CNend
691bd4fe43Sopenharmony_ci*
701bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS  Success.
711bd4fe43Sopenharmony_ci* @retval #Other           Failure. For details, see hi_errno.h.
721bd4fe43Sopenharmony_ci* @par 依赖:
731bd4fe43Sopenharmony_ci*            @li hi_i2s.h:Describes I2S APIs.CNcomment:I2S相关接口。CNend
741bd4fe43Sopenharmony_ci* @see  hi_i2s_deinit。
751bd4fe43Sopenharmony_ci*/
761bd4fe43Sopenharmony_cihi_u32 hi_i2s_init(const hi_i2s_attribute *i2s_attribute);
771bd4fe43Sopenharmony_ci
781bd4fe43Sopenharmony_ci/**
791bd4fe43Sopenharmony_ci* @ingroup  iot_i2s
801bd4fe43Sopenharmony_ci* @brief  Deinitializes I2S.CNcomment:去初始化I2S。CNend
811bd4fe43Sopenharmony_ci*
821bd4fe43Sopenharmony_ci* @par 描述:
831bd4fe43Sopenharmony_ci*           Deinitializes I2S.CNcomment:去初始化I2S。CNend
841bd4fe43Sopenharmony_ci*
851bd4fe43Sopenharmony_ci* @attention This API is used together with hi_i2s_init.CNcomment:与hi_i2s_init成对使用。CNend
861bd4fe43Sopenharmony_ci* @param  None
871bd4fe43Sopenharmony_ci*
881bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS  Success.
891bd4fe43Sopenharmony_ci* @retval #Other           Failure. For details, see hi_errno.h.
901bd4fe43Sopenharmony_ci* @par 依赖:
911bd4fe43Sopenharmony_ci*            @li hi_i2s.h:Describes I2S APIs.CNcomment:I2S相关接口。CNend
921bd4fe43Sopenharmony_ci* @see  hi_i2s_deinit。
931bd4fe43Sopenharmony_ci*/
941bd4fe43Sopenharmony_cihi_u32 hi_i2s_deinit(hi_void);
951bd4fe43Sopenharmony_ci
961bd4fe43Sopenharmony_ci/**
971bd4fe43Sopenharmony_ci* @ingroup  iot_i2s
981bd4fe43Sopenharmony_ci* @brief TX interface for the I2S.CNcomment:I2S发送接口。CNend
991bd4fe43Sopenharmony_ci*
1001bd4fe43Sopenharmony_ci* @par 描述:
1011bd4fe43Sopenharmony_ci*           TX interface for the I2S.CNcomment:I2S发送接口。CNend
1021bd4fe43Sopenharmony_ci*
1031bd4fe43Sopenharmony_ci* @attention None
1041bd4fe43Sopenharmony_ci*
1051bd4fe43Sopenharmony_ci* @param  wr_data         [OUT] type #hi_u8*,TX data pointer.CNcomment:接收数据指针。CNend
1061bd4fe43Sopenharmony_ci* @param  wr_len          [IN]  type #hi_u32,length of the target data to be send (unit: byte).
1071bd4fe43Sopenharmony_ciCNcomment:发送数据长度(单位:byte)。CNend
1081bd4fe43Sopenharmony_ci* @param  time_out_ms     [IN]  type #hi_u32,wait timeout period.CNcomment:超时时间。CNend
1091bd4fe43Sopenharmony_ci*
1101bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS  Success.
1111bd4fe43Sopenharmony_ci* @retval #Other           Failure. For details, see hi_errno.h.
1121bd4fe43Sopenharmony_ci* @par 依赖:
1131bd4fe43Sopenharmony_ci*            @li hi_i2s.h:Describes I2S APIs.CNcomment:I2S相关接口。CNend
1141bd4fe43Sopenharmony_ci* @see  hi_i2s_read。
1151bd4fe43Sopenharmony_ci*/
1161bd4fe43Sopenharmony_cihi_u32 hi_i2s_write(hi_u8 *wr_data, hi_u32 wr_len, hi_u32 time_out_ms);
1171bd4fe43Sopenharmony_ci
1181bd4fe43Sopenharmony_ci/**
1191bd4fe43Sopenharmony_ci* @ingroup  iot_i2s
1201bd4fe43Sopenharmony_ci* @brief Read interface for the I2S.CNcomment:I2S接收接口。CNend
1211bd4fe43Sopenharmony_ci*
1221bd4fe43Sopenharmony_ci* @par 描述:
1231bd4fe43Sopenharmony_ci*           Read interface for the I2S.CNcomment:I2S接收接口。CNend
1241bd4fe43Sopenharmony_ci*
1251bd4fe43Sopenharmony_ci* @attention None
1261bd4fe43Sopenharmony_ci*
1271bd4fe43Sopenharmony_ci* @param  rd_data         [OUT] type #hi_u8*,RX data pointer.CNcomment:接收数据指针。CNend
1281bd4fe43Sopenharmony_ci* @param  rd_len          [IN]  type #hi_u32,length of the target data to be received (unit: byte).
1291bd4fe43Sopenharmony_ciCNcomment:接收数据长度(单位:byte)。CNend
1301bd4fe43Sopenharmony_ci* @param  time_out_ms     [IN]  type #hi_u32,wait timeout period.CNcomment:超时时间。CNend
1311bd4fe43Sopenharmony_ci*
1321bd4fe43Sopenharmony_ci* @retval #HI_ERR_SUCCESS  Success.
1331bd4fe43Sopenharmony_ci* @retval #Other           Failure. For details, see hi_errno.h.
1341bd4fe43Sopenharmony_ci* @par 依赖:
1351bd4fe43Sopenharmony_ci*            @li hi_i2s.h:Describes I2S APIs.CNcomment:I2S相关接口。CNend
1361bd4fe43Sopenharmony_ci* @see  hi_i2s_write。
1371bd4fe43Sopenharmony_ci*/
1381bd4fe43Sopenharmony_cihi_u32 hi_i2s_read(hi_u8 *rd_data, hi_u32 rd_len, hi_u32 time_out_ms);
1391bd4fe43Sopenharmony_ci
1401bd4fe43Sopenharmony_ci#endif
141