说明
-
virtual code实现编辑功能,其有强大的代码提示、代码阅读功能。
-
通过bat文件,通过cmd编译、下载,具体下载器设置仍需在keil软件中设置
-
具体代码调试仍需在keil软件下
项目配置文件
新建.vscode文件夹,在其下建立两个文件settings.json
,c_cpp_properties.json
。
settings.json
文件如下:
{
"files.associations": {
"stm32f10x.h": "c"
},
"files.encoding": "gb2312",
"editor.detectIndentation": false,
"editor.tabSize": 2
}
c_cpp_properties.json
文件如下:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Keil_v5/ARM/ARMCC/include"
],
"defines": [
"USE_STDPERIPH_DRIVER",
"STM32F10X_MD",
"__CC_ARM"
],
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
这里第7行keil路径要换成自己的。
编写.bat文件实现编译、下载
编写的keil.bat文件如下:
@echo off
set UV=C:\Keil_v5\UV4\UV4.exe
if "%1" == "" goto NOP
set UV_PRO_PATH=%cd%\USER\%1.uvprojx
if "%2" == "-b" (
echo Init building ...
%UV% -j0 -b %UV_PRO_PATH% -o %cd%\build_log.txt
type build_log.txt
) else if "%2" == "-f" (
echo Init flashing ...
%UV% -j0 -f %UV_PRO_PATH% -o %cd%\build_log.txt
type build_log.txt
) else (
echo Init building ...
%UV% -j0 -b %UV_PRO_PATH% -o %cd%\build_log.txt
type build_log.txt
echo Init flashing ...
%UV% -j0 -f %UV_PRO_PATH% -o %cd%\build_log.txt
type build_log.txt
)
if "%3" == "-f" (
echo Init flashing ...
%UV% -j0 -f %UV_PRO_PATH% -o %cd%\build_log.txt
type build_log.txt
)
goto end
:NOP
echo No ProjectName
goto end
:end
exit
这里需要需改的是2,4行的路径。
编译+下载: .\keil.bat 项目名
仅编译:.\keil.bat 项目名 -b
仅烧写:.\keil.bat 项目名 -f