使用Visual Studio Code开发Arduino相关配置

3 篇文章 0 订阅
3 篇文章 0 订阅

看了博文1 博文2,知道了VSCode安装Arduino插件可以用来开发Arduino项目,但是实际使用时提示头文件未包含,显然是设置问题。   #include errors detected. Please update your includePath.  

百度没有搜索到相关的中文资料,搜到英文的资料,这里记录一下。

文件关联设置

设置文件 settings.json 添加以下脚本

// Files
    // Configure file associations to languages (e.g. "*.extension": "html").
    // These have precedence over the default associations of the languages 
    // installed.
    "files.associations": {
        "*.ino": "cpp"
    },

设置头文件路径

 在项目 .vscode 文件夹中 创建  c_cpp_properties.json 文件,并添加相关头文件路径信息。

{
            "name": "Arduino",
            "includePath": [
                "{path-to-arduino}/hardware/arduino/avr/cores/arduino/",
                "{path-to-arduino}/hardware/arduino/avr/libraries/EEPROM/",
                "{path-to-arduino}/hardware/arduino/avr/libraries/SPI/",
                "{path-to-arduino}/hardware/arduino/avr/libraries/SoftwareSerial/",
                "{path-to-arduino}/hardware/arduino/avr/libraries/Wire/",
                "{path-to-arduino}/hardware/tools/avr/avr/include/",
                "{path-to-arduino}/hardware/tools/avr/avr/include/avr/",
                "{path-to-arduino}/hardware/tools/avr/avr/include/compat/",
                "{path-to-arduino}/hardware/tools/avr/avr/include/util/",
                "{path-to-arduino}/hardware/tools/avr/lib/gcc/avr/4.*.*/include/",
                "{path-to-arduino}/hardware/tools/avr/lib/gcc/avr/4.*.*/include-fixed/"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }

 

Visual Studio Code (VSCode) 是一款强大的开源代码编辑器,它支持嵌入式开发,尤其适用于那些与硬件交互或使用特定微控制器框架的项目。下面是使用VSCode进行嵌入式开发的一般步骤和教程概述: 1. **安装 VSCode**: 首先,确保你已经在计算机上安装了最新版本的VSCode。如果尚未安装,可以从官网下载并安装。 2. **安装 C/C++ 插件**: 对于嵌入式开发,你需要安装 "C/C++" 插件,如 "CodeLLDB" 或 "PlatformIO Tools"。这些插件提供了编译、调试和连接C/C++代码的功能。在VSCode的扩展市场搜索这些名称并安装。 3. **配置工具链**: 根据你的目标平台(如Arduino、AVR、STM32等),配置相应的构建系统。对于基于Makefile的项目,可能需要设置`tasks.json`文件;而对于基于IDEF(例如PlatformIO)的项目,可以直接通过插件管理配置。 4. **编写代码**: 使用VSCode创建一个新的C/C++文件,开始编写你的程序。VSCode提供了语法高亮、智能提示和自动完成等功能。 5. **构建和调试**: 使用插件中的构建任务(如`tasks.json`中的`build`命令)来编译你的代码。VSCode还支持断点设置、逐步执行和查看变量值的调试功能。 6. **硬件连接与调试**: 如果是通过USB连接硬件,可能需要使用像JTAG调试器这样的设备。许多插件如"PlatformIO Debugger"或"C/C++ Debug Adapter"提供了与特定调试器的集成。 7. **代码片段和模板**: 可以利用社区贡献的代码片段和模板来快速启动项目或常见功能的编写。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值