MDK Keil Template Annotation Template

When writing a program, some norms are often followed. A good code style can improve the readability of the code and facilitate subsequent maintenance and upgrades. The following are some comment templates that imitate the code style of the official hal library source code of stm32.

1. Add user comment template template in MDK

Insert picture description here

2. Commonly used code comment templates

2.1
Define a BSP_DAC_Driver group, and put void bsp_dac1_Init(void) into this group.

 /** @defgroup BSP_DAC_Driver
   * @brief xxx driver modules
   * @{
   */ 
     void bsp_dac1_Init(void);
 /** 
   * @}
   */

2.2
Add void bsp_dac2_Init(void) to the BSP_DAC_Driver group.

   /** @addtogroup BSP_DAC_Driver 
     * @{
     */
       void bsp_dac2_Init(void);
   /** 
     * @}
     */

2.3 The
use of a standardized code comment mode can enhance the readability of the code, and a more comprehensive description can be achieved by using the following sentences.
@brief Briefly describe the function function
@note Note
@param Function parameter
@retval Function return value

/**
  * @brief  停止ADC数据转换
  * @note   NONE
  * @param  NONE
  * @retval NONE
  */
void bsp_adc1_stop(void)
{
    
    
  ///
}

3. Summary

Through MDK's Template function, you can easily add user code comment templates, improve the quality of the code, and facilitate subsequent maintenance and upgrades.

Guess you like

Origin blog.csdn.net/weixin_41344412/article/details/114149159