1.安装环境需要的软件
- Visual Studio Code
- STM32Cubemx 生成makefile工程的
- arm-none-eabi-gcc 交叉编译的
- Make工具
- LLVM 工具 提取码:1234 用于代码补全的
- Git for Windows
2.添加环境变量![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/8a5d509ad82d98a60bd8357622e5330d.png)
测试安装完成
arm-none-eabi-gcc --version
git --version
make --version
clang --version
3.stm32cubemx创建工程
4.Vscode 插件安装
5.创建.vscode 文件夹
c_cpp_properties.json
添加头文件的路径
LLVM代码补全的路径
添加宏定义 __CC_ARM
{
"configurations": [
{
"name": "Win32",
"browse": {
"path": [
"${workspaceFolder}/",
"${workspaceFolder}/Core/Inc",
"${workspaceFolder}/Drivers/CMSIS/RTOS/Template",
"${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc",
"${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include"
],
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"${workspaceFolder}/",
"${workspaceFolder}/Core/Inc",
"${workspaceFolder}/Drivers/CMSIS/RTOS/Template",
"${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc",
"${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"__CC_ARM",
"USE_STDPERIPH_DRIVER",
"STM32F10X_HD"
],
"compilerPath": "C:\\Program Files\\LLVM\\bin\\clang.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
settings.json 设置终端的Shell为Bash
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe",
"files.associations": {
"main.h": "c",
"stm32f4xx_hal.h": "c",
"stm32f4xx_hal_conf.h": "c"
}
}
6. make编译
Ctrl+~ 进入终端
编译完成