RVB2601评估板试用4: 麦克风录音测试
本帖最后由 我爱下载 于 2021-8-11 13:41 编辑<p style="text-align: center;"><span style="font-size:24px;">麦克风录音测试</span></p>
<p><span style="font-size:20px;">1、概述</span></p>
<p> RVB2601采用ES7210进行麦克风的数字化采样。本次测试,学习使用I2S接口从ES7210中进行一定时间的麦克风音频数据采集和暂存。</p>
<p><span style="font-size:20px;">2、驱动描述</span></p>
<p><span style="font-size:16px;">2.1 硬件接口原理</span></p>
<p></p>
<p>CH2601采用I2C接口完成ES7210的配置,采用I2S接口读取ES7210的转换数据,其接口如图所示。</p>
<table class="a5">
<tbody>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">序号</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">ES</span><span style="font-size: 10.5pt;">7210</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">GPIO</span></p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">1</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">I</span><span style="font-size: 10.5pt;">2</span><span style="font-size: 10.5pt;">C</span><span style="font-size: 10.5pt;"> SCL</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">PA</span><span style="font-size: 10.5pt;">8</span><span style="font-size: 10.5pt;">(I</span><span style="font-size: 10.5pt;">2C0_SCL</span><span style="font-size: 10.5pt;">)</span></p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">2</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">I2C SDA</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">PA</span><span style="font-size: 10.5pt;">9</span><span style="font-size: 10.5pt;">(</span><span style="font-size: 10.5pt;">I</span><span style="font-size: 10.5pt;">2C</span><span style="font-size: 10.5pt;">0_</span><span style="font-size: 10.5pt;">SDA</span><span style="font-size: 10.5pt;">)</span></p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">3</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">ADC MCLK</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">PA</span><span style="font-size: 10.5pt;">1</span><span style="font-size: 10.5pt;">0</span><span style="font-size: 10.5pt;">(</span><span style="font-size: 10.5pt;">I</span><span style="font-size: 10.5pt;">2S</span><span style="font-size: 10.5pt;">0_M</span><span style="font-size: 10.5pt;">CLK</span><span style="font-size: 10.5pt;">)</span></p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">4</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">ADC BCLK</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">I2</span><span style="font-size: 10.5pt;">S</span><span style="font-size: 10.5pt;">4_SCLK</span></p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">5</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">ADC LRLK</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">I2S4_LSCLK</span></p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">6</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">ADC DAT1</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">I2S4_DATA</span></p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">7</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">ADC DAT</span><span style="font-size: 10.5pt;">2</span></p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;"><span style="font-size: 10.5pt;">I2S</span><span style="font-size: 10.5pt;">5</span><span style="font-size: 10.5pt;">_DATA</span></p>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size:16px;">2.2 软件驱动设计 </span>CODEC</p>
<p>CODEC在这里指的是同时具有D/A(数字讯号转换成模拟讯号)和A/D(模拟讯号转换成数字讯号)转换功能的编解码器,播放音乐的时候用到的是D/A转换功能。在录音的时候用到的是A/D转换功能。</p>
<p>在接口中,D/A指的是输出通道,A/D指的是输入通道。我们这里主要使用AD的输入通道</p>
<p style="text-align: left; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span style="font-family: Helvetica; color: rgb(51, 51, 51);">本次使用CODEC</span><span style="font-family: Helvetica; color: rgb(51, 51, 51);">的</span><span style="font-family: Helvetica; color: rgb(51, 51, 51);">CSI</span><span style="font-family: Helvetica; color: rgb(51, 51, 51);">接口如下所示:</span></span></p>
<p style="text-align: left; margin-bottom: 10.2pt;"> </p>
<table class="Table" style="width:15.0cm; background:white; border-collapse:collapse" width="567">
<thead>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:1px solid #dddddd; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体">函数</span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:1px solid #dddddd; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体">说明</span></span></span></p>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_init</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">设备初始化</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:#f8f8f8; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_uninit</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:#f8f8f8; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">设备去初始化</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_input_open</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道打开</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:#f8f8f8; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_input_config</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:#f8f8f8; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道配置</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_input_analog_gain</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道设置模拟增益</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_input_start</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">接收输入音频流</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_input_stop</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">结束接收输入音频流</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_input_read_async</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道异步模式读取数据</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_input_read</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道同步模式读取数据</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">csi_codec_input_attach_callback</span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道注册回调函数</span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US">csi_codec_input_detach_callback</span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US">CODEC</span>输入通道注销回调函数</span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US">csi_codec_input_close</span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US">CODEC</span>输入通道关闭</span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1px solid #dddddd; width:269px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:1px solid #dddddd">
<p style="text-align:justify"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US">csi_codec_input_link_dma</span></span></span></span></p>
</td>
<td style="border-bottom:1px solid #dddddd; width:298px; padding:6px 13px 6px 13px; background-color:white; border-top:none; border-right:1px solid #dddddd; border-left:none">
<p style="text-align:justify"><span style="font-size:16px;"><span style="box-sizing:border-box"><span style="-webkit-tap-highlight-color:transparent"><span style="text-size-adjust:none"><span style="-webkit-font-smoothing:antialiased"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US">CODEC</span>输入通道配置DMA</span></span></span></span></span></span></span></p>
</td>
</tr>
</tbody>
</table>
<p style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><br />
<span style="font-family: Helvetica; font-size: 16px;">CODEC设备初始化</span><span style="font-size:16px;"><span style="font-family: Helvetica; color: rgb(51, 51, 51);">CODEC</span><span style="font-family: Helvetica; color: rgb(51, 51, 51);">用于输入</span><span style="font-family: Helvetica; color: rgb(51, 51, 51);">接口详细说明</span></span></p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span style="line-height:normal"><span style="font-family:宋体"><span lang="EN-US"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span><span style="color:#333333"><span style="letter-spacing:.15pt">设备初始化</span></span></span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> csi_error_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">csi_codec_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">init</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *codec, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">uint32_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">idx</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 功能描述:</p>
<p> 通过设备ID初始化对应的CODEC实例。</p>
<p> 参数: <span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">codec</span>: 设备句柄(需要用户申请句柄空间)。</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> idx</span>: 设备ID。</p>
<p> 返回值:</p>
<p> CSI_OK: 初始化成功。</p>
<p> CSI_ERROR: 初始化失败。</p>
<p style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-family: 'Helvetica'; font-size: 15pt; color: #333333;"> csi_codec_t</span></p>
<table style="table-layout: auto;">
<tbody>
<tr>
<th>
<p><span style="font-size: 10.5pt;">成员</span></p>
</th>
<th>
<p><span style="font-size: 10.5pt;">类型</span></p>
</th>
<th>
<p><span style="font-size: 10.5pt;">说明</span></p>
</th>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">dev</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_dev_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi</span><span style="font-size: 10.5pt;">设备统一句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">output_chs</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_codec_output_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">输出通道句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">input_chs</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_codec_input_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">输入通道句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">*</span><span style="font-size: 10.5pt;">priv</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">void</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">设备私有变量</span></p>
</td>
</tr>
</tbody>
</table>
<p style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-family: 'Helvetica'; font-size: 15pt; color: #333333;"> ringbuffer_t</span></p>
<table style="table-layout: auto;">
<tbody>
<tr>
<th>
<p><span style="font-size: 10.5pt;">成员</span></p>
</th>
<th>
<p><span style="font-size: 10.5pt;">类型</span></p>
</th>
<th>
<p><span style="font-size: 10.5pt;">描述</span></p>
</th>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">buffer</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint8_t *</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">环形缓冲区地址</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">size</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">环形缓冲区大小</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">write</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">环形缓冲区当前写指针位置</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">read</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">环形缓冲区当前读指针位置</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">data_len</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">环形缓冲区当前可读数据长度</span></p>
</td>
</tr>
</tbody>
</table>
<p style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-family: 'Helvetica'; font-size: 15pt; color: #333333;"> csi_codec_output_t</span></p>
<table style="table-layout: auto;">
<tbody>
<tr>
<th>
<p><span style="font-size: 10.5pt;">成员</span></p>
</th>
<th>
<p><span style="font-size: 10.5pt;">类型</span></p>
</th>
<th>
<p><span style="font-size: 10.5pt;">描述</span></p>
</th>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">codec</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_codec_t</span><span style="font-size: 10.5pt;"> *</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">CODEC设备句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">ch_idx</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">当前通道的序号</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">callback</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">void (</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">callback)(</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">csi_codec_output_t</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;"> </span><span style="font-size: 10.5pt;">output, </span><span style="font-size: 10.5pt;">csi_codec_event_t</span><span style="font-size: 10.5pt;"> event, void *</span><span style="font-size: 10.5pt;">arg</span><span style="font-size: 10.5pt;">)</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">当前通道的回调</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">arg</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">void *</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">当前通道的用户参数</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">ring_buf</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">ringbuffer_t</span><span style="font-size: 10.5pt;"> *</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">当前通道的缓冲器句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">period</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">设置完成多少数据发送上报周期</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">sound_channel_num</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">声道数</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">state</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_state_t</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">当前通道的状态</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">dma</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_dma_ch_t</span><span style="font-size: 10.5pt;"> *</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">当前通道的DMA句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">next</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">struct</span><span style="font-size: 10.5pt;"> </span><span style="font-size: 10.5pt;">csi_codec_output</span><span style="font-size: 10.5pt;"> *</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">下一个输出通道的地址指针</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">priv</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">void *</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">设备私有变量</span></p>
</td>
</tr>
</tbody>
</table>
<p style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-family: 'Helvetica'; font-size: 15pt; color: #333333;"> csi_codec_input_t</span></p>
<table style="table-layout: auto;">
<tbody>
<tr>
<th>
<p><span style="font-size: 10.5pt;">成员</span></p>
</th>
<th>
<p><span style="font-size: 10.5pt;">类型</span></p>
</th>
<th>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333; font-weight: bold;">描述</span></p>
</th>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">codec</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_codec_t</span><span style="font-size: 10.5pt;"> *</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">CODEC</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">设备句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">ch_idx</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">当前通道的序号</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">callback</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">void (</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">callback)(</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">csi_codec_input_t</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;"> </span><span style="font-size: 10.5pt;">input, </span><span style="font-size: 10.5pt;">csi_codec_event_t</span><span style="font-size: 10.5pt;"> event, void *</span><span style="font-size: 10.5pt;">arg</span><span style="font-size: 10.5pt;">)</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">当前通道的回调</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">arg</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">void *</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">当前通道的用户参数</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">ring_buf</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">ringbuffer_t</span><span style="font-size: 10.5pt;"> *</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">当前通道的缓冲器句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">period</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">设置完成多少数据接收</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">上报周期</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">sound_channel_num</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">uint32_t</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">声道数</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">state</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_state_t</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">当前通道的状态</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">dma</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">csi_dma_ch_t</span><span style="font-size: 10.5pt;"> *</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">当前通道的</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">DMA</span><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">句柄</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">next</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">struct</span><span style="font-size: 10.5pt;"> </span><span style="font-size: 10.5pt;">csi_codec_input</span><span style="font-size: 10.5pt;"> *</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">下一个输入通道的地址指针</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">priv</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">void *</span></p>
</td>
<td>
<p><span style="font-family: 'Helvetica'; font-size: 10.5pt; color: #333333;">设备私有变量</span></p>
</td>
</tr>
</tbody>
</table>
<p> </p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span style="font-family: Helvetica; color: rgb(51, 51, 51);">CODEC设备去初始化</span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> void</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #4271AE;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8E908C;">csi_codec_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8E908C;">uninit</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">csi_codec_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;"> *codec)</span></p>
<p> 功能描述:</p>
<p> codec实例反初始化。该接口会清理并释放相关的软硬件资源。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> codec</span>: 实例句柄。</p>
<p> 返回值:</p>
<p> 无。</p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span></span></span><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道打开</span></span></span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> csi_error_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">csi_codec_input_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">open</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *codec, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">uint32_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">ch_idx</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 功能描述:</p>
<p> 将输入通道的ch句柄注册到codec句柄中。初始化输入通道有关的硬件资源。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> codec</span>: codec实例句柄。</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch</span>: 输入通道的实例句柄。</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch_idx</span>:通道的ID。</p>
<p> 返回值:</p>
<p> 错误码csi_error_t。</p>
<p> </p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span></span></span><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道配置</span></span></span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> csi_error_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">csi_codec_input_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">config</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_config_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">config</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 功能描述:</p>
<p> 根据传入的配置配置输入通道。配置输入通道采样宽度、采样比率、设置缓冲区地址、设置输入通道的输出模式(差分输入还是单端输入)。</p>
<p> 参数</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch</span>:通道实例句柄。</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> config</span>:配置参数。</p>
<p> 返回值:</p>
<p> 错误码csi_error_t。</p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span></span></span><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道注册回调函数</span></span></span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> csi_error_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">csi_codec_input_attach_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">callback</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">void</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *callback, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">void</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">arg</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 功能描述:</p>
<p> 设置输入通道回调函数。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> csi_codec_input_t</span>:输入通道实例句柄。</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> callback:codec</span>:输入通道的事件回调函数(一般在上下文执行)。</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> arg</span>:回调函数参数(可选,由用户定义)。</p>
<p> 返回值:</p>
<p> 错误码csi_error_t。</p>
<p> callback</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> void</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> (*</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">callback)(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *input, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_event_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> event, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">void</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">arg</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 其中 input为输入通道句柄,event 为传给回调函数的事件类型,arg 为用户自定义的回调函数对应的参数。</p>
<p> </p>
<p> codec 回调事件枚举类型csi_codec_event_t定义如下:</p>
<table style="table-layout: auto;">
<tbody>
<tr>
<th>
<p><span style="font-size: 10.5pt;">类型</span></p>
</th>
<th>
<p><span style="font-size: 10.5pt;">说明</span></p>
</th>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">CODEC_EVENT_PERIOD_READ_COMPLETE</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">接收period完成</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">CODEC_EVENT_PERIOD_WRITE_COMPLETE</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">发送period完成</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">CODEC_EVENT_WRITE_BUFFER_EMPTY</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">发送缓冲区已经空</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">CODEC_EVENT_READ_BUFFER_FULL</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">接收缓冲区已经满</span></p>
</td>
</tr>
<tr>
<td>
<p><span style="font-size: 10.5pt;">CODEC_EVENT_TRANSFER_ERROR</span></p>
</td>
<td>
<p><span style="font-size: 10.5pt;">传输错误</span></p>
</td>
</tr>
</tbody>
</table>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体">CODEC</span></span></span><span style="150%"><span style="font-family:宋体">输入通道注销回调函数</span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> void</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #4271AE;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8E908C;">csi_codec_input_detach_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8E908C;">callback</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">)</span></p>
<p> 功能描述:</p>
<p> 注销CODEC 输入通道的回调函数。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch</span>:通道实例句柄。</p>
<p> 返回值:</p>
<p> 无。</p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体">CODEC</span></span></span><span style="150%"><span style="font-family:宋体">输入通道关闭</span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> void</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #4271AE;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8E908C;">csi_codec_input_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8E908C;">close</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #F5871F;">)</span></p>
<p> 功能描述:</p>
<p> 关闭输入通道。调用该接口会马上停止接收数据。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch</span>:通道实例句柄。</p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体">CODEC</span></span></span><span style="150%"><span style="font-family:宋体">输入通道配置DMA</span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> csi_error_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">csi_codec_input_link_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">dma</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_dma_ch_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">dma</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 功能描述:</p>
<p> 输入通道连接DMA。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch</span>:输入通道的实例句柄。</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> dma</span>:dma实例句柄。</p>
<p> 返回:</p>
<p> 错误码csi_error_t。</p>
<p> </p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span></span></span><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">接收输入音频流</span></span></span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> csi_error_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">csi_codec_input_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">start</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 功能描述:</p>
<p> 输入通道开始数据流。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch</span>:输入通道的实例句柄。</p>
<p> 返回值:</p>
<p> 错误码csi_error_t。</p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span></span></span><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">结束接收输入音频流</span></span></span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> csi_error_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">csi_codec_input_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">stop</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 功能描述:</p>
<p> 输入通道结束数据流。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch</span>:输入通道的实例句柄。</p>
<p> 返回值:</p>
<p> 错误码csi_error_t。</p>
<p> </p>
<ul>
<li style="margin-top: 15.3pt; margin-bottom: 10.2pt;"><span style="font-size:16px;"><span lang="EN-US"><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">CODEC</span></span></span></span></span><span style="150%"><span style="font-family:宋体"><span style="color:#333333"><span style="letter-spacing:.15pt">输入通道设置模拟增益</span></span></span></span></span></li>
</ul>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;"> csi_error_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">csi_codec_input_analog_</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">gain</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">(</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">csi_codec_input_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> *</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">ch</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">, </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #8959A8;">uint32_t</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> </span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">val</span><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;">)</span></p>
<p> 功能描述:</p>
<p> 设置输入通道模拟增益。</p>
<p> 参数:</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> ch</span>:输入通道的实例句柄。</p>
<p><span style="font-family: 'Consolas'; font-size: 11.5pt; color: #333333;"> val</span>: 增益的DB值。</p>
<p> 返回值:</p>
<p> 错误码csi_error_t。</p>
<p><span style="font-size:20px;">3、测试程序</span></p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"><span style="font-family: 'Consolas'; font-size: 11.5pt;"> 本测试程序通过RVB</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">2601</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">建立一个</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">通过</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">I</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">2</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">S</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">接口读取</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">ES</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">7210</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">录音</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">测试程序,</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">数据录取结束后将数据打印到串口终端</span><span style="font-family: 'Consolas'; font-size: 11.5pt;">。</span></p>
<p><span style="font-size:16px;">3.1 初始化</span></p>
<p>初始化代码参考wiki上的基本配置信息完成。</p>
<pre>
<code class="language-cpp">csi_codec_input_config_t input_config;
/* init函数的idx参数,请根据soc的实际情况进行选择 */
ret = csi_codec_init(&codec, 0);;
if (ret != CSI_OK) {
return -1;
}
/* input ch config */
csi_codec_input_attach_callback(&codec_input_ch, codec_input_event_cb_fun, NULL);
codec_input_ch.period = INPUT_BUF_SIZE/2;
codec_input_ch.ring_buf = &input_ring_buffer;
csi_codec_input_open(&codec, &codec_input_ch, 0);
input_config.bit_width = 16;
input_config.sample_rate = 8000;
input_config.buffer = input_buf;
input_config.buffer_size = INPUT_BUF_SIZE;
input_config.period = INPUT_BUF_SIZE/2;
input_config.mode = CODEC_INPUT_DIFFERENCE;
csi_codec_input_config(&codec_input_ch,&input_config);
csi_codec_input_link_dma(&codec_input_ch,&dma_ch_input_handle);
csi_codec_input_start(&codec_input_ch);</code></pre>
<p><span style="font-size:16px;">3.2 事件处理</span></p>
<pre>
<code class="language-cpp">static void codec_input_event_cb_fun(csi_codec_input_t *i2s, csi_codec_event_t event, void *arg)
{
if (event == CODEC_EVENT_PERIOD_READ_COMPLETE) {
cb_input_transfer_flag = 1;
}
}
</code></pre>
<p> </p>
<p><span style="font-size:16px;">3.3 数据的显示</span></p>
<pre>
<code class="language-cpp">int i;
uint16_t *p = (uint16_t *)(repeater_data_addr + 24*1024);
for(i=0;i<48*512;i++)
{
if(i%16 == 0)
printf("\n");
printf("%04x ",p<i>);
}
</i></code></pre>
<p><i><span style="font-size:16px;">3.4 通过console调用</span></i></p>
<pre>
<i><code class="language-cpp">static void mic_handler(char *wbuf, int wbuf_len, int argc, char **argv)
{
csi_error_t ret;
csi_codec_input_config_t input_config;
ret = csi_codec_init(&codec, 0);
if (ret != CSI_OK) {
printf("csi_codec_init error\n");
return ;
}
codec_input_ch.ring_buf = &input_ring_buffer;
csi_codec_input_open(&codec, &codec_input_ch, 0);
/* input ch config */
csi_codec_input_attach_callback(&codec_input_ch, codec_input_event_cb_fun, NULL);
input_config.bit_width = 16;
input_config.sample_rate = 8000;
input_config.buffer = input_buf;
input_config.buffer_size = INPUT_BUF_SIZE;
input_config.period = 1024;
input_config.mode = CODEC_INPUT_DIFFERENCE;
csi_codec_input_config(&codec_input_ch, &input_config);
csi_codec_input_analog_gain(&codec_input_ch, 0xbf);
csi_codec_input_link_dma(&codec_input_ch, &dma_ch_input_handle);
printf("start recorder\n");
csi_codec_input_start(&codec_input_ch);
while (new_data_flag < 48) {
if (cb_input_transfer_flag) {
csi_codec_input_read_async(&codec_input_ch, repeater_data_addr + (new_data_flag * 1024), 1024);
cb_input_transfer_flag = 0U;
new_data_flag ++;
}
}
aos_msleep(100);
printf("record sound data: \n");
int i;
uint16_t *p = (uint16_t *)(repeater_data_addr + 24*1024);
for(i=0;i<512;i++)
{
if(i%16 == 0)
printf("\n");
printf("%04x ",p<i>);
}
printf("stop reorder\n");
csi_codec_input_stop(&codec_input_ch);
csi_codec_input_link_dma(&codec_input_ch, NULL);
csi_codec_input_detach_callback(&codec_input_ch);
csi_codec_uninit(&codec);
return;
}
int cli_reg_cmd_ft(void)
{
static const struct cli_command mic_cmd_info = {
"mic",
"mic",
mic_handler,
};
aos_cli_register_command(&mic_cmd_info);
return 0;
}
</i></code></i></pre>
<p><i><i> </i></i></p>
<p><i><i><span style="font-size:20px;">4、实测效果演示:</span></i></i></p>
<p><i><i><span style="font-size:16px;">4.1 录取数据开始</span></i></i></p>
<p><i><i></i></i></p>
<p><i><i> </i></i></p>
<p><i><i><span style="font-size:16px;">4.2 展示数据结束:</span></i></i></p>
<p><i><i></i></i></p>
<p><i><i><span style="font-size:16px;">4.3 波形数据展示</span></i></i></p>
<p><i><i></i></i></p>
<p>赞一个</p>
<p>听着效果怎么样</p> <p>有没有相关的资料能不能共享一下,什么格式的都行</p>
页:
[1]