【Silicon Labs 开发套件评测】+FreeRTOS+奇妙的基础外设
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"> <font face="宋体">本节我们将实现一些基础的外设应用,主要包括</font><font face="Calibri">GPIO</font><font face="宋体">的输入输出(对于开发板的按钮及</font><font face="Calibri">LED</font><font face="宋体">)、串口打印输出等,这些基础的搭建好之后,后面的应用就在这个基础上实现了。</font></span></span></span></span></p><p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"> <font face="宋体">一,</font> <font face="宋体">首先我们添加</font><font face="Calibri">Freertos</font><font face="宋体">实时系统。</font><font face="Calibri">SSv5</font><font face="宋体">已经为我们搭建好所有的基础工作,我们只需要初始化安装就可以了。</font></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"> <font face="宋体">我就在前面的工程下添加在下图指示位置找到</font><font face="Calibri">FreeRTOS</font><font face="宋体">后,点击</font><font face="Calibri">install</font><font face="宋体">,默认就安装好了。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">点击</font><font face="Calibri">configure</font><font face="宋体">,可以对</font><font face="Calibri">rtos</font><font face="宋体">下图所需要的参数进行配置。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">点击</font><font face="Calibri">view source</font><font face="宋体">可以打开可视化参数配置的头文件</font><font face="Calibri">FreeRTOSConfig.h</font><font face="宋体">,即是</font><font face="Calibri">FreeRTOS</font><font face="宋体">所需要的用户配置头文件。</font></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="Calibri">FreeRTOS</font><font face="宋体">源码安装好之后,开始添加任务。</font><font face="Calibri">SSv5</font><font face="宋体">做得比较智能化,安装实时系统后,在</font><font face="Calibri">main</font><font face="宋体">函数中也给你添加了实时系统的初始化及启动。看起来方便了很多,但是给学习的人带来了一定程度的懒惰,会导致一些技术人员对底层的基础一知半解。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">我们在</font><font face="Calibri">app_init</font><font face="宋体">函数中实现任务函数,我们任务函数就实现</font><font face="Calibri">LED</font><font face="宋体">定时闪烁</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">实现了一个基本的是实时任务,编译、下载。系统能正常运行。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">二,然后实现按键输入</font></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">找到</font><font face="Calibri">button</font><font face="宋体">按键的驱动初始化。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">硬件接口是</font><font face="Calibri">GPIO-PB3</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">系统默认初始化后使用输入中断输入模式,我这里修改为查询方式</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">对按键进行初始化,忍不住说一下中断处理流程。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">通过注册回调函数</font></span></span><span style="font-size:10.0000pt"><span style="background:#d4d4d4"><span style="font-family:Consolas"><span style="color:#000000"><font face="Consolas">sli_simple_button_on_change</font></span></span></span></span><span style="font-size:10.0000pt"><span style="background:#d4d4d4"><span style="font-family:宋体"><span style="color:#000000"><font face="宋体">中进一步解释</font><font face="Consolas">button</font><font face="宋体">描述符</font></span></span></span></span><span style="font-size:10.0000pt"><span style="background:#d4d4d4"><span style="font-family:Consolas"><span style="color:#000000"><font face="Consolas">sl_simple_button_array</font></span></span></span></span><span style="font-size:10.0000pt"><span style="background:#d4d4d4"><span style="font-family:宋体"><span style="color:#000000"><font face="宋体">。</font></span></span></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">我这里使用查询方式,就比较简单,直接初始化就行。</font></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">然后注册一个按键任务</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">实现按一下</font><font face="Calibri">led</font><font face="宋体">翻转一下,编译,下载。运行正常。</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">三,接着实现</font><font face="Calibri">printf</font><font face="宋体">输出</font></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">直接可视化安装</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">点击初始化时,发生一个错误</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">是因为没有安装串口</font><font face="Calibri">USUART</font><font face="宋体">和</font><font face="Calibri">STDIO</font><font face="宋体">两个服务,</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">安装之后就没有错误了。</font></span></span></span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">在按键任务中添加</font><font face="Calibri">printf</font><font face="宋体">打印</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">编译,下载,运行</font></span></span></span></span></p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"> </p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">这几个基本的外设和实时系统搭建好之后,后面应用在人机通信这块都会使用上。后面开始传感器的排位了。</font></span></span></span></span></p>
<p>不错,顶一下楼主,学习了。</p>
<p>看来楼主很顺利都是运行正常</p>
<p>期待下文</p>
页:
[1]