Visual Keil project configuration template, one trick to improve the development efficiency of single-chip microcomputer

When I was working on a project with Keil MDK, I had an idea: Can macro definitions be made into a visual template? In this way, I don't have to modify the corresponding .h or .c files directly, and it can also reduce the problem of project compilation caused by manual errors.

In addition, when the program needs to change a certain parameter, you can also tell those who do not understand the program to help configure it, which increases the maintainability of the program. Fortunately, Keil MDK supports such an approach!

So how to achieve it? Search the Configuration Wizard in the official documentation :

841fac1ae6d876e4f63a545b09a720ae.png

dddeb334fbbbf8703d9af3accc381a39.png

This document is described in great detail and also provides a configuration template. We only need to write the corresponding format according to the document description to generate a graphical configuration interface. ( Note: Keil is not so smart. After writing this template, it cannot be automatically matched immediately. You need to close the Keil project and then open it again to load it into a graphic configuration template, and then you can realize instant modification and instant response. This is a lot of writing articles. The author did not tell the reader about this pit!!! ), here I am using the KeilV5.25 version, and it is not clear whether the later new version has improved this problem.    

Next, we create a new .h or a .c file, and then add it at the beginning of the .h file or .c file:

// <<< Use Configuration Wizard in Context Menu >>>

At the end of the file add:

// <<< Use Configuration Wizard in Context Menu >>>

Then close the project again, continue to open the project, and then open the file, you can see the following effect:

a3e7139b38b66f77a532cef5d160dfaf.png

    Next, we need to add our configuration method to the beginning-end of this pair of configuration wizards. The following are the syntax rules of the configuration method:

ec1595e5dd9206a1324599a12a0bc725.png

Next, we can quickly modify the configuration template we want based on the configuration template and parameters provided by the official website above. It provides the configuration of radio buttons, checkboxes, strings, parameter range definitions and other functions. Program. Here is a configuration template I made with Bear Pie as an example:

// <<< Use Configuration Wizard in Context Menu >>>
#ifndef __BEARPI_CONFIG_H
#define __BEARPI_CONFIG_H

//是否支持调试使能
// <c1> Debug Config
// <i> Debug Config generation
#define _USE_DEBUG
// </c>

//小熊派开发配置,选择E53传感器模组以及IoT通信模组
// <h>BearPi Config
//  <o>Select E53 Module
//   <i> Default: E53_IA1
//  <0=>E53_IA1
//  <1=>E53_SC1
//   <2=>E53_SC2
//   <3=>E53_SF1
//   <4=>E53_IS1
//  <5=>E53_ST1
#define BEARPI_E53_MODULE 0
//  <o>Select WAN Module
//   <i> Default: E53_IA1
//  <0=>NB-IoT&Card-NB35-A
//  <1=>WIFI-WIFI8266
//   <2=>2G-G26
//   <3=>HiLink-HiLink710
#define BEARPI_WAN_MODULE 0
// </h>

//是否支持调试LED
// <c1> Support Debug Led
// <i> Use PC13 debug led
#define _SUPPORT_DEBUG_LED
// </c>

//是否支持键盘
// <c1> Support KeyBoard
// <i> Support using keyboard
#define _SUPPORT_KEYBOARD
// </c>

//是否支持AT24C02
// <c1> Support AT24C02
// <i> Support using AT24C02 to store module parameters
#define _SUPPORT_AT24C02
// </c>

//是否支持W25Q64
// <c1> Support W25Q64
// <i> Support using SPIFLASH to store module parameters
//#define _SUPPORT_W25Q64
// </c>

//是否支持SD卡
// <c1> Support SDCard
// <i> Support using SPIFLASH to store module parameters
#define _SUPPORT_SDCARD
// </c>

//版本信息
// <s>Version information
//  <i>version 
#define BEARPI_CONFIG_VERSION "1.0.0"

#endif //__BEARPI_CONFIG_H
// <<< end of configuration section >>>

The final effect is as follows:

95ea406d673fb20656fc3a865168b133.png

 When we select the corresponding function, the macro definition will automatically modify the corresponding parameters for us, such as modifying the version information:

20220326

1798314fa80b4d80522c12f1f68a7b9c.png

We can see that this macro definition in the .h file has modified this value:

08ee2dd989555524bd2cc2a004d50252.png

This function provided by Keil MDK is really a boon for microcontroller engineers! ! ! !

References

[1]https://www.keil.com/support/man/docs/uv4cl/uv4cl_ut_configwizard.htm

[2]https://blog.csdn.net/qq_15647227/article/details/89297207

—— The End ——

Recommended in the past

Have you mastered the embedded basic knowledge points that novices often overlook?

An interesting project, OLED realizes "naked eye 3D"

A collection of domestic alternative selections for single-chip microcomputers, it is imperative!

Walk into the fab and gain an in-depth understanding of the chip manufacturing process

The degree of automation of the DJI factory is really a bit high

Practical single-chip reverse circuit, no longer afraid of reverse power supply

The most suitable communication protocol for single-chip microcomputer, how to design?

Click on the card above to follow me

c79b21f1315d2e3917235ce8fdde7304.png

Everything you ordered looks good , I take it seriously as I like it

Guess you like

Origin blog.csdn.net/u010632165/article/details/124162184