描述
<h3><span class="colour" style="font-size:16px;">先不描述了,先上图!^.^</span></h3>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/0oAXJNw0RLXewGaDyMkEgyQ2Y75HPFN1QgT03RWu.jpeg" alt="" width="950" height="534"></h3>
<p> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">* 1、项目功能介绍</h3>
<p></p><hr class="horizontal-splitline normal-bold-2"><p> </p>
<p style="padding-left:40px;"><span style="color:#000000;font-size:16px;">基于启英泰伦离线语音模组CI-C22GS02S的凉习智能风扇LX02,</span><span style="font-size:16px;">改造家里的老风扇,动嘴不动手</span></p>
<ul><li style="list-style-type:none;">
<ul><li style="list-style-type:none;">
<ul><li style="list-style-type:none;">
<ul><li>通过语音识别技术,无须联网即可”动动嘴“实现开关机、档位控制。</li>
<li>同时它还保留了实体按键,可以完美改造家里的老风扇。</li>
<li>按键下面搭配了插件的LED灯,可以根据原有的按键高低调整,</li>
<li>3个档位对应实现亮灯,方便识别当前档位;</li>
<li>值得一提的是,通过合理选择LED限流电阻,LED灯在夜晚也并不刺眼,睡觉也不会受到影响。</li>
</ul></li>
</ul></li>
</ul></li>
</ul><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="font-size:16px;"><span style="font-size:36px;">”<span style="font-size:24px;color:#e67e23;">它</span></span>,叫<span style="color:#e67e23;">小橘子</span>,是一个住在老风扇里的新时代小精灵。它能让老风扇听懂”新“声音,一个指令,一句话,言出必达。</span>还搭载了儿时听到小铃声,在休闲乘凉之际重温孩提时光。还有几个幽默小功能哦,亟待您的发现~<span style="font-size:36px;">“</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;">基本参数:</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;">类型:4键3档; 0 1 2 3</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;">安装尺寸:键间尺寸18mm</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;">供电:AC220V</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*2、项目属性</h3>
<hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">项目首次公开。是原创。项目未曾在其他比赛获奖。项目未在学校参加答辩。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="color:#95a5a6;font-size:14px;">注:请说明项目是否首次公开;项目是否为原创;项目是否曾经在其他比赛中获奖,若有获奖则叙述获奖详情;项目是否在学校参加过答辩。</span></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">* 3、开源协议</h3>
<hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#95a5a6;"><span style="font-size:14px;">GPL3.0</span></span></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*4、硬件部分</h3>
<hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><strong>4.1、3个继电器IO</strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/nNdJM1cZRXjMbB9iiuAvHnksaEgx5RLwyNkbeLgK.jpeg" alt="" width="500" height="339"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;">采用模块的PWM3\PWM4\PWM5作为继电器控制端(RLY_C1、2、3)。<strong>主控这里记得引出MCLK引脚,这个是烧录程序必备的。</strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><strong>4.2、4个按键IO</strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:16px;">模组CI-C22GS02S(<a href="https://item.szlcsc.com/2879102.html" target="_blank">C2759836</a>)本来IO口引出的不多,有两个串口,真正运行时本项目用不上串口。故想把它作为按键IO来使用,通过查询它的手册 :</span><a href="https://item.szlcsc.com/2879102.html" target="_blank"><span style="font-size:16px;">模组CI-C22GS02S</span></a> 发现可行</p>
<table style="border-collapse:collapse;width:91.4076%;height:197px;margin-left:40px;"><tr style="height:22px;padding-left:40px;"><td style="width:11.7036%;height:22px;padding-left:40px;">管脚号</td>
<td style="width:12.2299%;height:22px;padding-left:40px;">管脚名称</td>
<td style="width:13.9842%;height:22px;padding-left:40px;">I/O类型</td>
<td style="width:14.5691%;height:22px;padding-left:40px;">IO驱动能力</td>
<td style="width:16.9667%;height:22px;padding-left:40px;">IO上电默认状态</td>
<td style="width:26.0327%;height:22px;padding-left:40px;">功能定义</td>
</tr><tr style="height:22px;padding-left:40px;"><td style="width:11.7036%;height:22px;padding-left:40px;">……</td>
<td style="width:12.2299%;height:22px;padding-left:40px;"> </td>
<td style="width:13.9842%;height:22px;padding-left:40px;"> </td>
<td style="width:14.5691%;height:22px;padding-left:40px;"> </td>
<td style="width:16.9667%;height:22px;padding-left:40px;"> </td>
<td style="width:26.0327%;height:22px;padding-left:40px;"> </td>
</tr><tr style="height:22px;padding-left:40px;"><td style="width:11.7036%;height:22px;padding-left:40px;">6</td>
<td style="width:12.2299%;height:22px;padding-left:40px;">RX0 </td>
<td style="width:13.9842%;height:22px;padding-left:40px;">IO,T+U</td>
<td style="width:14.5691%;height:22px;padding-left:40px;">4mA</td>
<td style="width:16.9667%;height:22px;padding-left:40px;">IN,T+U</td>
<td style="width:26.0327%;height:22px;padding-left:40px;">1.UART0_RX 2.GPIO1_7</td>
</tr><tr style="height:22px;padding-left:40px;"><td style="width:11.7036%;height:22px;padding-left:40px;">7</td>
<td style="width:12.2299%;height:22px;padding-left:40px;">TX0</td>
<td style="width:13.9842%;height:22px;padding-left:40px;">IO,T+U</td>
<td style="width:14.5691%;height:22px;padding-left:40px;">4mA</td>
<td style="width:16.9667%;height:22px;padding-left:40px;">IN,T+U</td>
<td style="width:26.0327%;height:22px;padding-left:40px;">1.UART0_TX 2.GPIO2_0</td>
</tr><tr style="height:22px;padding-left:40px;"><td style="width:11.7036%;height:22px;padding-left:40px;">……</td>
<td style="width:12.2299%;height:22px;padding-left:40px;"> </td>
<td style="width:13.9842%;height:22px;padding-left:40px;"> </td>
<td style="width:14.5691%;height:22px;padding-left:40px;"> </td>
<td style="width:16.9667%;height:22px;padding-left:40px;"> </td>
<td style="width:26.0327%;height:22px;padding-left:40px;"> </td>
</tr><tr style="height:22px;padding-left:40px;"><td style="width:11.7036%;height:22px;padding-left:40px;">10</td>
<td style="width:12.2299%;height:22px;padding-left:40px;">TX1</td>
<td style="width:13.9842%;height:22px;padding-left:40px;">IO,T+U</td>
<td style="width:14.5691%;height:22px;padding-left:40px;">4mA</td>
<td style="width:16.9667%;height:22px;padding-left:40px;">IN,T+U</td>
<td style="width:26.0327%;height:22px;padding-left:40px;">1.UART1_TX 2.I2C0_SCL 3.GPIO3_0</td>
</tr><tr style="height:22px;padding-left:40px;"><td style="width:11.7036%;height:22px;padding-left:40px;">11</td>
<td style="width:12.2299%;height:22px;padding-left:40px;">RX1</td>
<td style="width:13.9842%;height:22px;padding-left:40px;">IO,T+U</td>
<td style="width:14.5691%;height:22px;padding-left:40px;">4mA</td>
<td style="width:16.9667%;height:22px;padding-left:40px;">IN,T+U</td>
<td style="width:26.0327%;height:22px;padding-left:40px;">1.UART1_RX 2.I2C0_SDA 3.GPIO3_1</td>
</tr></table><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="font-size:16px;">串口0和串口1的管脚都支持普通IO口的功能,故可以用作检测按键输入。引脚上使用TX1作为0档开关按键,RX1作为1档开关,TX0作为2档开关,RX作为3档开关。</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><strong><span style="font-size:16px;">4.3、继电器驱动</span></strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="font-size:16px;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/SsmNI9dWH7WN0PBEniJURrKdGsqLOmhICFO7JaIK.jpeg" alt="" width="485" height="387"></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;">采用NUD3105(<a href="https://item.szlcsc.com/15566.html" target="_blank">C14894</a>)作为继电器的驱动,这个驱动芯片内部自带了MOS、限流电阻、反向的二极管等,可以很好驱动继电器且不影响MCU,极大的节省了多个元器件。非常适合我们手工撸板的DIY玩家。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><strong>4.4、PCB分区</strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;">由于风扇外壳的部分很小,按键和继电器在一块上面的话,外壳就放不下了,只好把板子分为两个部分,拿到板子后裁开两块,飞线连接。这样比较好适配风扇的外壳。</p>
<table style="border-collapse:collapse;width:98.3184%;height:686px;"><tr style="height:664px;"><td style="width:49.2367%;text-align:right;height:664px;" colspan="2">
<p><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/TZxPhT7XAU29xURUKRuNgiQkjNLkGFrsaGwxtFsy.jpeg" alt="" width="1000" height="642"></p>
<p style="text-align:center;">沿虚线剪开</p>
</td>
</tr><tr style="height:22px;"><td style="width:49.2367%;height:22px;">
<p><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/3CFSm3BkAE0QtRxPHBYai4saYol8061Gxmdg4AUD.jpeg" alt="" width="500" height="281"></p>
<p style="text-align:center;">基本完成的</p>
</td>
<td style="width:49.2367%;height:22px;text-align:center;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/eK7xiAJ3skr4tHdzGTZfFtxya5XvkB3urC1aKLLf.jpeg" alt="" width="500" height="281">裁开的板子</td>
</tr></table><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*5、软件部分</h3>
<hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><strong><span style="font-size:14px;">附件有本案的修改好的SDK,可以直接下载烧录,完美复制拥有你的“<span style="color:#e67e23;">小橘子</span>”,想要个性化修改的小伙伴继续往下看,希望可以帮到你。</span></strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><strong><span style="font-size:18px;">5.1继电器部分:</span></strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><strong>5.1.1、初始化继电器io</strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> relay_init(<span style="color:#ba372a;">void</span>)<span style="color:#2dc26b;">//PWM3-relay1-GPIO1_4 ,PWM4-relay2-GPIO1_5,PWM5-relay3-GPIO1_6</span></span></code></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><code><span style="color:#000000;"> {</span></code><br><code><span style="color:#000000;"> <span style="color:#2dc26b;">//以下代码控制GPIO输出模式</span></span></code><br><code><span style="color:#000000;"> Scu_SetDeviceGate((<span style="color:#ba372a;">unsigned int)</span><em><span style="color:#3598db;">GPIO1</span></em><span style="color:#3598db;"><span style="color:#000000;">,</span></span><em><span style="color:#3598db;">ENABLE</span></em>);</span></code><br><code><span style="color:#000000;"> Scu_SetIOReuse(<em><span style="color:#3598db;">PWM3_PAD</span></em>,<em><span style="color:#3598db;">FIRST_FUNCTION</span></em>);</span></code><br><code><span style="color:#000000;"> Scu_SetIOPull(<em><span style="color:#3598db;">PWM3_PAD</span></em><span style="color:#3598db;"><span style="color:#000000;">,</span></span><em><span style="color:#3598db;">DISABLE</span></em>);</span></code><br><code><span style="color:#000000;"> Scu_SetIOReuse(<em><span style="color:#3598db;">PWM4_PAD</span></em>,<em><span style="color:#3598db;">FIRST_FUNCTION</span></em>);</span></code><br><code><span style="color:#000000;"> Scu_SetIOPull(<em><span style="color:#3598db;">PWM4_PAD</span></em>,<em><span style="color:#3598db;">DISABLE</span></em>);</span></code><br><code><span style="color:#000000;"> Scu_SetIOReuse(<em><span style="color:#3598db;">PWM5_PAD<span style="color:#000000;">,</span>FIRST_FUNCTION</span></em>);</span></code><br><code><span style="color:#000000;"> Scu_SetIOPull(<em><span style="color:#3598db;">PWM5_PAD</span></em><span style="color:#3598db;"><span style="color:#000000;">,</span></span><em><span style="color:#3598db;">DISABLE</span></em>);</span></code><br><code><span style="color:#000000;"> gpio_set_output_mode(<em><span style="color:#3598db;">GPIO1,gpio_pin_4</span></em><span style="color:#3598db;"><span style="color:#000000;">|</span></span><em><span style="color:#3598db;">gpio_pin_5</span></em><span style="color:#3598db;"><span style="color:#000000;">|</span></span><em><span style="color:#3598db;">gpio_pin_6</span></em>);</span></code></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><code><span style="color:#000000;">}</span></code></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><strong>5.1.2、继电器电器控制函数,GPIO高低输出</strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> Relay1_OFF(<span style="color:#ba372a;">void</span>){gpio_set_output_level_single(GPIO1,gpio_pin_4,0);} <span style="color:#2dc26b;"> //输出低电平</span></span></code><br><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> Relay2_OFF(<span style="color:#ba372a;">void</span>){gpio_set_output_level_single(GPIO1,gpio_pin_5,0);} <span style="color:#2dc26b;">//输出低电平</span></span></code><br><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> Relay3_OFF(<span style="color:#ba372a;">void</span>){gpio_set_output_level_single(GPIO1,gpio_pin_6,0);} <span style="color:#2dc26b;">//输出低电平</span></span></code></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> Relay1_ON(<span style="color:#ba372a;">void</span>){gpio_set_output_level_single(GPIO1,gpio_pin_4,1);} <span style="color:#2dc26b;"> //输出高电平</span></span></code><br><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> Relay2_ON(<span style="color:#ba372a;">void</span>){gpio_set_output_level_single(GPIO1,gpio_pin_5,1);} <span style="color:#2dc26b;"> //输出高电平</span></span></code><br><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> Relay3_ON(<span style="color:#ba372a;">void</span>){gpio_set_output_level_single(GPIO1,gpio_pin_6,1);} <span style="color:#2dc26b;">//输出高电平</span></span></code></p>
<p><strong>5.1.3、档位控制函数,调用如:Gear(0);//0档,关闭</strong></p>
<p style="padding-left:40px;"><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> Gear(<span style="color:#ba372a;">unsigned char</span> GearNum)</span></code><br><code><span style="color:#000000;">{ </span></code></p>
<p style="padding-left:40px;"><code><span style="color:#000000;"> <span style="color:#ba372a;">if</span>(GearNum==0){Relay1_OFF();Relay2_OFF();Relay3_OFF();}<span style="color:#2dc26b;">//注意要先关后开</span></span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;">if</span>(GearNum==1){Relay2_OFF();Relay3_OFF();Relay1_ON();}</span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;"> if</span>(GearNum==2){Relay1_OFF();Relay3_OFF();Relay2_ON();}</span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;"> if</span>(GearNum==3){Relay1_OFF();Relay2_OFF();Relay3_ON();}</span></code><br><code><span style="color:#000000;">}</span></code></p>
<p> </p>
<p><strong><span style="font-size:18px;">5.2按键部分:</span></strong></p>
<p><strong><span style="font-size:16px;">5.2.1、 按键清单list</span></strong><strong><span style="font-size:16px;">修改gpio_key.c内的 gpio_key_list[]</span></strong></p>
<p style="padding-left:40px;"><code><span style="color:#000000;"><span style="color:#ba372a;">static</span> <span style="color:#2dc26b;">gpio_key_info</span> gpio_key_list[]=</span></code><br><code><span style="color:#000000;">{</span></code><br><code><span style="color:#000000;"> <span style="color:#2dc26b;">//按键一 OFF</span></span></code><br><code><span style="color:#000000;"> {4,I2C0_SCL_PAD,GPIO3,gpio_pin_0},</span></code><br><code><span style="color:#000000;"> <span style="color:#2dc26b;"> //按键二 1档relay1</span></span></code><br><code><span style="color:#000000;"> {1,I2C0_SDA_PAD,GPIO3,gpio_pin_1},</span></code><br><code><span style="color:#000000;"> <span style="color:#2dc26b;"> //按键三 2档relay2</span></span></code><br><code><span style="color:#000000;"> {2,UART0_TX_PAD,GPIO2,gpio_pin_0},</span></code><br><code><span style="color:#000000;"> <span style="color:#2dc26b;"> //按键四 3档relay3</span></span></code><br><code><span style="color:#000000;"> {3,UART0_RX_PAD,GPIO1,gpio_pin_7},</span></code><br><code><span style="color:#000000;">};</span></code></p>
<p><strong><span style="font-size:16px;">5.2.2、</span></strong><strong>添加中断处理程序,</strong></p>
<p style="padding-left:40px;">由于4个按键中分属于不同的GPIOX组,故需要在<span style="color:#3598db;">ci112x_gpio.c</span>文件中的<code><span style="color:#000000;"><span style="color:#ba372a;">void</span> GPIO1_IRQHandler(<span style="color:#ba372a;">void</span>) 、<span style="color:#ba372a;">void</span> GPIO2_IRQHandler(<span style="color:#ba372a;">void</span>) 、<span style="color:#ba372a;">void</span> GPIO3_IRQHandler(<span style="color:#ba372a;">void</span></span>)</code> 三个中断处理函数中添加以下函数:</p>
<p style="padding-left:80px;"><code><span style="color:#000000;">ci_key_gpio_isr_handle();<span style="color:#2dc26b;">//GPIO按键处理函数</span></span></code></p>
<p style="padding-left:40px;">如:</p>
<p style="padding-left:80px;"><code><span style="color:#2dc26b;">/**</span></code><br><code><span style="color:#2dc26b;"> * @brief GPIO1中断处理函数</span></code><br><code><span style="color:#2dc26b;"> *</span></code><br><code><span style="color:#2dc26b;"> */</span></code><br><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> GPIO1_IRQHandler(<span style="color:#ba372a;">void</span>)</span></code><br><code><span style="color:#000000;">{</span></code><br><code><span style="color:#000000;"> ci_key_gpio_isr_handle();<span style="color:#2dc26b;">//GPIO按键处理函数</span></span></code><br><code><span style="color:#000000;">}</span></code></p>
<p style="padding-left:40px;">PS:我下载的SDK的未完成按键的DEMO部分,”<span style="color:#3598db;">ci112x_gpio.c</span>“文件中未引用”<span style="color:#3598db;">ci_key.h</span>“,会导致”<span style="color:#3598db;">ci_key_gpio_isr_handle();//GPIO按键处理函数</span>“报1次警告,在开头添加头文件即可”<span style="color:#ba372a;">#include</span> <span style="color:#3598db;">"ci_key.h"</span>“</p>
<p><strong><span style="font-size:16px;">5.2.</span>3、处理按键消息</strong></p>
<p style="padding-left:40px;">在”<span style="color:#3598db;">user_msg_deal.c</span>"内找到以下按键处理函数</p>
<p style="padding-left:40px;"><code><span style="color:#000000;"><span style="color:#ba372a;">void</span> userapp_deal_key_msg(<span style="color:#ba372a;">sys_msg_key_data_t</span> *key_msg)</span></code><br><code><span style="color:#000000;">{</span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;">if</span>(key_msg-><span style="color:#3598db;">key_index</span> != KEY_NULL)</span></code><br><code><span style="color:#000000;"> {</span></code><br><code><span style="color:#000000;"> ci_loginfo(LOG_USER,"<span style="color:#3598db;">key_value is 0x%x</span> ",key_msg-><span style="color:#3598db;">key_index</span>);</span></code></p>
<p style="padding-left:40px;"><code><span style="color:#000000;"> //按键被按下</span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;">if</span>(<span style="color:#3598db;"><em>MSG_KEY_STATUS_PRESS</em></span> == key_msg-><span style="color:#3598db;">key_status</span>)</span></code><br><code><span style="color:#000000;"> {</span></code><br><code><span style="color:#000000;"> ci_loginfo(LOG_USER,"<span style="color:#3598db;">status : press down\n"</span>);</span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;"> if</span>(key_msg-><span style="color:#3598db;">key_index</span> ==4){Gear(0);}</span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;">if</span>(key_msg-><span style="color:#3598db;">key_index</span> ==1){Gear(1);}</span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;"> if</span>(key_msg-><span style="color:#3598db;">key_index</span> ==2){Gear(2);}</span></code><br><code><span style="color:#000000;"> <span style="color:#ba372a;">if</span>(key_msg-><span style="color:#3598db;">key_index</span> ==3){Gear(3);}</span></code><br><code><span style="color:#000000;"> }</span></code><br><code><span style="color:#000000;"> }</span></code></p>
<p style="padding-left:40px;"><code><span style="color:#000000;">}</span></code></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="font-size:18px;"><strong><span style="color:#000000;">5.3烧录程序的方法:</span></strong></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(1)、下载附件的代码压缩包“CI1122.ZIP”</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(2)、解压到纯英文路径的文件夹或直接解压到桌面</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(3)、依次打开文件夹 “你的桌面\CI112X_SDK_V1.2.5\CI112X_SDK_V1.2.5\sample\internal\sample_1122\firmware ”</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(4)、用TTL串口下载工具连接到板子DEBUG调试口</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(5)、用短路帽短接板子上的BOOT端</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(6)、检查线序,无误后将TTL串口下载工具插入电脑</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(7)、打开“firmware”文件夹内的“<span style="color:#3598db;">打包升级.bat</span>",选择固件升级</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/tFcnvgoklX4uZ1XYFRXiWekYgLHVaQFcUeQ3HDMl.png" alt=""></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(8)、可以看到COM口已经自动识别,然后按下图打上各个选项。(仅更改了代码部分的,只勾选”擦除NV“)</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/JFxqzAuGpjVpRpqjVDf3XbDS3ABUsbxBz5OZ1dps.jpeg" alt="" width="750" height="502"></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(9)、拔掉板子和下载工具直接的GND杜邦线,然后再迅速插回(手动重启上电)即可进入烧录模式。约1-2min左右烧录完毕将会自动重启。进入正常运行</span></p>
<table style="border-collapse:collapse;width:97.3266%;height:396px;margin-left:40px;"><tr style="height:396px;padding-left:40px;"><td style="width:48.7742%;text-align:center;height:396px;padding-left:40px;"><span style="color:#000000;"><img src="//image.lceda.cn/pullimage/sf3E2du18V5p0YClIAqzfeCmhaQMkeRkkPavBLpn.jpeg" alt="" width="750" height="503">正在烧录</span></td>
<td style="width:48.7742%;text-align:center;height:396px;padding-left:40px;"><span style="color:#000000;"><img src="//image.lceda.cn/pullimage/3cnR9VB6FYeS8AxQ07e7xG7ln4k3k5wybfBHmViB.jpeg" alt="" width="750" height="508">烧录完成</span></td>
</tr></table><p style="padding-left:40px;"><span style="color:#000000;font-size:14px;text-align:center;">(10)、正常复原笔者的项目到这一步就结束了。</span></p>
<p style="padding-left:40px;"><span style="color:#000000;font-size:14px;text-align:center;">(11)、如果有自己的想法,个性化更改了代码。需要再eclipse内编译通过,观察到提示bin文件已生成即可。如下显示:</span></p>
<p style="padding-left:80px;"><code><span style="color:#000000;">Finished building: sample_1122.bin</span></code><br><code><span style="color:#000000;">Finished building: sample_1122.siz</span></code><br><code><span style="color:#000000;">Finished building: sample_1122.lst</span></code><br><code><span style="color:#00e4ff;">18:16:48 Build Finished. 0 errors, 0 warnings. (took 15s.27ms)</span></code></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;">(12)、打开“firmware”文件夹内的“打包升级.bat",选择”固件打包“。在弹出的界面继续选择下方的”打包固件“,提示”固件已生成“</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/lO3Ng6SIx0lpC8UlvGhbsluvMlk4GUVO8mHVxKlH.jpeg" alt="" width="774" height="664">(13)、选择固件升级,重复8、9烧录程序</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;"><em>*如遇到未知问题,可以再详细看看厂家的指南:传送门——><a href="https://document.chipintelli.com/beginner-guide/%E6%96%B0%E6%89%8B%E6%8C%87%E5%8D%97/%E5%9B%BA%E4%BB%B6%E5%90%88%E6%88%90%E5%8F%8A%E7%83%A7%E5%BD%95/" target="_blank">固件合成及烧录</a></em></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height:1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*6、BOM清单</h3>
<hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#95a5a6;"><span style="font-size:14px;">详见右方BOM清单按钮</span></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">*7、大赛LOGO验证</h3>
<hr class="horizontal-splitline normal-bold-2"><p style="line-height:1.8;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/JgG3RglUHWvkSPSWHXdqWpkq8fYnKB3tFhtOrrrH.jpeg" alt="" width="750" height="522"></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">* 8、避坑指南</h3>
<hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="color:#000000;font-size:14px;text-align:center;">(1)、首选避坑指南是厂家的<a href="https://document.chipintelli.com/beginner-guide/#_1" target="_blank">新手指南 - 新手指南 (chipintelli.com)</a></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="color:#000000;font-size:14px;text-align:center;">(2)、软件代码入门也是厂家的SDK指南<a href="https://document.chipintelli.com/%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91/SDK/CI112X%E8%8A%AF%E7%89%87SDK/CI112X%E8%8A%AF%E7%89%87SDK/" target="_blank">SDK概述 - 启英泰伦文档中心 (chipintelli.com)</a>,注意CI-C22GS02S模块的主控芯片是CI1122,看CI1122部分。</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="color:#000000;font-size:14px;text-align:center;">(3)、我下载的SDK V1.2.5的版本是未完成按键的DEMO部分的,”ci112x_gpio.c“文件中未引用”<span style="color:#3598db;">ci_key.h</span>“,会导致<code>ci_key_gpio_isr_handle();<span style="color:#2dc26b;">//GPIO按键处理函数</span></code>报1次警告,在开头添加头文件即可”<span style="color:#ba372a;">#include</span> <span style="color:#3598db;">"ci_key.h"</span>“</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="color:#000000;font-size:14px;text-align:center;">(4)、添加按键的代码后会报RAM ROM不够的错,报的错误类似是:(这个错误困扰了我许久-_-)</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;text-align:center;background-color:#f8cac6;">ample_1122.elf section `.ro_data' will not fit in region `ROM'<br>section .data LMA [000000001ff21000,000000001ff2150f] overlaps section .ro_data LMA [000000001ff1d518,000000001ff210bf]</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;text-align:center;background-color:#f8cac6;">region `ROM' overflowed by 192 bytes</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><span style="color:#000000;font-size:14px;text-align:center;">如下图:</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;"><span style="color:#000000;font-size:14px;text-align:center;"><img style="margin-left:auto;margin-right:auto;" src="//image.lceda.cn/pullimage/6ncTatUM4Sg4UYVT7gEoyfOH4OhL4itVDYgfGjv3.jpeg" alt="" width="950" height="506"></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;"><span style="color:#000000;font-size:14px;text-align:center;">在<span style="text-decoration:underline;"><a href="https://bbs.chipintelli.com/" target="_blank">厂家的BBS</a></span>发帖后得到厂家大佬<a class="xw1" href="https://bbs.chipintelli.com/home.php?mod=space&uid=593" target="_blank">qinglin.li@chip</a>回复:</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;"><span style="color:#000000;font-size:14px;text-align:center;"><strong>原因:</strong>新增代码后,增加的代码量会超出flash分配的user code地址大小,会引起这类报错。</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;"><span style="color:#000000;font-size:14px;text-align:center;"><strong>解决方法</strong>:使用编辑器打开SDK目录下文件\sample\internal\sample_1122\src\ci112x.lds,根据实际情况增加ROM_SIZE的大小,同时相对的减少ASR_USED_SIZE的大小。</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:80px;"> </p>
<pre class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:120px;"><code><span style="color:#000000;font-size:14px;text-align:center;">ROM_SIZE = 1024*(130+1+1+1);//上面+1<br>FHEAP_SIZE = 1024*(81);<br>ASR_USED_SIZE = 1024*(283-1-1-1);//下面就-1,直到不报错<br>RAM_SIZE = 1024*(18);<br>STACK_SIZE = 0xC00;/*inclued in RW*/</span></code></pre>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;">* 9、演示您的项目并录制成视频上传</h3>
<hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="color:#95a5a6;font-size:12px;">视频要求:请横屏拍摄,分辨率不低于1280×720,格式Mp4/Mov,单个视频大小限100M内;</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"><span style="color:#95a5a6;font-size:12px;">视频标题:立创电赛:{项目名称}-{视频模块名称};如立创电赛:《自动驾驶》-团队介绍。</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"><strong>已发布,见附件。</strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;padding-left:40px;"> </p>
<h3><span class="colour">* 10、注意事项</span></h3>
<div><hr></div>
<p>1、做好了后安装在老风扇里就可以了,但是一定要注意220V的危险!<span style="font-size:18px;">危险!</span><span style="font-size:24px;">危险</span><span style="font-size:36px;">!</span></p>
<p>2、请遵守开源协议</p>
<p>3、转载参考请注明来源:立创开源平台<a href="/Red_mt/li-xian-yu" target="_blank">https://oshwhub.com/Red_mt/li-xian-yu</a></p>
<p>4、案例仅供参考,笔者水平有限,多多包涵啦。目前实测可行不代表以后也实测可行</p>
<p> </p>
<p style="text-align:center;"><strong><span style="font-size:24px;">点个赞再走呗</span></strong></p>
<p> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height:1.8;"> </p>
评论(0)