„Home“ hinzufügen

master
MoD 2 weeks ago
commit 8f8f2050cf

@ -0,0 +1,99 @@
# Coding Guide
## ToDo's and Discussion
* Rieter data type (ru8, ru16, ru32, ri8, ri16, ri32, rbool, ...)
* Use Googles StyleGuide https://google.github.io/styleguide/cppguide.html?
## Generell
* Indentation `Instead of Tabulator use 4 Spaces`
* Variables `Names are in CamelCase`
* Queues `Only used in ther own modul`
* Global variables / extern declaration `Avoid them - use getter/setter-functions` `(If it is really needed use include of its header instead of another extern declaration)`
* Follow the rule `Code is like humor - if you have to explain it, it's bad`
## Module
* Name is a combination of its software layer which its from and the feature of it (TBD prefix "r")
* Initialization-function is needed by every modul (empty or not) called modulnameInit
* Every modul (c/cpp) has own (or more) h/hpp files with the same filename (more files use postfix)
Standard: LayerFeature.c and LayerFeature.h
Optional: LayerFeatureUsecase.h
## Functions
* Functions with return only has one return in the last row
## Includes
## Defines / Macros
* Start with prefix D_
* Only use UPPERCASE
* Use brackets for the value
* Global defines also have the modulname where they come from
* Macros use M_ as prefix instead of D_
* Avoid magic numbers in code and use defines instead
```
#define D_<MODULNAME_>FEATURE_NAME (value) //comment
#define D_STACKSIZE_DEBUG (0x200) //bytes
#define D_YARNHANDLE_TIMER_XYZ (12) //ms
```
## Enumerations
* Enumtype start with prefix te followed by Modul which it comes from and the Name d
* Enumerations start with e followed by Modul, Name (of enum) and _NAME (uppercase for constant name)
* Set the first enumeration to zero, if possible
```
typedef enum{
eModulName_INIT = 0,
eModulName_START,
eModulName_END,
eModulName_NUM
}teModulName;
```
## Structs
* Name start with prefix ts followed by Modul which it comes from and the Name
```
typedef struct{
uint8_t sFeatureName1;
int32_t sFeatureName2
}tsModulName;
tsModulName sName = {
.sFeatureName1 = 0;
.sFeatureName2 = -12;
};
```
## If / Switch case
* Curly brackets for every if/else/elseif-case
* Constants on the left side at if/elseif to avoid "=" instead of "==" bugs
* Always use default-case in switch
```
if(0x1337 == variable){
//code
} else {
//code
}
if(0x1337 == variable){
//code
}
else{
; //code
}
switch(variable){
case 0:
//code
break;
default:
//code or not
break;
}
```
Loading…
Cancel
Save