commit 7de0cc90a3bd7145a5160729fddc72a9aa46d330
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Thu Feb 21 18:04:04 2019 +0100

    All preprocessor directives without arguments (e.g. #endif) are now followed by a comment, indicating where it belongs to (e.g. the preceding #if).

diff --git a/core/src/aos_main.cpp b/core/src/aos_main.cpp
index 30cbe06..c340429 100644
--- a/core/src/aos_main.cpp
+++ b/core/src/aos_main.cpp
@@ -33,7 +33,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #if defined(AMIROOS_CFG_MAIN_EXTRA_INCLUDE_HEADER)
 #include AMIROOS_CFG_MAIN_EXTRA_INCLUDE_HEADER
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_EXTRA_INCLUDE_HEADER) */
 
 /******************************************************************************/
 /* LOCAL DEFINITIONS                                                          */
@@ -81,14 +81,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #define SSSP_STACKINIT_CANMSGID_ABORT           0x001
 
-#else /* AMIROOS_CFG_SSSP_ENABLE == false */
+#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
 /**
  * @brief   Default shutdown mode if SSSP is unavailable.
  */
 #define AOS_SHUTDOWN_DEFAULT                    AOS_SHUTDOWN_DEEPSLEEP
 
-#endif /* AMIROOS_CFG_SSSP_ENABLE */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
 /**
  * @brief   CAN message identifier for calender synchronization message.
@@ -136,7 +136,7 @@ static AosShellChannel _stdshellchannel;
  */
 #if defined(AMIROOS_CFG_MAIN_EXTRA_STATIC_VARIABLES)
 AMIROOS_CFG_MAIN_EXTRA_STATIC_VARIABLES
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_EXTRA_STATIC_VARIABLES) */
 
 /******************************************************************************/
 /* LOCAL FUNCTIONS                                                            */
@@ -152,10 +152,10 @@ static inline void _unexpectedEventError(const eventmask_t mask, const eventflag
 {
 #if (AMIROOS_CFG_DBG == true)
   aosprintf("CTRL: unexpected/unknown event received. mask: 0x%08X; flags: 0x%08X\n", mask, flags);
-#else
+#else /* (AMIROOS_CFG_DBG == true) */
   (void)(mask);
   (void)(flags);
-#endif
+#endif /* (AMIROOS_CFG_DBG == true) */
   return;
 }
 
@@ -175,7 +175,7 @@ static void _ssspTimerCallback(void* par)
 
   return;
 }
-#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
 /**
  * @brief   Helper function to serialize data.
@@ -276,7 +276,7 @@ inline void _U642TM(struct tm* dst, const uint64_t src)
   return;
 }
 
-#endif /* HAL_USE_RTC == TRUE */
+#endif /* (HAL_USE_RTC == TRUE) */
 
 #if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__)
 /**
@@ -325,7 +325,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
   CANRxFrame canRxFrame;
 #if (AMIROOS_CFG_SSSP_STACK_START != true) || (AMIROOS_CFG_DBG == true)
   aos_ssspmoduleid_t lastid = 0;
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_START != true) || (AMIROOS_CFG_DBG == true) */
   flags_t flags;
   aos_timestamp_t uptime;
 
@@ -405,7 +405,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
         aosDbgPrintf(">>> 3-4 (abort)\n");
         break;
     }
-#endif
+#endif /* (AMIROOS_CFG_DBG == true) */
 
     // reset wfe flag for the next iteration
     flags.wfe_next = true;
@@ -446,7 +446,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
 #if (AMIROOS_CFG_SSSP_STACK_END != true)
         aosDbgPrintf("disabling UP\n");
         apalControlGpioSet(&moduleSsspGpioUp, APAL_GPIO_OFF);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_END != true) */
         // set shutdown flag and exit the loop
         shutdown = AOS_SHUTDOWN_PASSIVE;
         break;
@@ -474,11 +474,11 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
       // get the flags
       eventflags_t oseventflags = chEvtGetAndClearFlags(&_eventListenerOS);
       // there should be no OS events at this point
-#ifdef MODULE_SSSP_STARTUP_3_OSEVENT_HOOK
+#if defined(MODULE_SSSP_STARTUP_3_OSEVENT_HOOK)
       MODULE_SSSP_STARTUP_3_OSEVENT_HOOK(eventmask, eventflags);
-#else
+#else /* defined(MODULE_SSSP_STARTUP_3_OSEVENT_HOOK) */
       _unexpectedEventError(eventmask, oseventflags);
-#endif
+#endif /* defined(MODULE_SSSP_STARTUP_3_OSEVENT_HOOK) */
     }
     // if a CAN event occurred
     if ((eventmask & eventListenerCan.events)) {
@@ -536,16 +536,16 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           // proceed immediately
           stage = STAGE_3_2;
           flags.wfe_next = false;
-#else
+#else /* (AMIROOS_CFG_SSSP_STACK_START == true) */
           // set the timeout timer
           chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
           // proceed
           stage = STAGE_3_3_WAITFORFIRSTID;
-#endif
-#else
+#endif /* (AMIROOS_CFG_SSSP_STACK_START == true) */
+#else /* (AMIROOS_CFG_SSSP_MASTER == true) */
           // set the timeout timer
           chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
         }
 
 #if (AMIROOS_CFG_SSSP_MASTER != true)
@@ -568,15 +568,15 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
             // proceed
             stage = STAGE_3_2;
             flags.wfe_next = false;
-#else
+#else /* (AMIROOS_CFG_SSSP_STACK_START == true) */
             // set the timeout timer
             chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
             // proceed
             stage = STAGE_3_3_WAITFORFIRSTID;
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_START == true) */
           }
         }
-#endif
+#endif /* (AMIROOS_CFG_SSSP_MASTER != true) */
 
         break;
       } /* end of STAGE_3_1 */
@@ -599,9 +599,9 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
             chEvtBroadcast(&eventSourceTimeout);
             break;
           }
-#if (AMIROOS_CFG_SSSP_STACK_START != true) || (AMIROOS_CFG_DBG == true)
+#if (AMIROOS_CFG_DBG == true)
           lastid = aos.sssp.moduleId;
-#endif
+#endif /* (AMIROOS_CFG_DBG == true) */
 #if (AMIROOS_CFG_SSSP_STACK_END == true)
           // sequence is already over
           // deactivate S
@@ -609,10 +609,10 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           apalControlGpioSet(&moduleSsspGpioSync, APAL_GPIO_OFF);
           // proceed
           stage = STAGE_3_3_WAITFORID;
-#else
+#else /* (AMIROOS_CFG_SSSP_STACK_END == true) */
           // set the delay timer so the UP signal is activated later
           chVTSet(&timerDelay, chTimeUS2I(AMIROOS_CFG_SSSP_SIGNALDELAY), _ssspTimerCallback, &eventSourceDelay);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_END == true) */
         }
 
         // if a delay event occurred
@@ -629,7 +629,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           // proceed
           stage = STAGE_3_3_WAITFORID;
         }
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_START == true) */
 
         break;
       } /* end of STAGE_3_2 */
@@ -666,7 +666,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
             eventmask &= ~(eventListenerTimeout.events);
           }
         }
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_START != true) */
         break;
       } /* end of STAGE_3_3_WAITFORFIRSTID */
 
@@ -728,7 +728,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           // activate UP
           aosDbgPrintf("enabling UP\n");
           apalControlGpioSet(&moduleSsspGpioUp, APAL_GPIO_ON);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_END != true) */
           // deactivate S
           aosDbgPrintf("disabling S\n");
           apalControlGpioSet(&moduleSsspGpioSync, APAL_GPIO_OFF);
@@ -739,7 +739,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           // proceed
           stage = STAGE_3_3_WAITFORID;
         }
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_START != true) */
 
         break;
       } /* end of STAGE_3_3_WAITFORIDORSIG */
@@ -760,14 +760,14 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
             // Plausibility of the received ID is not checked at this point but is done by other modules still in a previous stage.
             lastid = _deserialize(canRxFrame.data8, 4);
             aosDbgPrintf("ID (%u)\n", lastid);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_START != true) || (AMIROOS_CFG_DBG == true) */
             // restart timeout timer
             chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
             chEvtWaitAnyTimeout(eventListenerTimeout.events, TIME_IMMEDIATE);
             eventmask &= ~(eventListenerTimeout.events);
           }
         }
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_END != true) */
 
         break;
       } /* end of STAGE_3_3_WAITFORID */
@@ -877,7 +877,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
 #if (AMIROOS_CFG_SSSP_STACK_END != true)
   aosDbgPrintf("disabling UP\n");
   apalControlGpioSet(&moduleSsspGpioUp, APAL_GPIO_OFF);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_END != true) */
   aosDbgPrintf("disabling S\n");
   apalControlGpioSet(&moduleSsspGpioSync, APAL_GPIO_OFF);
   aosSysGetUptime(&uptime);
@@ -885,7 +885,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
 
   return shutdown;
 }
-#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
 /**
  * @brief   Application entry point.
@@ -899,7 +899,7 @@ int main(void)
   aos_shutdown_t shutdown = AOS_SHUTDOWN_NONE;
 #if defined(AMIROOS_CFG_MAIN_EXTRA_THREAD_VARIABLES)
   AMIROOS_CFG_MAIN_EXTRA_THREAD_VARIABLES
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_EXTRA_THREAD_VARIABLES) */
 
   /*
    * ##########################################################################
@@ -910,68 +910,68 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_0)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_0_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_0(AMIROOS_CFG_MAIN_INIT_HOOK_0_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_0_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_0();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_0_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_0) */
 
   /* hardware, kernel, and operating system initialization */
   // ChibiOS/HAL and custom hal additions (if any)
   halInit();
-#ifdef MODULE_INIT_HAL_EXTRA
+#if defined(MODULE_INIT_HAL_EXTRA)
   MODULE_INIT_HAL_EXTRA();
-#endif
+#endif /* defined(MODULE_INIT_HAL_EXTRA) */
 
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_1)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_1_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_1(AMIROOS_CFG_MAIN_INIT_HOOK_1_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_1_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_1();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_1_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_1) */
 
   // ChibiOS/RT kernel and custom kernel additions (if any)
   chSysInit();
-#ifdef MODULE_INIT_KERNEL_EXTRA
+#if defined(MODULE_INIT_KERNEL_EXTRA)
   MODULE_INIT_KERNEL_EXTRA();
-#endif
+#endif /* defined(MODULE_INIT_KERNEL_EXTRA) */
 
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_2)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_2_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_2(AMIROOS_CFG_MAIN_INIT_HOOK_2_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_2_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_2();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_2_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_2) */
 
   // AMiRo-OS and custom OS additions (if any)
 #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true)
   aosSysInit(moduleShellPrompt);
-#else
+#else /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
   aosSysInit();
-#endif
-#ifdef MODULE_INIT_OS_EXTRA
+#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
+#if defined(MODULE_INIT_OS_EXTRA)
   MODULE_INIT_OS_EXTRA();
-#endif
+#endif /* defined(MODULE_INIT_OS_EXTRA) */
 
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_3)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_3_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_3(AMIROOS_CFG_MAIN_INIT_HOOK_3_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_3_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_3();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_3_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_3) */
 
   /* event associations */
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   ioeventflagsmask |= MODULE_SSSP_EVENTFLAGS_PD | MODULE_SSSP_EVENTFLAGS_SYNC;
 #if (AMIROOS_CFG_SSSP_STACK_START != true)
   ioeventflagsmask |= MODULE_SSSP_EVENTFLAGS_DN;
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_START != true) */
 #if (AMIROOS_CFG_SSSP_STACK_END != true)
   ioeventflagsmask |= MODULE_SSSP_EVENTFLAGS_UP;
-#endif
-#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
+#endif /* (AMIROOS_CFG_SSSP_STACK_END != true) */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   if (ioeventflagsmask != 0) {
     chEvtRegisterMaskWithFlags(&aos.events.io, &_eventListenerIO, IOEVENT_MASK, ioeventflagsmask);
   }
@@ -980,22 +980,22 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_4)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_4_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_4(AMIROOS_CFG_MAIN_INIT_HOOK_4_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_4_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_4();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_4_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_4) */
 
   /* periphery communication initialization */
   // module specific initialization (if any)
-#ifdef MODULE_INIT_PERIPHERY_COMM
+#if defined(MODULE_INIT_PERIPHERY_COMM)
   MODULE_INIT_PERIPHERY_COMM();
-#endif
+#endif /* defined(MODULE_INIT_PERIPHERY_COMM) */
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   // CAN (mandatory)
   canStart(&MODULE_HAL_CAN, &moduleHalCanConfig);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   // user interface (if any)
-#ifdef MODULE_HAL_PROGIF
+#if defined(MODULE_HAL_PROGIF)
   aosIOChannelInit(&_stdiochannel, (BaseAsynchronousChannel*)&MODULE_HAL_PROGIF);
   aosIOChannelOutputEnable(&_stdiochannel);
   aosIOStreamAddChannel(&aos.iostream, &_stdiochannel);
@@ -1004,16 +1004,16 @@ int main(void)
   aosShellChannelInputEnable(&_stdshellchannel);
   aosShellChannelOutputEnable(&_stdshellchannel);
   aosShellStreamAddChannel(&aos.shell.stream, &_stdshellchannel);
-#endif
-#endif
+#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
+#endif /* defined(MODULE_HAL_PROGIF) */
 
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_5)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_5_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_5(AMIROOS_CFG_MAIN_INIT_HOOK_5_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_5_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_5();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_5_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_5) */
 
   /* module is ready -> print welcome prompt */
   aosprintf("\n");
@@ -1035,26 +1035,26 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_6)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_6_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_6(AMIROOS_CFG_MAIN_INIT_HOOK_6_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_6_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_6();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_6_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_6) */
 
 #if (AMIROOS_CFG_TESTS_ENABLE == true)
 #if defined(MODULE_INIT_TESTS)
   MODULE_INIT_TESTS();
-#else
-  #warning "MODULE_INIT_TESTS() not defined"
-#endif
-#endif
+#else /* defined(MODULE_INIT_TESTS) */
+  #warning "AMIROOS_CFG_TESTS_ENABLE set to true, but MODULE_INIT_TESTS() not defined"
+#endif /* defined(MODULE_INIT_TESTS) */
+#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
 
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_7)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_7_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_7(AMIROOS_CFG_MAIN_INIT_HOOK_7_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_7_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_7();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_7_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_7) */
 
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   /* SSSP startup OS synchronization phase (end of startup stage 2) */
@@ -1070,11 +1070,11 @@ int main(void)
       if (eventflags & MODULE_SSSP_EVENTFLAGS_PD) {
         shutdown = AOS_SHUTDOWN_PASSIVE;
       } else {
-#ifdef MODULE_SSSP_STARTUP_2_2_IOEVENT_HOOK
+#if defined(MODULE_SSSP_STARTUP_2_2_IOEVENT_HOOK)
         MODULE_SSSP_STARTUP_2_2_IOEVENT_HOOK(eventmask, eventflags);
-#else
+#else /* defined(MODULE_SSSP_STARTUP_2_2_IOEVENT_HOOK) */
         // ignore any other IO events
-#endif
+#endif /* defined(MODULE_SSSP_STARTUP_2_2_IOEVENT_HOOK) */
       }
     }
     // OS event
@@ -1096,7 +1096,7 @@ int main(void)
   if (shutdown == AOS_SHUTDOWN_NONE) {
     shutdown = _ssspModuleStackInitialization();
   }
-#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
   /*
    * There must be no delays at this point, thus no hook is allowed.
@@ -1126,7 +1126,7 @@ int main(void)
     canTransmitTimeout(&MODULE_HAL_CAN, CAN_ANY_MAILBOX, &frame, TIME_IMMEDIATE);
 
     aosDbgPrintf("done\n");
-#else /* AMIROOS_CFG_SSSP_MASTER == false */
+#else /* (AMIROOS_CFG_SSSP_MASTER == true) */
     CANRxFrame frame;
     uint64_t encoded;
     struct tm t;
@@ -1136,9 +1136,9 @@ int main(void)
 #if (AMIROOS_CFG_DBG == true)
     // increase timeout in debug mode due to additional delays introduced by the many prinf() calls
     if (canReceiveTimeout(&MODULE_HAL_CAN, CAN_ANY_MAILBOX, &frame, chTimeUS2I(10 * AOS_SYSTEM_SSSP_TIMEOUT)) == MSG_OK) {
-#else
+#else /* (AMIROOS_CFG_DBG == true) */
     if (canReceiveTimeout(&MODULE_HAL_CAN, CAN_ANY_MAILBOX, &frame, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT)) == MSG_OK) {
-#endif
+#endif /* (AMIROOS_CFG_DBG == true) */
       // validate message
       if (frame.DLC == 8 &&
           frame.RTR == CAN_RTR_DATA &&
@@ -1157,7 +1157,7 @@ int main(void)
     } else {
       aosDbgPrintf("fail (timeout)\n");
     }
-#endif /* AMIROOS_CFG_SSSP_MASTER == false */
+#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
     aosDbgPrintf("\n");
   }
 #endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (HAL_USE_RTC == TRUE) */
@@ -1165,10 +1165,10 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_8)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_8_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_8(AMIROOS_CFG_MAIN_INIT_HOOK_8_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_8_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_8();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_8_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_8) */
 
   /* completely start AMiRo-OS */
   if (shutdown == AOS_SHUTDOWN_NONE) {
@@ -1178,10 +1178,10 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_9)
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_9_ARGS)
   AMIROOS_CFG_MAIN_INIT_HOOK_9(AMIROOS_CFG_MAIN_INIT_HOOK_9_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_9_ARGS) */
   AMIROOS_CFG_MAIN_INIT_HOOK_9();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_9_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_INIT_HOOK_9) */
 
   /*
    * ##########################################################################
@@ -1194,17 +1194,17 @@ int main(void)
     // wait for an event
 #if (AMIROOS_CFG_MAIN_LOOP_TIMEOUT != 0)
     eventmask = chEvtWaitOneTimeout(ALL_EVENTS, chTimeUS2I(AMIROOS_CFG_MAIN_LOOP_TIMEOUT));
-#else
+#else /* (AMIROOS_CFG_MAIN_LOOP_TIMEOUT != 0) */
     eventmask = chEvtWaitOne(ALL_EVENTS);
-#endif
+#endif /* (AMIROOS_CFG_MAIN_LOOP_TIMEOUT != 0) */
 
 #if defined(AMIROOS_CFG_MAIN_LOOP_HOOK_0)
 #if defined(AMIROOS_CFG_MAIN_LOOP_HOOK_0_ARGS)
     AMIROOS_CFG_MAIN_LOOP_HOOK_0(AMIROOS_CFG_MAIN_LOOP_HOOK_0_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_LOOP_HOOK_0_ARGS) */
     AMIROOS_CFG_MAIN_LOOP_HOOK_0();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_LOOP_HOOK_0_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_LOOP_HOOK_0) */
 
     switch (eventmask) {
       // if this was an I/O event
@@ -1217,16 +1217,16 @@ int main(void)
           shutdown = AOS_SHUTDOWN_PASSIVE;
         }
         // all other events
-#ifdef MODULE_MAIN_LOOP_IO_EVENT
+#if defined(MODULE_MAIN_LOOP_IO_EVENT)
         else {
           MODULE_MAIN_LOOP_IO_EVENT(eventflags);
         }
-#endif
-#else /* AMIROOS_CFG_SSSP_ENABLE == false */
-#ifdef MODULE_MAIN_LOOP_IO_EVENT
+#endif /* defined(MODULE_MAIN_LOOP_IO_EVENT) */
+#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */
+#if defined(MODULE_MAIN_LOOP_IO_EVENT)
         MODULE_MAIN_LOOP_IO_EVENT(eventflags);
-#endif
-#endif /* AMIROOS_CFG_SSSP_ENABLE */
+#endif /* defined(MODULE_MAIN_LOOP_IO_EVENT) */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
         break;
 
       // if this was an OS event
@@ -1247,11 +1247,11 @@ int main(void)
           case AOS_SYSTEM_EVENTFLAGS_RESTART:
             shutdown = AOS_SHUTDOWN_RESTART;
             break;
-#else /* AMIROOS_CFG_SSSP_ENABLE == false */
+#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */
           case AOS_SYSTEM_EVENTFLAGS_SHUTDOWN:
             shutdown = AOS_SHUTDOWN_DEFAULT;
             break;
-#endif /* AMIROOS_CFG_SSSP_ENABLE */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
           default:
             _unexpectedEventError(eventmask, eventflags);
             break;
@@ -1263,17 +1263,17 @@ int main(void)
         eventflags = 0;
 #if (AMIROOS_CFG_MAIN_LOOP_TIMEOUT == 0)
         _unexpectedEventError(eventmask, eventflags);
-#endif
+#endif /* (AMIROOS_CFG_MAIN_LOOP_TIMEOUT == 0) */
         break;
     }
 
 #if defined(AMIROOS_CFG_MAIN_LOOP_HOOK_1)
 #if defined(AMIROOS_CFG_MAIN_LOOP_HOOK_1_ARGS)
     AMIROOS_CFG_MAIN_LOOP_HOOK_1(AMIROOS_CFG_MAIN_LOOP_HOOK_1_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_LOOP_HOOK_1_ARGS) */
     AMIROOS_CFG_MAIN_LOOP_HOOK_1();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_LOOP_HOOK_1_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_LOOP_HOOK_1) */
   }
 
   /*
@@ -1285,10 +1285,10 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_0)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_0_ARGS)
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_0(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_0_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_0_ARGS) */
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_0();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_0_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_0) */
 
   // initialize/acknowledge shutdown
   aosSysShutdownInit(shutdown);
@@ -1296,10 +1296,10 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_1)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_1_ARGS)
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_1(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_1_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_1_ARGS) */
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_1();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_1_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_1) */
 
   // stop system threads
   aosSysStop();
@@ -1307,10 +1307,10 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_2)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_2_ARGS)
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_2(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_2_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_2_ARGS) */
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_2();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_2_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_2) */
 
   // deinitialize system
   aosSysDeinit();
@@ -1318,27 +1318,27 @@ int main(void)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_3)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_3_ARGS)
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_3(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_3_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_3_ARGS) */
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_3();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_3_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_3) */
 
   /* stop all periphery communication */
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   // CAN (mandatory)
   canStop(&MODULE_HAL_CAN);
-#endif
-#ifdef MODULE_SHUTDOWN_PERIPHERY_COMM
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
+#if defined(MODULE_SHUTDOWN_PERIPHERY_COMM)
   MODULE_SHUTDOWN_PERIPHERY_COMM();
-#endif
+#endif /* defined(MODULE_SHUTDOWN_PERIPHERY_COMM) */
 
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_4)
 #if defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_4_ARGS)
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_4(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_4_ARGS);
-#else
+#else /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_4_ARGS) */
     AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_4();
-#endif
-#endif
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_4_ARGS) */
+#endif /* defined(AMIROOS_CFG_MAIN_SHUTDOWN_HOOK_4) */
 
   // finally hand over to bootloader
   aosSysShutdownFinal(shutdown);
