1 上篇已经创建了一个LED_TEST的工程,这里尝试点亮第一个LED灯

看到工程目录下有对应的LED_TEST.pintool和LED_TEST.slcp
双击打开LED_TEST.slcp

可以看到工程包含的一些功能窗口,这里我们通过图形工具进行配置, 
看到原理图中LED对应的管脚是PA04
再打开LED_TEST.pintool
可以通过工程目录下双击打开也可以在右侧的Quick Links打开

咱们勾选PA04前的选择框

再点击Function栏

其中的Function通过下拉箭头选择GPIO mode

在Custom Pin Name起一个名称,这里使用led0

点击APPLY AND CLOSE

注意进行保存
然后编译工程

通过状态栏信息窗口观察编译结果

2 添加LED示例
打开LED_TEST.slcp,选择SOFTWARE COMPONENTS菜单页

通过过滤筛选led

选择Simple LED示例


点击Install进行示例安装

点击Done完成示例安装。

对LED进行配置

和对应的管脚进行关联就行
3 上面已经把工程配置好了,接下来编写LED的应用程序
打开main.c,查看工程的程序结构

这里看到初始化部分有对应的 app_init();
应用程序部分有对应的 app_process_action();
我们把对应的LED初始化部分放在app_init();把LED的应用放在app_process_action();尽量保持程序结构的一致性。
查看工程autogen菜单可以看到上一步安装的led示例已经生成了对应的应用代码。

这里直接把修改后的代码贴出

添加了对应的头文件包含,和LED灯的开和关应用程序。
编译工程

下载查看运行状态

LED已经可以点亮和关闭了
|