Embedded Development Board Learning


Visual Studio Code for ARM with CMake #6 IntelliSense

Fecha: febrero 20, 2023

Autor: Guillermo Garcia

Categorías: Visual Studio Code Etiquetas:

Visual Studio Code como entorno de desarrollo para proyecto Embedded Systems

In the previous article, Visual Studio Code for ARM with CMake #5 VSC Tasks, we added the files to create tasks to automate the compilation processes.

In this article, we will configure the IntelliSense extension, which is an essential tool when using Visual Studio Code for cross-compiling.

Cross-compiling

Cross-compiling is a feature of compilers that allows them to generate executable code for a different platform than the one on which the compiler is running.

With the development environment in Visual Studio Code, we are performing cross-compiling thanks to the ARM GCC compiler.

Example the cross-compiling

Visual Studio Code does not inherently recognize the language features. To enhance this capability in the code editor, we use the IntelliSense extension.

IntelliSense

The extension provides features such as syntax highlighting, data type highlighting, and function and library inclusion definitions.

It is necessary to provide configuration settings. These settings are established through a file called c_cpp_properties.json.

c_cpp_properties.json

We will create this file in the .vscode directory. In this file, we will include the paths to the directories that contain the inclusion files, along with other configurations.

Configurate file c_cpp_properties.json for IntelliSense

Let’s look at the contents of the c_cpp_properties.json file.

{
    "configurations": [
        {
            "name": "ARM none eabi GCC",
            "includePath": [
                "${workspaceFolder}/main",
                "${workspaceFolder}/CMSIS/Include",
                "${workspaceFolder}/CMSIS/Device/ST/STM32G0xx",
                "${workspaceFolder}/Device",
                "${workspaceFolder}/Drivers/Inc",
                "${workspaceFolder}/Drivers/Inc/Legacy"
            ],
            "defines": [
                "STM32G071xx",
                "USE_HAL_DRIVER"
            ],
            "compilerPath": "${config:SetPathToolchainARM}/arm-none-eabi-gcc.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-arm"
        }
    ],
    "version": 4
}

In the includePath section, we will list the paths to all directories containing inclusion files.

To highlight code sections with preprocessor statements, we place the definitions in the defines section.

In compilerPath, we specify the path to the compiler executable. Here, we use the variable ${config:SetPathToolchainARM}, which we defined in the settings.json file.

Resultado

Let’s see how Visual Studio Code behaves when we don’t have the configuration file for IntelliSense.

We see how it doesn’t recognize certain definitions in source code files.

IntelliSense without configuration

When we add the c_cpp_properties.json configuration file we see how the extension begins to perform its function by exploring all the content of our project.

IntelliSense with configuration

Now we can navigate between the definitions by Ctrl + click.



Card image cap
Guillermo Garcia I am an embedded systems software engineer. I like constant learning, IoT systems and sharing knowledge


Comentarios... no existen comentarios.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Subscribe


Subscribe to receive the latest content.
Loading