-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Author: T.Meerstetter
To ensure a common coding style in the software some rules are defined.
! This Guidelines are still under construction !
#Overview
Acronym | Description |
---|---|
l | l ong - 32 bit variable |
s | s hort - 16 bit variable |
c | c har - 8 bit variable |
u | u nsigned - e.g. ul = unsigned long |
e | e numeration |
p | p ointer - e.g. pl = pointer to long |
v | v oid - functions with no return type |
prv | pr i v ate - File intern functions |
os | o perating s ystem - RTX Thread functions |
######Table: Prefix acronym list |
#Naming Conventions
##Variables ####Prefix Variables which are visible outside of a function follow these rules:
-
Variables of type uint32_t are prefixed ul, where the 'u' denotes 'unsigned' and the 'l' denotes 'long'.
-
Variables of type uint16_t are prefixed us, where the 'u' denotes 'unsigned' and the 's' denotes 'short'.
-
Variables of type uint8_t are prefixed uc, where the 'u' denotes 'unsigned' and the 'c' denotes 'char'.
-
Variables of non stdint types are prefixed x.
-
Unsigned variables of non stdint types have an additional prefix u.
-
Enumerated variables are prefixed e
-
Pointers have an additional prefixed p, for example a pointer to a uint16_t will have prefix pus.
-
Function intern variables don’t need these prefixes, but they should have meaningful names.
####Case Sensitivity
- Variables start with a lowercase letter.
- Every new word in the name starts with an uppercase letter
Example: uint32_t ulTestVariable
or with no prefix (function intern variable): uint32_t testVariable
##Functions ####Prefix
- File scope static (private) functions are prefixed with prv.
- API functions are prefixed with their return type, as per the convention defined for variables, with the addition of the prefix v for void.
- Keil RTX functions (thead initialisation) are prefixed with os for operating system
####Case Sensitivity
-
All functions start with the lowercase prefix
-
Every new word in the name starts with an uppercase letter , just like variables
Example:
void prvFunctionName(uint32_t ulInput) { ... }
######Code: Example of a function
##Defines
-
Defines are all written in **upper case ** letters and are separated with an underscore
-
Global used defines are located in the header files.
-
Only file intern used defines are located in the source file.
Example:
#define DEFINE_NAME "Name"
######Code: Example of a define
##Macros
-
Macros are prefixed with a lower case indicator of the macros origin file.
-
After the prefix all letters are upper case and are separated with an underscore
Example:
#define ledGPIO_HIGH(a,b) a->BSRRL = b
######Code: Macro to set a LED GPIO, located in the led.c/.h file.
#Style Guide
##Headers
Every souce- / headerfile or function has a Doxygen conform comment header with a short description and some other information. The Header files used in this software are located in extern Gists (see section below).
Example:
/***********************************************************************/
/* Function: prvFunctionName */
/***********************************************************************/
/*! \brief Short description of the function
*
* Function : More detailed description of the function
*
* \param[in] ulInput Comment for parameter1
*
* \return None
*
* \author Name
*
* \version 0.0.1
*
* \date dd.mm.jjjj Function created
*
************************************************************************/
void prvFunctionName(uint32_t ulInput)
{
...
}
/* *********************************************************************/
/* End : prvFunctionName */
/* *********************************************************************/
######Code: Example of a function header
####Gists
##Comments
/* Comments are made like this */
only use double slash (//) comments for commenting out code parts
##Layout