Using Visual Studio Code with IAR Embedded Workbench

 

Using Visual SUsing Visual Studio Code with IAR Embedded Workbenchtudio Code with IAR Embedded Workbench

Introduction

Visual Studio Code (VS Code) is a popular cross-platform code editor. It is customizable and extensible, and can be adapted for a variety of workflows. This Technical Note shows how to use VS Code to develop IAR Embedded Workbench projects.

Prerequisites

  • This document assumes little to no previous knowledge of VS Code.
  • IAR Systems does not provide support for the VS Code editor. If you have any problems setting up or using VS Code, contact your provider.

Tools to install

  • IAR Embedded Workbench
  • Visual Studio Code
  • IAR For Visual Studio Code (a VS Code extension)

IAR For Visual Studio Code can be installed from the extensions panel in VS Code or from the web marketplace. Installing this extension will also install the C/C++ extension.

Discussion

Configuring the extension

To get started in VS Code, go to File>Open Folder and select the folder containing your IAR Embedded Workbench project. This extension uses the IAR Command Line Build Utility (iarbuild.exe) to perform its tasks, and the information about which source files to build, compilation flags to use, etc., is defined by the project file (.ewp).

The extension detects project configurations and IAR Embedded Workbench installations. You can choose the installation, compiler, project and configuration from the status bar at the bottom of the VS Code window.

Specifying IAR Embedded Workbench install location(s)

If the extension does not find your IAR Embedded Workbench installation(s), you will need to manually point to them. To do this:

  1. Go to File>Preferences>Settings.
  2. Search for iar.
  3. Change Iar Install Directories to include your IAR Embedded Workbench install location(s).

Using the extension

Once the extension has been configured, it will provide language features such as autocompletion, diagnostics and code navigation.

You can build the project from VS Code using the provided tasks. To do this, go to Terminal>Run Task>iar>Iar Build. You may configure this as the default build task by going to Terminal>Configure Default Build Task. You can then press Ctrl+Shift+B to build the project.

The extension also includes tasks for running C-STAT. To do this, go to Terminal>Run Task>iar-cstat>Run C-STAT Analysis. This will output any C-STAT warnings in the Problems panel.

Open VS Code from the IAR Embedded Workbench IDE

To use VS Code together with the IAR Embedded Workbench IDE, you may add a menu option inside the IDE to open the current file in VS Code. To do this, go to Tools>Configure Tools… and add a new entry called Open in VS Code. 

By default, VS Code is installed under:

C:\users\{username}\AppData\Local\Programs\Microsoft VS Code. Based on this, set the Command field to your VS Code executable like this (using a Windows standard environment variable): 

$_localappdata_$\Programs\Microsoft VS Code\Code.exe 

The Argument field should be $WS_DIR$ -g $FILE_PATH$:$CUR_LINE$. 

Example:

Press OK. You can now open the current file and line in VS Code at any time by selecting the menu item Tools>Open in VS Code.

Open IAR Embedded Workbench IDE from the VS Code

It is possible to open the IAR Embedded Workbench IDE from VS Code. This is done by running the iar: Iar Open task. This will open the current project in the IDE.

Limitations

  • The VS Code extension does not support modifying project settings or adding project files. This means that files created in VS Code will not be built by the IAR compiler, and should instead be added in the IAR Embedded Workbench IDE to be stored in the project file (.ewp).
  • The extension currently does not include support for IAR C-SPY debugging.
  • The extension is not owned by IAR Systems. Issues can be reported on GitHub.

Conclusion

This Technical Note briefly describes how to set up Visual Studio Code to develop IAR Embedded Workbench projects. It also shows how to facilitate working on the same project in both VS Code and the IAR Embedded Workbench IDE. For further information about how to use the IAR For Visual Studio Code extension, see the IAR For Visual Studio Code documentation.

 

All product names are trademarks or registered trademarks of their respective owners.

posted on 2020-12-13 21:51  荷树栋  阅读(515)  评论(0编辑  收藏  举报

导航