惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

珒陶

LC电路分析入门 - 珒陶 Windows下OpenCV交叉编译到ARM-Linux - 珒陶 本博客基本完成迁移 - 珒陶 微软在GitHub合并了我提交的PR! - 珒陶 C语言实现中缀表达式计算 - 珒陶 Murmurer 现已上架Google Play! - 珒陶 MindCanvas 思维导图现已开源! - 珒陶 本站已更新 - 珒陶 本站已恢复 - 珒陶
使用VSCode编辑Keil μVision5项目,并用Makefile自动化编译和下载 - 珒陶
珒陶 珒陶 · 2022-04-01 · via 珒陶

  不久后就要参加电子设计竞赛了。Keil的界面实在不好看,自动补全等功能也不太方便,于是决定想办法将VSCode配置为Keil的编辑器,并用Makefile自动化编译和下载。

无标题.png


步骤如下:
  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即可将项目编译并下载到单片机了。


参考:

c_cpp_properties.json reference
µVision User’s Guide

Q.E.D.