xujinxi 发表于 2021-7-18 19:55

BLE超低功耗声纹门锁

<p align="center" style="text-align:center"><span style="font-family:Microsoft YaHei;"><span style="font-size:24px;"><b><span lang="EN-US"><span style="color:black">BLE</span></span><span style="color:black">超低功耗声纹门锁</span></b></span></span></p>

<p align="right" style="margin-right:64px; text-align:right"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><b><span style="font-size:12.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">作者:xujinxi</span></span></b></span></span></p>

<p style="margin-right: 64px;">&nbsp;</p>

<p style="margin-right: 64px;"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><b><span style="font-size:14.0pt"><span style="background:white"><span style="font-family:&quot;微软雅黑&quot;,sans-serif"><span style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 一、项目背景</span></span></span></span></b></span></span></p>

<p style="text-indent: 21pt;"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">OnSemi</span></span><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">提供的RSL10蓝牙模组,应该为业界最小的蓝牙低功耗模组,并且该模组有业界最优的低功耗管理,且开发套件的sensor外设丰富,为各种奇思妙想的实现提供了非常理想的平台。</span></span></span></span></p>

<p style="text-indent: 21pt;">&nbsp;</p>

<p style="text-indent: 21pt;"><strong><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">二、作品简介</span></span></span></span></strong></p>

<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">RSL10</span></span><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">蓝牙模组具有超低功耗以及方便使用的音频接口。搭载传感器以及相关的参考驱动代码,可以可靠、便捷的实现工程师的奇思妙想,深受工程师欢迎。EEWORLD+OnSemi开展的创意设计大赛,为广大工程师朋友提供施展才华的舞台。</span></span></span></span></p>

<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">本项目构思使用RSL10蓝牙模组搭载的DMIC和IMU单元。用于智能门锁户外敲门的识别和语音拾取,并发送至室内接收端。室内的RSL10蓝牙模组则接收户外传来的语音数据,通过串口传递至PC,PC使用该语音数据访问语音平台,识别语音指令。如果是正确的&ldquo;开门&rdquo;指令,则&rdquo;开门&rdquo;信号通过串口经室内RSL10蓝牙模组,再通过BLE传输至户外RSL10蓝牙模组,进而发出门锁开启信号。完成整个低功耗语音门锁的实现</span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><b><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp; 三、<span style="font-family:&quot;微软雅黑&quot;,sans-serif">系统框图和各部分功能说明</span></span></span></b></span></span></p>

<p style="text-indent:21.0pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">整个体统主要由RSL10、IMU、DMIC等传感器接口组成,如下为系统电子系统框图:USB端口连接Jlink,Jlink通过USB CDC建立与PC的通讯路径,RSL10户外语音采集板将采集的语音数据通过蓝牙传至室内RSL10模组,再通过Jlink的串口上传至PC Python代码,用于数据分析和处理。PC将数据推送至百度语音识别引擎,识别结果返回给PC。最后下发至室内和户外RSL10模组做相应操作。</span></span></span></span></p>

<p style="text-indent:21.0pt; text-align:justify">&nbsp; &nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><strong><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">&nbsp;&nbsp;&nbsp; 四、作品源码和案例中处理的传感器数据</span></span></span></span></strong></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"></p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p>/* ----------------------------------------------------------------------------<br />
&nbsp;* Copyright (c) 2015-2017 Semiconductor Components Industries, LLC (d/b/a<br />
&nbsp;* ON Semiconductor), All Rights Reserved<br />
&nbsp;*<br />
&nbsp;* Copyright (C) RivieraWaves 2009-2016<br />
&nbsp;*<br />
&nbsp;* This module is derived in part from example code provided by RivieraWaves<br />
&nbsp;* and as such the underlying code is the property of RivieraWaves [a member<br />
&nbsp;* of the CEVA, Inc. group of companies], together with additional code which<br />
&nbsp;* is the property of ON Semiconductor. The code (in whole or any part) may not<br />
&nbsp;* be redistributed in any form without prior written permission from<br />
&nbsp;* ON Semiconductor.<br />
&nbsp;*<br />
&nbsp;* The terms of use and warranty for this code are covered by contractual<br />
&nbsp;* agreements between ON Semiconductor and the licensee.<br />
&nbsp;*<br />
&nbsp;* This is Reusable Code.<br />
&nbsp;*<br />
&nbsp;* ----------------------------------------------------------------------------<br />
&nbsp;* app.c<br />
&nbsp;* - Main application file<br />
&nbsp;* ----------------------------------------------------------------------------<br />
&nbsp;* $Revision: 1.25 $<br />
&nbsp;* $Date: 2017/12/05 16:02:54 $<br />
&nbsp;* ------------------------------------------------------------------------- */</p>

<p>//20210626 add dmic support by hhz<br />
#include &quot;app.h&quot;<br />
#include &lt;printf.h&gt;</p>

<p>#define DMIC_DATA_WIDTH_16&nbsp;&nbsp; &nbsp;//16bit DMIC data-- &nbsp; DMIC_DATA_WIDTH_8 8bit DMIC data</p>

<p>#ifdef DMIC_DATA_WIDTH_8&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//FS = 16000hz,data width = int8_t,2 second record data =16000*1 =16000 samples<br />
&nbsp;&nbsp; &nbsp;#define DMIC_BUF_SIZE 16000&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//100 sample, equal 200 bytes data(int16_t)<br />
#else<br />
&nbsp;&nbsp; &nbsp;#define DMIC_BUF_SIZE 16000&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//FS = 16000hz,data width = int16_t,2 second record data =16000*2 =32000 s<br />
#endif</p>

<p>#define BLE_TX_PACKET_SIZE 100&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//200</p>

<p>uint32_t output_flag = 0;<br />
uint32_t data_ready_flag = 0;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//init not data ready until interruption receive DMIC_BUF_SIZE data from DMIC</p>

<p>int16_t dmic_value_scope_int16 = 0;</p>

<p>#ifdef DMIC_DATA_WIDTH_8<br />
&nbsp;&nbsp; &nbsp;int8_t dmic_value_buf = {0};&nbsp;&nbsp; &nbsp;//d0_msb,d0_lsb,d1_msb,d1_lsb...<br />
#else<br />
&nbsp;&nbsp; &nbsp;int16_t dmic_value_buf = {0};&nbsp;&nbsp; &nbsp;//d0_msb,d0_lsb,d1_msb,d1_lsb...<br />
#endif</p>

<p>//dmic_value_buf = lsb, dmic_value_buf = msb<br />
uint8_t* dmic_buf_pointer_uint8 = (uint8_t *)dmic_value_buf;</p>

<p>uint32_t j = 0,k = 0;</p>

<p>uint32_t dmic_packet_num = 0;<br />
uint32_t tx_cnt = 0;<br />
uint32_t record_sample_num = 0;<br />
//+ lsb_num,~,~,msb_num packet num uint32 lsb fist<br />
uint8_t* pointer_record_sample_num_uint8 = (uint8_t *)(&amp;record_sample_num);</p>

<p>uint8_t syn_head_array = {0x55,0x55,0x55,0x55};&nbsp;&nbsp; &nbsp;//+ lsb_num,~,~,msb_num packet num uint32 lsb fist<br />
uint8_t syn_end_array &nbsp;= {0xaa,0xaa,0xaa,0xaa};&nbsp;&nbsp; &nbsp;//+ lsb_num,~,~,msb_num packet num uint32 lsb fist<br />
uint8_t head_sended_flag = 0;<br />
uint8_t end_sended_flag = 0;</p>

<p>static uint8_t asr_flag = 0;</p>

<p>void DMIC_OUT_OD_IN_IRQHandler(void)<br />
{<br />
&nbsp; &nbsp; static int32_t &nbsp;i = 0;</p>

<p>&nbsp; &nbsp; //dmic_value_scope_int32 = (int32_t)AUDIO-&gt;DMIC0_DATA;<br />
&nbsp; &nbsp; //dmic_value_scope_int16 = (int16_t)((dmic_value_scope_int32 &gt;&gt; 1) &amp; 0xffff);<br />
&nbsp; &nbsp; //dmic_value_scope_int16 = (int16_t)((dmic_value_scope_int32) &amp; 0xffff);<br />
&nbsp; &nbsp; //dmic_value_scope_int16 = (int16_t)(dmic_value_scope_int32);<br />
&nbsp; &nbsp; //PRINTF(&quot;%d = %08x = %d\n&quot;,dmic_value_scope_int32,dmic_value_scope_int32,dmic_value_scope_int16);</p>

<p>&nbsp; &nbsp; //dmic_value_scope_int16 = (int16_t)AUDIO-&gt;DMIC0_DATA;<br />
&nbsp; &nbsp; dmic_value_scope_int16 = (int16_t)((uint16_t)(AUDIO-&gt;DMIC_DATA &amp; 0x0000ffff));<br />
&nbsp; &nbsp; Sys_GPIO_Toggle(3);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//test frame frequency</p>

<p>&nbsp; &nbsp; //dmic_value_scope_int16 = dmic_packet_num;<br />
&nbsp; &nbsp; //PRINTF(&quot;%d = %08x\n&quot;,dmic_value_scope_int16,dmic_value_scope_int16);</p>

<p>&nbsp; &nbsp; if(dmic_packet_num &lt; DMIC_BUF_SIZE)<br />
&nbsp; &nbsp; {<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#ifdef DMIC_DATA_WIDTH_8&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//FS = 16000hz,data width = int8_t,2 second record data =16000*1 =16000 samples<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;dmic_value_buf = (int8_t)dmic_value_scope_int16;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#else<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;dmic_value_buf = dmic_value_scope_int16;<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//dmic_value_buf = dmic_packet_num;<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#endif</p>

<p>&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;dmic_packet_num++;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; else<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;data_ready_flag = 1;<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//asr_flag = 2;<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//NVIC_DisableIRQ(DMIC_OUT_OD_IN_IRQn);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//close DMIC interrupt<br />
&nbsp; &nbsp; }</p>

<p>}</p>

<p><br />
void DIO0_IRQHandler(void)<br />
{<br />
&nbsp; &nbsp; //static uint8_t ignore_next_dio_int = 1;<br />
&nbsp; &nbsp; PRINTF(&quot;DIO0 INTERRUPT\n&quot;);<br />
&nbsp; &nbsp; asr_flag ++;</p>

<p>&nbsp; &nbsp; if(asr_flag == 2)<br />
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;NVIC_EnableIRQ(DMIC_OUT_OD_IN_IRQn);<br />
}</p>

<p><br />
int main(void)<br />
{<br />
&nbsp; &nbsp; uint32_t length;<br />
&nbsp; &nbsp; uint8_t temp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//for uart</p>

<p>&nbsp; &nbsp; static uint8_t time_cnt = 0;</p>

<p>&nbsp; &nbsp; /* Initialize the system */<br />
&nbsp; &nbsp; App_Initialize();</p>

<p>&nbsp; &nbsp; //setting dio3 as dmic interrupt toggle output for sample rate conform<br />
&nbsp; &nbsp; Sys_DIO_Config(3, DIO_MODE_GPIO_OUT_0);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//CLOCK OUTPUT<br />
&nbsp; &nbsp; //Sys_DIO_Config(3, DIO_MODE_AUDIOCLK);</p>

<p>&nbsp; &nbsp; //Sys_DIO_Config(LED_DIO_GREEN, DIO_MODE_GPIO_OUT_0);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//GREEN LED<br />
&nbsp; &nbsp; Sys_GPIO_Toggle(LED_DIO_GREEN);<br />
&nbsp; &nbsp; Sys_GPIO_Set_High(LED_DIO_GREEN);</p>

<p>&nbsp; &nbsp; NVIC_EnableIRQ(DIO0_IRQn);</p>

<p>&nbsp; &nbsp; PRINTF(&quot;HARDWARE INIT OK !\n&quot;);&nbsp;&nbsp; &nbsp;//hhz<br />
&nbsp; &nbsp; PRINTF(&quot;into main loop !\n&quot;);&nbsp;&nbsp; &nbsp;//hhz</p>

<p>&nbsp; &nbsp; /* Main application loop:<br />
&nbsp; &nbsp; &nbsp;* - Run the kernel scheduler<br />
&nbsp; &nbsp; &nbsp;* - Send notifications for the battery voltage and RSSI values<br />
&nbsp; &nbsp; &nbsp;* - Refresh the watchdog and wait for an interrupt before continuing */<br />
&nbsp; &nbsp; while (1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; Kernel_Schedule();</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; /*if(asr_flag == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;NVIC_EnableIRQ(DMIC_OUT_OD_IN_IRQn);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//PRINTF(&quot;NVIC_EnableIRQ\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(asr_flag == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;NVIC_DisableIRQ(DMIC_OUT_OD_IN_IRQn);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//PRINTF(&quot;NVIC_DisableIRQ\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }*/</p>

<p><br />
&nbsp; &nbsp; &nbsp; &nbsp; if (unhandled_packets != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (UART_FillTXBuffer(unhandled_packets-&gt;length,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unhandled_packets-&gt;data) !=<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UART_ERRNO_OVERFLOW)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unhandled_packets = removeNode(unhandled_packets);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; if (ble_env.state == APPM_CONNECTED)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (app_env.send_batt_ntf &amp;&amp; bass_support_env.enable)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app_env.send_batt_ntf = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Batt_LevelUpdateSend(0, app_env.batt_lvl, 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (cs_env.sentSuccess)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Copy data from the UART RX buffer to the TX buffer<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length = UART_EmptyRXBuffer(temp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (length &gt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Split buffer into two packets when it&#39;s greater than<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // packet size<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (length &gt; PACKET_SIZE)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CS_IDX_TX_VALUE_VAL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;temp,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PACKET_SIZE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CS_IDX_TX_VALUE_VAL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;temp,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;length - PACKET_SIZE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CS_IDX_TX_VALUE_VAL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;temp,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;length);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //test dmic first 0~1000 sample data<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((data_ready_flag == 1) &amp; (tx_cnt &lt; DMIC_BUF_SIZE))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;PRINTF(&quot;%d\n&quot;,dmic_value_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;tx_cnt++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if (cs_env.sentSuccess)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (cs_env.sentSuccess &amp; (data_ready_flag == 1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;head_sended_flag = 1;&nbsp;&nbsp; &nbsp;//without head test<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;end_sended_flag = 1;&nbsp;&nbsp; &nbsp;//without end test</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if(head_sended_flag == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PRINTF(&quot;TX:syn_head_array !\n&quot;);&nbsp;&nbsp; &nbsp;//hhz<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS_IDX_TX_VALUE_VAL,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; syn_head_array,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; 4);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS_IDX_TX_VALUE_VAL,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; pointer_record_sample_num_uint8,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; 4);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;head_sended_flag = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;}</p>

<p>#ifdef DMIC_DATA_WIDTH_8<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(tx_cnt=0;tx_cnt &lt; DMIC_BUF_SIZE/BLE_TX_PACKET_SIZE;tx_cnt++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PRINTF(&quot;TX:%d &#39; DMIC packet !\n&quot;,tx_cnt);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS_IDX_TX_VALUE_VAL,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; dmic_buf_pointer_uint8,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; BLE_TX_PACKET_SIZE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;dmic_buf_pointer_uint8 += BLE_TX_PACKET_SIZE;</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PRINTF(&quot;TX:tx dmic watchdog refresh !\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Sys_Watchdog_Refresh();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;}<br />
#else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((data_ready_flag == 1) &amp; (tx_cnt &lt; DMIC_BUF_SIZE*2/BLE_TX_PACKET_SIZE))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//PRINTF(&quot;%d\n&quot;,dmic_value_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;PRINTF(&quot;TX:%d &#39; DMIC packet !\n&quot;,tx_cnt);</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;CS_IDX_TX_VALUE_VAL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;syn_head_array,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;2);</p>

<p><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS_IDX_TX_VALUE_VAL,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; dmic_buf_pointer_uint8,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; BLE_TX_PACKET_SIZE);</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;dmic_buf_pointer_uint8 += BLE_TX_PACKET_SIZE;</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CS_IDX_TX_VALUE_VAL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;syn_end_array,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;2);</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;tx_cnt++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if((data_ready_flag == 1) &amp; (tx_cnt &gt;= DMIC_BUF_SIZE*2/BLE_TX_PACKET_SIZE))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;data_ready_flag = 0;</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//without head test<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//head_sended_flag = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//end_sended_flag = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;dmic_buf_pointer_uint8 = (uint8_t *)dmic_value_buf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;dmic_packet_num = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;tx_cnt = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;asr_flag = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;NVIC_DisableIRQ(DMIC_OUT_OD_IN_IRQn);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;PRINTF(&quot;close od interrupt,init all flag\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;/*for(tx_cnt=0;tx_cnt &lt; DMIC_BUF_SIZE*2/BLE_TX_PACKET_SIZE;tx_cnt++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PRINTF(&quot;TX:%d &#39; DMIC packet !\n&quot;,tx_cnt);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS_IDX_TX_VALUE_VAL,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; dmic_buf_pointer_uint8,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; BLE_TX_PACKET_SIZE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;dmic_buf_pointer_uint8 += BLE_TX_PACKET_SIZE;</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PRINTF(&quot;TX:tx dmic watchdog refresh !\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Sys_Watchdog_Refresh();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;}*/</p>

<p>#endif<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((end_sended_flag == 0) &amp; (data_ready_flag == 0))&nbsp;&nbsp; &nbsp;//all dmic data have been sended over BLE<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;PRINTF(&quot;TX:syn_end_array !\n&quot;);&nbsp;&nbsp; &nbsp;//hhz<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;CustomService_SendNotification(ble_env.conidx,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS_IDX_TX_VALUE_VAL,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; syn_end_array,<br />
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; 4);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;//end_sended_flag = 1;</p>

<p><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;head_sended_flag = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;end_sended_flag = 0;</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;dmic_buf_pointer_uint8 = (uint8_t *)dmic_value_buf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;dmic_packet_num = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;tx_cnt = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;asr_flag = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;PRINTF(&quot;close od interrupt,init all flag\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //PRINTF(&quot;TX dmic_value_buf\n&quot;);</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //for(tx_cnt=0;tx_cnt &lt; DMIC_BUF_SIZE;tx_cnt++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //&nbsp;&nbsp; &nbsp;PRINTF(&quot;%d\n&quot;,dmic_value_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //&nbsp;&nbsp; &nbsp;Sys_Watchdog_Refresh();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //}</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data_ready_flag = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Sys_Watchdog_Refresh();</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;&nbsp; &nbsp;//connected</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; Sys_GPIO_Toggle(3);</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; /* Refresh the watchdog timer */<br />
&nbsp; &nbsp; &nbsp; &nbsp; Sys_Watchdog_Refresh();</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; /* Wait for an event before executing the scheduler again */<br />
&nbsp; &nbsp; &nbsp; &nbsp; SYS_WAIT_FOR_EVENT;</p>

<p>&nbsp; &nbsp; }&nbsp;&nbsp; &nbsp;//while(1)<br />
}&nbsp;&nbsp; &nbsp;//main</p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><b><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">&nbsp;&nbsp;&nbsp;&nbsp; 五、视频<span style="font-family:&quot;微软雅黑&quot;,sans-serif">演示</span></span></span></b></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">1</span></span></span><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">、室内机RSL10模组上电;</span></span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">2</span></span></span><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">、户外RSL10 sensor板上电;</span></span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">3</span></span></span><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">、启动PC处理程序,连接室内RSL10模组;</span></span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">4</span></span></span><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">、通过按键启动户外RSL10 sensor模组录音,录音数据通过BLE传输至室内RSL10模组,RSL10模组转接至PC,PC转百度语音识别引擎识别,识别结果返回PC,并做识别结果演示。</span></span></span></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif">演示视频链接如下:</span></span></span></span></p>

<p><iframe allowfullscreen="true" frameborder="0" height="450" src="//player.bilibili.com/player.html?bvid=1Ff4y1j7KW&amp;page=1" style="background:#eee;margin-bottom:10px;" width="750"></iframe></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">B</span></span></span><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">站:<a href="https://www.bilibili.com/video/BV1Ff4y1j7KW?share_source=copy_web" style="color:#0563c1; text-decoration:underline"><span style="color:black">https://www.bilibili.com/video/BV1Ff4y1j7KW?share_source=copy_web</span></a></span></span></span> </span></span></p>

<p>&nbsp;</p>

<p><iframe allowfullscreen="true" frameborder="0" height="450" src="http://player.youku.com/embed/XNTE4MzEzNDMwNA" style="background:#eee;margin-bottom:10px;" width="750"></iframe></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif"><span style="color:black">优酷:https://v.youku.com/v_show/id_XNTE4MzEzNDMwNA==.html</span></span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><b><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">&nbsp;&nbsp;&nbsp; 六、项目总结</span></span></b></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><b>&nbsp;&nbsp;&nbsp;&nbsp; </b><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif">RSL10</span></span><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑 Light&quot;,sans-serif">开发板撘载的多种sensor:例如IMU,DMIC,温度,湿度等传感器,在简单或者复杂环境下,可以同时采集多种数据用于数据分析,以找出环境与传感器的数据关系,从而方便电子设备辨别环境或者动作,实现电子系统对环境和动作的感知。相关的代码例程和sensor硬件DEMO,方便工程师将传感器集成进原来系统内,进而减少时间浪费,快速评估传感器,赞</span></span><b><span lang="EN-US" style="font-size:14.0pt"><span style="font-family:&quot;Segoe UI Emoji&quot;,sans-serif">&#128077;</span></span></b><b><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">!</span></span></b></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;,serif"><b><span style="font-size:14.0pt"><span style="font-family:&quot;微软雅黑&quot;,sans-serif">&nbsp; &nbsp; </span></span></b></span></span></p>

<p style="text-align:justify"><strong><span style="font-family:Microsoft YaHei;"><span style="font-size:16px;">本项目只完成了户外RSL10模组DMIC数据采集,DMIC数据BLE传输至室内RSL10模组,RSL10通过串口传输音频数据到PC,并通过百度语音识别引擎完成语音识别,并输出识别结果。剩余功能未完成。另DMIC数据以及传输可靠性还需优化,成功率较低。</span></span></strong></p>

w494143467 发表于 2021-7-19 14:38

<p>头一个用到了音频功能!</p>

cruelfox 发表于 2021-7-19 20:58

<p>语音采样率用的多少?8-bit还是16-bit?</p>

<p>感觉BLE要实时传输音频,带宽很吃紧。</p>

xujinxi 发表于 2021-7-19 21:29

cruelfox 发表于 2021-7-19 20:58
语音采样率用的多少?8-bit还是16-bit?

感觉BLE要实时传输音频,带宽很吃紧。

<p>没做实时的,我用16bit 16khz配置。另外我的Python没用好,接收不稳定,要做实时就更不好办了。</p>

客户专用 发表于 2021-7-27 11:41

xujinxi 发表于 2021-7-19 21:29
没做实时的,我用16bit 16khz配置。另外我的Python没用好,接收不稳定,要做实时就更不好办了。

<p>BLE语音实时传输,RSL10有一套remote mic sample 可以了解一下。时延低至40ms。采样率16kHz使用G722编码</p>

xujinxi 发表于 2021-8-3 09:06

客户专用 发表于 2021-7-27 11:41
BLE语音实时传输,RSL10有一套remote mic sample 可以了解一下。时延低至40ms。采样率16kHz使用G722编码
...

<p>那还不错,周末找时间试试</p>

jhearing 发表于 2022-2-26 09:24

您好,我的DMIC 一直没有数据,我不太懂硬件,付费求助,我要的是DMIC进,OD出,DMA方式
页: [1]
查看完整版本: BLE超低功耗声纹门锁