使用VSCode编辑Keil μVision5项目,并用Makefile自动化编译和下载
source link: https://www.chenjt.com/archives/275/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
不久后就要参加电子设计竞赛了。Keil的界面实在不好看,自动补全等功能也不太方便,于是决定想办法将VSCode配置为Keil的编辑器,并用Makefile自动化编译和下载。
步骤如下:
1、在Keil项目文件夹下新建一个文件夹.vscode
,并在其中新建文件c_cpp_properties.json
,其内容为:
{
"configurations": [
{
"name": "STM32",
"includePath": [
"C://keil_v5/ARM/ARMCC/**", // keil_v5安装目录
"${workspaceFolder}/**"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "${workspaceRoot}/.vscode/.browse.c_cpp.db",
"path": [
"C://keil_v5/ARM/ARMCC/**", // keil_v5安装目录
"${workspaceFolder}/**"
]
},
// 宏定义
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"__CC_ARM",
"USE_STDPERIPH_DRIVER",
"STM32F10X_HD" // 此项根据实际情况更改
],
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
2、在刚刚新建的.vscode
文件夹中,继续新建文件tasks.json
,其内容为:
{
"version": "2.0.0",
"tasks": [
{
"label": "make",
"command": "make.exe", // make.exe路径
"group": {
"kind": "build",
"isDefault": true
},
"args": [
"all"
],
}
]
}
3、在Keil项目文件夹下新建文件Makefile
,其内容为:
UV = C:/Keil_v5/UV4/UV4.exe # UV4.exe路径
UV_PRJ_PATH = $(wildcard $(shell cd)/**/*.uvprojx) # 自动查找uvprojx文件
TEMP_LOG_PATH = $(shell cd)\temp_log.txt
.PHONY: all build download
all: build download
build:
- @$(UV) -j0 -b $(UV_PRJ_PATH) -o $(TEMP_LOG_PATH)
@type $(TEMP_LOG_PATH)
@del $(TEMP_LOG_PATH)
download:
- @$(UV) -j0 -f $(UV_PRJ_PATH) -o $(TEMP_LOG_PATH)
@type $(TEMP_LOG_PATH)
@del $(TEMP_LOG_PATH)
至此,在VSCode中,运行生成任务...
或按快捷键Ctrl+Shift+B
即可将项目编译并下载到单片机了。
本文由 珒陶 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Apr 1, 2022 at 01:16 am
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK