How to elegantly develop STM32 in VScode

Original link: https://blog.lipux.cn/archives/367/

foreword

Recently, I am learning the STM32 development board. The development software uses Keil uVision5, but its interface style stuck in the last century makes the development process extremely inelegant, even a bit old-fashioned. In fact, the most unacceptable thing about Keil uVision5’s editor is that there is no code completion at all, and typing codes seems very painful. After all, I am lazy and don’t want to type them out one by one.

Just right, VScode can be said to be that elegant existence, so there is a demand, can VScode be used for stm32 development?

Thanks to the prosperous plug-in ecology of vscode, it is really possible. I can only say that vscode is amazing! !

plugin installation

Here we need to install two plugins

  • Keil Assistant
  • C/C++

Keil Assistant

This plugin is a Keil auxiliary tool on vscode, used in conjunction with the c/c++ plugin.

It can provide syntax highlighting and code snippet functions for Keil projects, and supports compiling and downloading Keil projects.

Only supports Keil uVison 5 and above

Only supports Windows platform

We open vscode, click on the extension installation, search for keil Assistant , and then we install the one with the highest download volume, usually the first one found in the search.

After the installation is complete, we click the settings icon of the plug-in to enter the settings interface

Change the path in the settings to your Keil uVision5 installation path, which is the path of UV4.exe

Note that the path must be correct, otherwise it will not compile.

C/C++

The installation of C/C++ can be installed directly without any special settings.

The function of this plug-in is to complete the code, which can greatly improve the efficiency of the code.


start using

  1. Create a good project on Keil, add good files, header file paths, etc.
  2. Click the Open Project icon or use vscode to directly open the directory where the keil project file (.uvproj) is located , and the plugin will automatically load the keil project;

common operation

  • Compile, Burn : 3 buttons are provided, which respectively represent compile, download and recompile

  • Save and refresh : Add/delete source files, change, and configure items on Keil, click Save All after the changes are completed, and the plug-in will automatically refresh the project after detecting changes in the keil project

  • Open the source file : click the source file to open in preview mode, double-click the source file to switch to non-preview mode to open

  • Switch Keil Target : Click the switch button of the project to switch between multiple Keil Targets

  • Expand references : After compiling, you can click the arrow icon of the source file item to expand its references (only ARM projects are supported)

other settings

  • Workspace settings: project exclusion list (KeilAssistant.Project.ExcludeList) When there are multiple keil projects in a directory, use the plug-in to open the directory, and the plug-in will load all keil projects. Through this option, you can specify which keil projects need to be excluded project to prevent the project’s default exclude list from being automatically loaded when the workspace is opened:

     [ "template.uvproj", "template.uvprojx" ]

at last

Try to compile the code in VScode, if the compilation is successful, if there are 0 errors and 0 warnings, it means the configuration is successful!

Then I can continue to learn STM32 gracefully.

Author open source address

https://github.com/github0null/keil-assistant/

This article is transferred from: https://blog.lipux.cn/archives/367/
This site is only for collection, and the copyright belongs to the original author.