From 8f8f2050cf25089c93845c863bd8368ed9b35f3d Mon Sep 17 00:00:00 2001 From: MoD Date: Fri, 6 Mar 2026 08:11:42 +0100 Subject: [PATCH] =?UTF-8?q?=E2=80=9EHome=E2=80=9C=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Home.md | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 Home.md diff --git a/Home.md b/Home.md new file mode 100644 index 0000000..366a3b7 --- /dev/null +++ b/Home.md @@ -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_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; +} +``` \ No newline at end of file