1. 程式人生 > 其它 >【vscode】打造你的嵌入式開發環境(STM8)

【vscode】打造你的嵌入式開發環境(STM8)

技術標籤:vscodevscode

vscode十分的輕量化,本身擴充套件也很多。本文主要安利一款非常好用的外掛,支援IAR和KEIL,同時分享一些不錯的擴充套件,讓你的嵌入式開發快起來。

準備工作

vscode
iar for stm8
stvp

主菜

EIDE手冊
國人作者的專案,相當的不錯,如果是萬事俱備只欠東風的小夥伴,點進去學習就可以了,下文主要針對首次使用vscode的小夥伴。

擴充套件

Better Align
顧名思義,更好的對齊程式碼,讓你的程式碼更美觀

Bracket Pair Colorizer
1
讓你的括號色彩斑斕,成雙成對

C/C++
C++ Intellisense


C語言開發必備

Chinese (Simplified) Language Pack for Visual Studio Code
中文支援包

Comment Translate
使用谷歌翻譯的API,看原始碼的註釋時相當舒適

Github
提交/拉取你的程式碼倉庫
速度慢的,hosts檔案內新增如下文字,基本上可以滿足使用

# GitHub Start 
140.82.113.3      github.com
140.82.114.20     gist.github.com
185.199.110.153   github.github.io
151.101.184.133    assets-cdn.github.com
151.101.184.133    raw.githubusercontent.com
151.101.184.133    gist.githubusercontent.com
151.101.184.133    cloud.githubusercontent.com
151.101.184.133    camo.githubusercontent.com
151.101.184.133    avatars0.githubusercontent.com
199.232.68.133     avatars0.githubusercontent.com
199.232.28.133     avatars1.githubusercontent.com
151.101.184.133    avatars1.githubusercontent.com
151.101.184.133    avatars2.githubusercontent.com
199.232.28.133     avatars2.githubusercontent.com
151.101.184.133    avatars3.githubusercontent.com
199.232.68.133     avatars3.githubusercontent.com
151.101.184.133    avatars4.githubusercontent.com
199.232.68.133     avatars4.githubusercontent.com
151.101.184.133    avatars5.githubusercontent.com
199.232.68.133     avatars5.githubusercontent.com
151.101.184.133    avatars6.githubusercontent.com
199.232.68.133     avatars6.githubusercontent.com
151.101.184.133    avatars7.githubusercontent.com
199.232.68.133     avatars7.githubusercontent.com
151.101.184.133    avatars8.githubusercontent.com
199.232.68.133     avatars8.githubusercontent.com

# GitHub End

vscode-pdf
檢視你的pdf檔案(使用感受不佳)

Settings Sync
同步你的擴充套件

One Dark Pro
非常好看的主題

註釋模板

良好的程式碼風格離不開註釋,vscode支援使用者新增自己的程式碼片段。
具體方法:左下角 管理->使用者程式碼片段->新建全域性程式碼片段檔案->命名
之後可以看到如下片段:

{
	// Place your 全域性 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
	// Placeholders with the same ids are connected.
	// Example:
	// "Print to console": {
	// 	"scope": "javascript,typescript",
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
}

修改如下:

{
	// Place your 全域性 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
	// Placeholders with the same ids are connected.
	// Example:
	"HEAD": {
		"scope": "c",
		"prefix": "ysy_HEADER",
		"body": [
			"/*************************************************************",
			"Copyright (c) $CURRENT_YEAR Shawn Yan, All rights reserved",
			"-------------------------------------------------------------",
			"File Name: ",
			"",
			"Desc     : ",
			"",
			"Author   : Shawn Yan",
			"",
			"Date     : $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
			"",
			"*************************************************************/"
		],
		"description": "My filehead description"
	},
	"Function_Struct": {
		"scope": "c",
		"prefix": "ysy_struct",
		"body": [
			"/*------------------------- Includes -----------------------*/",
			"",
			"",
			"/*----------- Global Definitions and Declarations ----------*/",
			"",
			"",
			"/*-------------------- Type Declarations -------------------*/",
			"",
			"",
			"/*------------------ Variable Declarations -----------------*/",
			"",
			"",
			"/*------------------- Function Prototype -------------------*/",
			"",
			"",
			"/*------------------- Function Implement -------------------*/",
			"",
			"",
			"/*--------------------------- END --------------------------*/"
		],
		"description": "My function struct"
	},
	"Function_Description": {
		"scope": "c",
		"prefix": "ysy_fundesc",
		"body": [
			"/*************************************************************",
			"Function Name       : ",
			"Function Description: ",
			"Param_in            : ",
			"Param_out           : ",
			"Return Type         : ",
			"Note                : ",
			"Author              : Yan",
			"Time                : $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE",
			"*************************************************************/"
		],
		"description": "My function description"
	}
	
}

主要關注scope、prefix、body三項
scope為關聯語言,即在c語言的檔案中才能被使用
在檔案中輸入prefix中的內容即可快速列印body中的內容
效果如下

/*************************************************************
Copyright (c) 2020 Shawn Yan, All rights reserved
-------------------------------------------------------------
File Name: 

Desc     : 

Author   : Shawn Yan

Date     : 2020-12-26

*************************************************************/
/*************************************************************
Function Name       : 
Function Description: 
Param_in            : 
Param_out           : 
Return Type         : 
Note                : 
Author              : Yan
Time                : 2020-12-26
*************************************************************/
/*------------------------- Includes -----------------------*/


/*----------- Global Definitions and Declarations ----------*/


/*-------------------- Type Declarations -------------------*/


/*------------------ Variable Declarations -----------------*/


/*------------------- Function Prototype -------------------*/


/*------------------- Function Implement -------------------*/


/*--------------------------- END --------------------------*/

大概就介紹到這裡啦,有什麼問題歡迎留言!