内江市规划建设教育培训 网站,数字城市建设网站,网络服务抽成,网站搭建免费域名编程规范和变量命令规范对于代码的可阅读性、可维护性有着很大的影响。编程规范有很多#xff0c;大公司也会制定自己公司的编程规范#xff0c;如《华为技术有限公司c语言编程规范》等。对于个人编程来说没必要将自己编写的代码按照每一种编程规范去规范#xff0c;因为不同…编程规范和变量命令规范对于代码的可阅读性、可维护性有着很大的影响。编程规范有很多大公司也会制定自己公司的编程规范如《华为技术有限公司c语言编程规范》等。对于个人编程来说没必要将自己编写的代码按照每一种编程规范去规范因为不同的 规范中可能会有相互冲突的地方。个人可以选择编写的代码阅读起来比较舒服的规范并一直坚持使用如此则可以形成自己的编程风格重点不在于你知道多少种规范的而是要在实际编程中去使用它不必拘泥于某一种规范可以综合几个规范选择适合自己的部分坚持使用。
这里我使用的是陈正冲老师《C语言深度解剖》中的编程规范并根据自己的实际使用做了些改动具体如下。
头文件模板
/*******************************************
* File Name : FN_FileName.h
* CopyRight : All Rights Reserved.
* Module Name : *
* CPU : STM32F103C8T6
* RTOS : RT-THREAD
*
* Creat Date : 2020/09/17
* Author/Corporation : Jason/DJI
*
* Abstract Description:
*
* --------------Revision History----------------
* NO Version Date Revised by Description
* 1 V0.0 2020/09/17 Jason the first verison
*
*******************************************//*******************************************
* Multi-Include-Prevent Section
*******************************************/
#ifndef __FN_FILENAME_H
#define __FN_FILENAME_H
/*******************************************
* Debug switch Section
*******************************************//*******************************************
* Include File Section
*******************************************//*******************************************
* Macro Define Section
*******************************************//*******************************************
* Struct Define Section
*******************************************//*******************************************
* Prototype Declare Section
*******************************************/#endif
源文件模板
/*******************************************
* File Name : FN_FileName.c
* CopyRight : All Rights Reserved.
* Module Name : *
* CPU : STM32F103C8T6
* RTOS : RT-THREAD
*
* Creat Date : 2020/09/17
* Author/Corporation : Jason/DJI
*
* Abstract Description:
*
* --------------Revision History----------------
* NO Version Date Revised by Description
* 1 V0.0 2020/09/17 Jason the first verison
*
*******************************************//*******************************************
* Debug switch Section
*******************************************//*******************************************
* Include File Section
*******************************************//*******************************************
* Macro Define Section
*******************************************//*******************************************
* Struct Define Section
*******************************************//*******************************************
* Prototype Declare Section
*******************************************//*******************************************
* Global Variable Declare Section
*******************************************//*******************************************
* File Static Variable Define Section
*******************************************//*******************************************
* Function Define Section
*******************************************/
函数注释模板
/*******************************************
* Function Name : delay_us
* Creat Date : 2020/09/17
* Author/Corporation : Jason/DJI
* Description : uS levels of delay, use static define delay_us() means this funtion is only used in this file
* Para : nus: the uS delay time
* Return Code : null
------------------------------
* Revision History
* Date Revised by Description
* 2020/09/17 Jason the first verison
*******************************************/
static void delay_us(uint16_t nus)
{
}/*******************************************
* Function Name : Get_ADS1115_Volt
* Creat Date : 2020/09/17
* Author/Corporation : Jason/DJI
* Description : get ADC convert result from ADS115
* Para : channel: ADS1115 channel wants to readtimes: read how many times
* Return Code : volt: the average of several results, unit is mV
------------------------------
* Revision History
* Date Revised by Description
* 2020/09/17 Jason the first verison
*******************************************/
int16_t Get_ADS1115_Volt(enum ADS1115_Channel channel, int16_t times)
{
}