commit 1e5f7648efbb73f81b28ef3450552585a0207dda
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Wed Sep 5 17:22:20 2018 +0200

    Major rework of the recent changes.
    - optimized interrupt system (removed aos_interrupt.h/c)
    - updated AMiRo-LLD submodule
    - updated all config files to match the latest templates by ChibiOS
    - fixed several issues regarding the new timer system (intervals)

diff --git a/modules/DiWheelDrive_1-1/alldconf.h b/modules/DiWheelDrive_1-1/alldconf.h
index 5b810a1..c3a3b66 100644
--- a/modules/DiWheelDrive_1-1/alldconf.h
+++ b/modules/DiWheelDrive_1-1/alldconf.h
@@ -27,6 +27,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define AMIRO_LLD_CFG_VERSION_MINOR         0
 
 /**
+ * @brief   Width of the apalTime_t data type.
+ *
+ * @details Possible values are 8, 16, 32, and 64 bits.
+ *          By definition time is represented ot a microsecond precision.
+ */
+#define AMIROLLD_CFG_TIME_SIZE          32
+
+/**
  * @brief   Enable flag for the A3906 motor driver.
  */
 #define AMIROLLD_CFG_USE_A3906
diff --git a/modules/DiWheelDrive_1-1/chconf.h b/modules/DiWheelDrive_1-1/chconf.h
index 68fe112..c8db701 100644
--- a/modules/DiWheelDrive_1-1/chconf.h
+++ b/modules/DiWheelDrive_1-1/chconf.h
@@ -32,6 +32,8 @@
 #define _CHIBIOS_RT_CONF_
 #define _CHIBIOS_RT_CONF_VER_5_1_
 
+#include <aosconf.h>
+
 /*===========================================================================*/
 /**
  * @name System timers settings
@@ -47,42 +49,7 @@
 #define CH_CFG_ST_RESOLUTION                16
 #endif
 
-/**
- * @brief   System tick frequency.
- * @details Frequency of the system timer that drives the system ticks. This
- *          setting also defines the system tick time unit.
- */
-#if !defined(CH_CFG_ST_FREQUENCY)
-#define CH_CFG_ST_FREQUENCY                 1000000UL
-#endif
-
-/**
- * @brief   Time intervals data size.
- * @note    Allowed values are 16, 32 or 64 bits.
- */
-#if !defined(CH_CFG_INTERVALS_SIZE)
-#define CH_CFG_INTERVALS_SIZE               64
-#endif
-
-/**
- * @brief   Time types data size.
- * @note    Allowed values are 16 or 32 bits.
- */
-#if !defined(CH_CFG_TIME_TYPES_SIZE)
-#define CH_CFG_TIME_TYPES_SIZE              32
-#endif
-
-/**
- * @brief   Time delta constant for the tick-less mode.
- * @note    If this value is zero then the system uses the classic
- *          periodic tick. This value represents the minimum number
- *          of ticks that is safe to specify in a timeout directive.
- *          The value one is not valid, timeouts are rounded up to
- *          this value.
- */
-#if !defined(CH_CFG_ST_TIMEDELTA)
-#define CH_CFG_ST_TIMEDELTA                 10
-#endif
+// more common definition in aos_chconf.h
 
 /** @} */
 
@@ -93,47 +60,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Round robin interval.
- * @details This constant is the number of system ticks allowed for the
- *          threads before preemption occurs. Setting this value to zero
- *          disables the preemption for threads with equal priority and the
- *          round robin becomes cooperative. Note that higher priority
- *          threads can still preempt, the kernel is always preemptive.
- * @note    Disabling the round robin preemption makes the kernel more compact
- *          and generally faster.
- * @note    The round robin preemption is not supported in tickless mode and
- *          must be set to zero in that case.
- */
-#if !defined(CH_CFG_TIME_QUANTUM)
-#define CH_CFG_TIME_QUANTUM                 0
-#endif
-
-/**
- * @brief   Managed RAM size.
- * @details Size of the RAM area to be managed by the OS. If set to zero
- *          then the whole available RAM is used. The core memory is made
- *          available to the heap allocator and/or can be used directly through
- *          the simplified core memory allocator.
- *
- * @note    In order to let the OS manage the whole RAM the linker script must
- *          provide the @p __heap_base__ and @p __heap_end__ symbols.
- * @note    Requires @p CH_CFG_USE_MEMCORE.
- */
-#if !defined(CH_CFG_MEMCORE_SIZE)
-#define CH_CFG_MEMCORE_SIZE                 0
-#endif
-
-/**
- * @brief   Idle thread automatic spawn suppression.
- * @details When this option is activated the function @p chSysInit()
- *          does not spawn the idle thread. The application @p main()
- *          function becomes the idle thread and must implement an
- *          infinite loop.
- */
-#if !defined(CH_CFG_NO_IDLE_THREAD)
-#define CH_CFG_NO_IDLE_THREAD               FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -144,17 +71,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   OS optimization.
- * @details If enabled then time efficient rather than space efficient code
- *          is used when two possible implementations exist.
- *
- * @note    This is not related to the compiler optimization options.
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_OPTIMIZE_SPEED)
-#define CH_CFG_OPTIMIZE_SPEED               TRUE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -165,224 +82,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Time Measurement APIs.
- * @details If enabled then the time measurement APIs are included in
- *          the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_TM)
-#define CH_CFG_USE_TM                       FALSE
-#endif
-
-/**
- * @brief   Threads registry APIs.
- * @details If enabled then the registry APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_REGISTRY)
-#define CH_CFG_USE_REGISTRY                 FALSE
-#endif
-
-/**
- * @brief   Threads synchronization APIs.
- * @details If enabled then the @p chThdWait() function is included in
- *          the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_WAITEXIT)
-#define CH_CFG_USE_WAITEXIT                 TRUE
-#endif
-
-/**
- * @brief   Semaphores APIs.
- * @details If enabled then the Semaphores APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_SEMAPHORES)
-#define CH_CFG_USE_SEMAPHORES               FALSE
-#endif
-
-/**
- * @brief   Semaphores queuing mode.
- * @details If enabled then the threads are enqueued on semaphores by
- *          priority rather than in FIFO order.
- *
- * @note    The default is @p FALSE. Enable this if you have special
- *          requirements.
- * @note    Requires @p CH_CFG_USE_SEMAPHORES.
- */
-#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
-#define CH_CFG_USE_SEMAPHORES_PRIORITY      FALSE
-#endif
-
-/**
- * @brief   Mutexes APIs.
- * @details If enabled then the mutexes APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MUTEXES)
-#define CH_CFG_USE_MUTEXES                  TRUE
-#endif
-
-/**
- * @brief   Enables recursive behavior on mutexes.
- * @note    Recursive mutexes are heavier and have an increased
- *          memory footprint.
- *
- * @note    The default is @p FALSE.
- * @note    Requires @p CH_CFG_USE_MUTEXES.
- */
-#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
-#define CH_CFG_USE_MUTEXES_RECURSIVE        FALSE
-#endif
-
-/**
- * @brief   Conditional Variables APIs.
- * @details If enabled then the conditional variables APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_MUTEXES.
- */
-#if !defined(CH_CFG_USE_CONDVARS)
-#define CH_CFG_USE_CONDVARS                 FALSE
-#endif
-
-/**
- * @brief   Conditional Variables APIs with timeout.
- * @details If enabled then the conditional variables APIs with timeout
- *          specification are included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_CONDVARS.
- */
-#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
-#define CH_CFG_USE_CONDVARS_TIMEOUT         FALSE
-#endif
-
-/**
- * @brief   Events Flags APIs.
- * @details If enabled then the event flags APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_EVENTS)
-#define CH_CFG_USE_EVENTS                   TRUE
-#endif
-
-/**
- * @brief   Events Flags APIs with timeout.
- * @details If enabled then the events APIs with timeout specification
- *          are included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_EVENTS.
- */
-#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
-#define CH_CFG_USE_EVENTS_TIMEOUT           TRUE
-#endif
-
-/**
- * @brief   Synchronous Messages APIs.
- * @details If enabled then the synchronous messages APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MESSAGES)
-#define CH_CFG_USE_MESSAGES                 FALSE
-#endif
-
-/**
- * @brief   Synchronous Messages queuing mode.
- * @details If enabled then messages are served by priority rather than in
- *          FIFO order.
- *
- * @note    The default is @p FALSE. Enable this if you have special
- *          requirements.
- * @note    Requires @p CH_CFG_USE_MESSAGES.
- */
-#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
-#define CH_CFG_USE_MESSAGES_PRIORITY        FALSE
-#endif
-
-/**
- * @brief   Mailboxes APIs.
- * @details If enabled then the asynchronous messages (mailboxes) APIs are
- *          included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_SEMAPHORES.
- */
-#if !defined(CH_CFG_USE_MAILBOXES)
-#define CH_CFG_USE_MAILBOXES                FALSE
-#endif
-
-/**
- * @brief   Core Memory Manager APIs.
- * @details If enabled then the core memory manager APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MEMCORE)
-#define CH_CFG_USE_MEMCORE                  FALSE
-#endif
-
-/**
- * @brief   Heap Allocator APIs.
- * @details If enabled then the memory heap allocator APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
- *          @p CH_CFG_USE_SEMAPHORES.
- * @note    Mutexes are recommended.
- */
-#if !defined(CH_CFG_USE_HEAP)
-#define CH_CFG_USE_HEAP                     FALSE
-#endif
-
-/**
- * @brief   Memory Pools Allocator APIs.
- * @details If enabled then the memory pools allocator APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MEMPOOLS)
-#define CH_CFG_USE_MEMPOOLS                 FALSE
-#endif
-
-/**
- * @brief  Objects FIFOs APIs.
- * @details If enabled then the objects FIFOs APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_OBJ_FIFOS)
-#define CH_CFG_USE_OBJ_FIFOS                FALSE
-#endif
-
-/**
- * @brief   Dynamic Threads APIs.
- * @details If enabled then the dynamic threads creation APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_WAITEXIT.
- * @note    Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
- */
-#if !defined(CH_CFG_USE_DYNAMIC)
-#define CH_CFG_USE_DYNAMIC                  FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -393,60 +93,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Objects Factory APIs.
- * @details If enabled then the objects factory APIs are included in the
- *          kernel.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_CFG_USE_FACTORY)
-#define CH_CFG_USE_FACTORY                  FALSE
-#endif
-
-/**
- * @brief   Maximum length for object names.
- * @details If the specified length is zero then the name is stored by
- *          pointer but this could have unintended side effects.
- */
-#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
-#define CH_CFG_FACTORY_MAX_NAMES_LENGTH     8
-#endif
-
-/**
- * @brief   Enables the registry of generic objects.
- */
-#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
-#define CH_CFG_FACTORY_OBJECTS_REGISTRY     TRUE
-#endif
-
-/**
- * @brief   Enables factory for generic buffers.
- */
-#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
-#define CH_CFG_FACTORY_GENERIC_BUFFERS      TRUE
-#endif
-
-/**
- * @brief   Enables factory for semaphores.
- */
-#if !defined(CH_CFG_FACTORY_SEMAPHORES)
-#define CH_CFG_FACTORY_SEMAPHORES           TRUE
-#endif
-
-/**
- * @brief   Enables factory for mailboxes.
- */
-#if !defined(CH_CFG_FACTORY_MAILBOXES)
-#define CH_CFG_FACTORY_MAILBOXES            TRUE
-#endif
-
-/**
- * @brief   Enables factory for objects FIFOs.
- */
-#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
-#define CH_CFG_FACTORY_OBJ_FIFOS            TRUE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -457,106 +104,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Debug option, kernel statistics.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_STATISTICS)
-#define CH_DBG_STATISTICS                   FALSE
-#endif
-
-/**
- * @brief   Debug option, system state check.
- * @details If enabled the correct call protocol for system APIs is checked
- *          at runtime.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
-#define CH_DBG_SYSTEM_STATE_CHECK           FALSE
-#endif
-
-/**
- * @brief   Debug option, parameters checks.
- * @details If enabled then the checks on the API functions input
- *          parameters are activated.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_CHECKS)
-#define CH_DBG_ENABLE_CHECKS                FALSE
-#endif
-
-/**
- * @brief   Debug option, consistency checks.
- * @details If enabled then all the assertions in the kernel code are
- *          activated. This includes consistency checks inside the kernel,
- *          runtime anomalies and port-defined checks.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_ASSERTS)
-#define CH_DBG_ENABLE_ASSERTS               TRUE
-#endif
-
-/**
- * @brief   Debug option, trace buffer.
- * @details If enabled then the trace buffer is activated.
- *
- * @note    The default is @p CH_DBG_TRACE_MASK_DISABLED.
- */
-#if !defined(CH_DBG_TRACE_MASK)
-#define CH_DBG_TRACE_MASK                   CH_DBG_TRACE_MASK_DISABLED
-#endif
-
-/**
- * @brief   Trace buffer entries.
- * @note    The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
- *          different from @p CH_DBG_TRACE_MASK_DISABLED.
- */
-#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
-#define CH_DBG_TRACE_BUFFER_SIZE            128
-#endif
-
-/**
- * @brief   Debug option, stack checks.
- * @details If enabled then a runtime stack check is performed.
- *
- * @note    The default is @p FALSE.
- * @note    The stack check is performed in a architecture/port dependent way.
- *          It may not be implemented or some ports.
- * @note    The default failure mode is to halt the system with the global
- *          @p panic_msg variable set to @p NULL.
- */
-#if !defined(CH_DBG_ENABLE_STACK_CHECK)
-#define CH_DBG_ENABLE_STACK_CHECK           TRUE
-#endif
-
-/**
- * @brief   Debug option, stacks initialization.
- * @details If enabled then the threads working area is filled with a byte
- *          value when a thread is created. This can be useful for the
- *          runtime measurement of the used stack.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_FILL_THREADS)
-#define CH_DBG_FILL_THREADS                 TRUE
-#endif
-
-/**
- * @brief   Debug option, threads profiling.
- * @details If enabled then a field is added to the @p thread_t structure that
- *          counts the system ticks occurred while executing the thread.
- *
- * @note    The default is @p FALSE.
- * @note    This debug option is not currently compatible with the
- *          tickless mode.
- */
-#if !defined(CH_DBG_THREADS_PROFILING)
-#define CH_DBG_THREADS_PROFILING            FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -567,130 +115,37 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   System structure extension.
- * @details User fields added to the end of the @p ch_system_t structure.
- */
-#define CH_CFG_SYSTEM_EXTRA_FIELDS                                          \
-  /* Add threads custom fields here.*/
+// common definitions in aos_chconf.h
 
-/**
- * @brief   System initialization hook.
- * @details User initialization code added to the @p chSysInit() function
- *          just before interrupts are enabled globally.
- */
-#define CH_CFG_SYSTEM_INIT_HOOK(tp) {                                       \
-  /* Add threads initialization code here.*/                                \
-}
-
-/**
- * @brief   Threads descriptor structure extension.
- * @details User fields added to the end of the @p thread_t structure.
- */
-#define CH_CFG_THREAD_EXTRA_FIELDS                                          \
-  /* Add threads custom fields here.*/
-
-/**
- * @brief   Threads initialization hook.
- * @details User initialization code added to the @p _thread_init() function.
- *
- * @note    It is invoked from within @p _thread_init() and implicitly from all
- *          the threads creation APIs.
- */
-#define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
-  /* Add threads initialization code here.*/                                \
-}
-
-/**
- * @brief   Threads finalization hook.
- * @details User finalization code added to the @p chThdExit() API.
- */
-#define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
-  /* Add threads finalization code here.*/                                  \
-}
-
-/**
- * @brief   Context switch hook.
- * @details This hook is invoked just before switching between threads.
- */
-#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
-  /* Context switch code here.*/                                            \
-}
-
-/**
- * @brief   ISR enter hook.
- */
-#define CH_CFG_IRQ_PROLOGUE_HOOK() {                                        \
-  /* IRQ prologue code here.*/                                              \
-}
-
-/**
- * @brief   ISR exit hook.
- */
-#define CH_CFG_IRQ_EPILOGUE_HOOK() {                                        \
-  /* IRQ epilogue code here.*/                                              \
-}
-
-/**
- * @brief   Idle thread enter hook.
- * @note    This hook is invoked within a critical zone, no OS functions
- *          should be invoked from here.
- * @note    This macro can be used to activate a power saving mode.
- */
-#define CH_CFG_IDLE_ENTER_HOOK() {                                          \
-  /* Idle-enter code here.*/                                                \
-}
+/** @} */
 
+/*===========================================================================*/
 /**
- * @brief   Idle thread leave hook.
- * @note    This hook is invoked within a critical zone, no OS functions
- *          should be invoked from here.
- * @note    This macro can be used to deactivate a power saving mode.
+ * @name Port-specific settings (override port settings defaulted in chcore.h).
+ * @{
  */
-#define CH_CFG_IDLE_LEAVE_HOOK() {                                          \
-  /* Idle-leave code here.*/                                                \
-}
+/*===========================================================================*/
 
 /**
- * @brief   Idle Loop hook.
- * @details This hook is continuously invoked by the idle thread loop.
+ * @brief   NVIC VTOR initialization offset.
+ * @details On initialization, the code at this address in the flash memory will be executed.
  */
-#define CH_CFG_IDLE_LOOP_HOOK() {                                           \
-  /* Idle loop code here.*/                                                 \
-}
+#define CORTEX_VTOR_INIT 0x00006000U
 
-/**
- * @brief   System tick event hook.
- * @details This hook is invoked in the system tick handler immediately
- *          after processing the virtual timers queue.
- */
-#define CH_CFG_SYSTEM_TICK_HOOK() {                                         \
-  /* System tick event code here.*/                                         \
-}
+/** @} */
 
+/*===========================================================================*/
 /**
- * @brief   System halt hook.
- * @details This hook is invoked in case to a system halting error before
- *          the system is halted.
+ * @name other
+ * @{
  */
-#define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
-  /* System halt code here.*/                                               \
-}
+/*===========================================================================*/
 
-/**
- * @brief   Trace hook.
- * @details This hook is invoked each time a new record is written in the
- *          trace buffer.
- */
-#define CH_CFG_TRACE_HOOK(tep) {                                            \
-  /* Trace code here.*/                                                     \
-}
+// common definitions in aos_chconf.h
 
 /** @} */
 
-/*===========================================================================*/
-/* Port-specific settings (override port settings defaulted in chcore.h).    */
-/*===========================================================================*/
+#include <aos_chconf.h>
 
 #endif  /* CHCONF_H */
 
diff --git a/modules/DiWheelDrive_1-1/halconf.h b/modules/DiWheelDrive_1-1/halconf.h
index 9b15e98..51586c1 100644
--- a/modules/DiWheelDrive_1-1/halconf.h
+++ b/modules/DiWheelDrive_1-1/halconf.h
@@ -1,31 +1,4 @@
 /*
- * AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
- * Copyright (C) 2016..2018  Thomas Schöpping et al.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @file    os/modules/DiWheelDrive/chconf.h
- * @brief   ChibiOS Configuration file for the DiWheelDrive v1.1 module.
- * @details Contains the application specific kernel settings.
- *
- * @addtogroup config
- * @details Kernel related settings and hooks.
- * @{
- */
-/*
 AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
 Copyright (C) 2016..2018  Thomas Schöpping et al.
 
@@ -57,151 +30,190 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef _HALCONF_H_
 #define _HALCONF_H_
 
+#define _CHIBIOS_HAL_CONF_
+#define _CHIBIOS_HAL_CONF_VER_6_0_
+
+#include "mcuconf.h"
+
 /**
  * @brief   Enables the PAL subsystem.
  */
 #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
-#define HAL_USE_PAL                 TRUE
+#define HAL_USE_PAL                         TRUE
 #endif
 
 /**
  * @brief   Enables the ADC subsystem.
  */
 #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
-#define HAL_USE_ADC                 FALSE
+#define HAL_USE_ADC                         FALSE
 #endif
 
 /**
  * @brief   Enables the CAN subsystem.
  */
 #if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
-#define HAL_USE_CAN                 TRUE
+#define HAL_USE_CAN                         TRUE
+#endif
+
+/**
+ * @brief   Enables the cryptographic subsystem.
+ */
+#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
+#define HAL_USE_CRY                         FALSE
 #endif
 
 /**
  * @brief   Enables the DAC subsystem.
  */
 #if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
-#define HAL_USE_DAC                 FALSE
+#define HAL_USE_DAC                         FALSE
 #endif
 
 /**
  * @brief   Enables the EXT subsystem.
  */
 #if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
-#define HAL_USE_EXT                 FALSE
+#define HAL_USE_EXT                         FALSE
 #endif
 
 /**
  * @brief   Enables the GPT subsystem.
  */
 #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT                 FALSE
+#define HAL_USE_GPT                         FALSE
 #endif
 
 /**
  * @brief   Enables the I2C subsystem.
  */
 #if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C                 TRUE
+#define HAL_USE_I2C                         TRUE
 #endif
 
 /**
  * @brief   Enables the I2S subsystem.
  */
 #if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
-#define HAL_USE_I2S                 FALSE
+#define HAL_USE_I2S                         FALSE
 #endif
 
 /**
  * @brief   Enables the ICU subsystem.
  */
 #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
-#define HAL_USE_ICU                 FALSE
+#define HAL_USE_ICU                         FALSE
 #endif
 
 /**
  * @brief   Enables the MAC subsystem.
  */
 #if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
-#define HAL_USE_MAC                 FALSE
+#define HAL_USE_MAC                         FALSE
 #endif
 
 /**
  * @brief   Enables the MMC_SPI subsystem.
  */
 #if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_MMC_SPI             FALSE
+#define HAL_USE_MMC_SPI                     FALSE
 #endif
 
 /**
  * @brief   Enables the PWM subsystem.
  */
 #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM                 TRUE
+#define HAL_USE_PWM                         TRUE
+#endif
+
+/**
+ * @brief   Enables the QSPI subsystem.
+ */
+#if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
+#define HAL_USE_QSPI                        FALSE
 #endif
 
 /**
  * @brief   Enables the RTC subsystem.
  */
 #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
-#define HAL_USE_RTC                 TRUE
+#define HAL_USE_RTC                         TRUE
 #endif
 
 /**
  * @brief   Enables the SDC subsystem.
  */
 #if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
-#define HAL_USE_SDC                 FALSE
+#define HAL_USE_SDC                         FALSE
 #endif
 
 /**
  * @brief   Enables the SERIAL subsystem.
  */
 #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL              TRUE
+#define HAL_USE_SERIAL                      TRUE
 #endif
 
 /**
  * @brief   Enables the SERIAL over USB subsystem.
  */
 #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL_USB          FALSE
+#define HAL_USE_SERIAL_USB                  FALSE
 #endif
 
 /**
  * @brief   Enables the SPI subsystem.
  */
 #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI                 TRUE
+#define HAL_USE_SPI                         TRUE
 #endif
 
 /**
  * @brief   Enables the UART subsystem.
  */
 #if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
-#define HAL_USE_UART                FALSE
+#define HAL_USE_UART                        FALSE
 #endif
 
 /**
  * @brief   Enables the USB subsystem.
  */
 #if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
-#define HAL_USE_USB                 FALSE
+#define HAL_USE_USB                         FALSE
 #endif
 
 /**
  * @brief   Enables the WDG subsystem.
  */
 #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
-#define HAL_USE_WDG                 FALSE
+#define HAL_USE_WDG                         FALSE
 #endif
 
 /**
  * @brief   Enables the QEI subsystem.
  */
 #if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
-#define HAL_USE_QEI                 TRUE
+#define HAL_USE_QEI                         TRUE
+#endif
+
+/*===========================================================================*/
+/* PAL driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
+#define PAL_USE_CALLBACKS                   TRUE
+#endif
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
+#define PAL_USE_WAIT                        FALSE
 #endif
 
 /*===========================================================================*/
@@ -213,7 +225,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
-#define ADC_USE_WAIT                FALSE
+#define ADC_USE_WAIT                        FALSE
 #endif
 
 /**
@@ -221,7 +233,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define ADC_USE_MUTUAL_EXCLUSION    FALSE
+#define ADC_USE_MUTUAL_EXCLUSION            FALSE
 #endif
 
 /*===========================================================================*/
@@ -232,7 +244,56 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Sleep mode related APIs inclusion switch.
  */
 #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
-#define CAN_USE_SLEEP_MODE          FALSE
+#define CAN_USE_SLEEP_MODE                  FALSE
+#endif
+
+/**
+ * @brief   Enforces the driver to use direct callbacks rather than OSAL events.
+ */
+#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
+#define CAN_ENFORCE_USE_CALLBACKS           FALSE
+#endif
+
+/*===========================================================================*/
+/* CRY driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables the SW fall-back of the cryptographic driver.
+ * @details When enabled, this option, activates a fall-back software
+ *          implementation for algorithms not supported by the underlying
+ *          hardware.
+ * @note    Fall-back implementations may not be present for all algorithms.
+ */
+#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
+#define HAL_CRY_USE_FALLBACK                FALSE
+#endif
+
+/**
+ * @brief   Makes the driver forcibly use the fall-back implementations.
+ */
+#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
+#define HAL_CRY_ENFORCE_FALLBACK            FALSE
+#endif
+
+/*===========================================================================*/
+/* DAC driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
+#define DAC_USE_WAIT                        TRUE
+#endif
+
+/**
+ * @brief   Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define DAC_USE_MUTUAL_EXCLUSION            TRUE
 #endif
 
 /*===========================================================================*/
@@ -243,7 +304,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Enables the mutual exclusion APIs on the I2C bus.
  */
 #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define I2C_USE_MUTUAL_EXCLUSION    TRUE
+#define I2C_USE_MUTUAL_EXCLUSION            TRUE
 #endif
 
 /*===========================================================================*/
@@ -251,17 +312,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /*===========================================================================*/
 
 /**
- * @brief   Enables an event sources for incoming packets.
+ * @brief   Enables the zero-copy API.
  */
 #if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
-#define MAC_USE_ZERO_COPY           FALSE
+#define MAC_USE_ZERO_COPY                   FALSE
 #endif
 
 /**
  * @brief   Enables an event sources for incoming packets.
  */
 #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
-#define MAC_USE_EVENTS              FALSE
+#define MAC_USE_EVENTS                      FALSE
 #endif
 
 /*===========================================================================*/
@@ -277,7 +338,27 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          use a DMA channel and heavily loads the CPU.
  */
 #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
-#define MMC_NICE_WAITING            FALSE
+#define MMC_NICE_WAITING                    FALSE
+#endif
+
+/*===========================================================================*/
+/* QSPI driver related settings.                                             */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(QSPI_USE_WAIT) || defined(__DOXYGEN__)
+#define QSPI_USE_WAIT                       TRUE
+#endif
+
+/**
+ * @brief   Enables the @p qspiAcquireBus() and @p qspiReleaseBus() APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(QSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define QSPI_USE_MUTUAL_EXCLUSION           TRUE
 #endif
 
 /*===========================================================================*/
@@ -289,7 +370,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Attempts are performed at 10mS intervals.
  */
 #if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
-#define SDC_INIT_RETRY              100
+#define SDC_INIT_RETRY                      100
 #endif
 
 /**
@@ -298,7 +379,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          at @p FALSE.
  */
 #if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
-#define SDC_MMC_SUPPORT             FALSE
+#define SDC_MMC_SUPPORT                     FALSE
 #endif
 
 /**
@@ -308,7 +389,21 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          lower priority, this may slow down the driver a bit however.
  */
 #if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
-#define SDC_NICE_WAITING            FALSE
+#define SDC_NICE_WAITING                    FALSE
+#endif
+
+/**
+ * @brief   OCR initialization constant for V20 cards.
+ */
+#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
+#define SDC_INIT_OCR_V20                    0x50FF8000U
+#endif
+
+/**
+ * @brief   OCR initialization constant for non-V20 cards.
+ */
+#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
+#define SDC_INIT_OCR                        0x80100000U
 #endif
 
 /*===========================================================================*/
@@ -321,7 +416,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          default configuration.
  */
 #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
-#define SERIAL_DEFAULT_BITRATE      115200
+#define SERIAL_DEFAULT_BITRATE              115200
 #endif
 
 /**
@@ -332,7 +427,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          buffers.
  */
 #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_BUFFERS_SIZE         16
+#define SERIAL_BUFFERS_SIZE                 16
 #endif
 
 /*===========================================================================*/
@@ -347,7 +442,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          buffers.
  */
 #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_SIZE     256
+#define SERIAL_USB_BUFFERS_SIZE             256
 #endif
 
 /**
@@ -355,7 +450,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    The default is 2 buffers.
  */
 #if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_NUMBER   2
+#define SERIAL_USB_BUFFERS_NUMBER           2
 #endif
 
 /*===========================================================================*/
@@ -367,15 +462,32 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
-#define SPI_USE_WAIT                TRUE
+#define SPI_USE_WAIT                        TRUE
+#endif
+
+/**
+ * @brief   Enables circular transfers APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
+#define SPI_USE_CIRCULAR                    FALSE
 #endif
 
+
 /**
  * @brief   Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define SPI_USE_MUTUAL_EXCLUSION    TRUE
+#define SPI_USE_MUTUAL_EXCLUSION            TRUE
+#endif
+
+/**
+ * @brief   Handling method for SPI CS line.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
+#define SPI_SELECT_MODE                     SPI_SELECT_MODE_PAD
 #endif
 
 /*===========================================================================*/
@@ -387,7 +499,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
-#define UART_USE_WAIT               FALSE
+#define UART_USE_WAIT                       FALSE
 #endif
 
 /**
@@ -395,7 +507,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define UART_USE_MUTUAL_EXCLUSION   FALSE
+#define UART_USE_MUTUAL_EXCLUSION           FALSE
 #endif
 
 /*===========================================================================*/
@@ -407,7 +519,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
-#define USB_USE_WAIT                FALSE
+#define USB_USE_WAIT                        FALSE
 #endif
 
 #endif /* _HALCONF_H_ */
diff --git a/modules/DiWheelDrive_1-1/mcuconf.h b/modules/DiWheelDrive_1-1/mcuconf.h
index 272beb0..4ebd59e 100644
--- a/modules/DiWheelDrive_1-1/mcuconf.h
+++ b/modules/DiWheelDrive_1-1/mcuconf.h
@@ -59,6 +59,21 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_PLS                           STM32_PLS_LEV0
 
 /*
+ * IRQ system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY            6
+#define STM32_IRQ_EXTI1_PRIORITY            6
+#define STM32_IRQ_EXTI2_PRIORITY            6
+#define STM32_IRQ_EXTI3_PRIORITY            6
+#define STM32_IRQ_EXTI4_PRIORITY            6
+#define STM32_IRQ_EXTI5_9_PRIORITY          6
+#define STM32_IRQ_EXTI10_15_PRIORITY        6
+#define STM32_IRQ_EXTI16_PRIORITY           6
+#define STM32_IRQ_EXTI17_PRIORITY           6
+#define STM32_IRQ_EXTI18_PRIORITY           6
+#define STM32_IRQ_EXTI19_PRIORITY           6
+
+/*
  * ADC driver system settings.
  */
 #define STM32_ADC_USE_ADC1                  FALSE
@@ -72,21 +87,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_CAN_CAN1_IRQ_PRIORITY         11
 
 /*
- * EXT driver system settings.
- */
-#define STM32_EXT_EXTI0_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI1_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI2_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI3_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI4_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI5_9_IRQ_PRIORITY      6
-#define STM32_EXT_EXTI10_15_IRQ_PRIORITY    6
-#define STM32_EXT_EXTI16_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI17_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI18_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI19_IRQ_PRIORITY       6
-
-/*
  * GPT driver system settings.
  */
 #define STM32_GPT_USE_TIM1                  FALSE
@@ -113,7 +113,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_I2C_I2C1_DMA_PRIORITY         3
 #define STM32_I2C_I2C2_DMA_PRIORITY         3
 #define STM32_I2C_DMA_ERROR_HOOK(i2cp)      osalSysHalt("DMA failure")
-#define STM32_I2C_USE_DMA                   FALSE
 
 /*
  * ICU driver system settings.
diff --git a/modules/DiWheelDrive_1-1/module.c b/modules/DiWheelDrive_1-1/module.c
index da71d77..d0001f6 100644
--- a/modules/DiWheelDrive_1-1/module.c
+++ b/modules/DiWheelDrive_1-1/module.c
@@ -18,26 +18,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "module.h"
 
+#include <amiroos.h>
+
 /*===========================================================================*/
 /**
  * @name Module specific functions
  * @{
  */
 /*===========================================================================*/
-#include <amiroos.h>
-
-/**
- * @brief   Interrupt service routine callback for I/O interrupt signals.
- *
- * @param   args      Channel on which the interrupt was encountered.
- */
-static void _modulePalIsrCallback(void *args) {
-  chSysLockFromISR();
-  chEvtBroadcastFlagsI(&aos.events.io, (1 << (*(uint16_t*)args)));
-  chSysUnlockFromISR();
-
-  return;
-}
 
 /** @} */
 
@@ -53,94 +41,6 @@ CANConfig moduleHalCanConfig = {
   /* btr  */ CAN_BTR_SJW(1) | CAN_BTR_TS2(2) | CAN_BTR_TS1(13) | CAN_BTR_BRP(1),
 };
 
-aos_interrupt_cfg_t moduleIntConfig[10] = {
-    /* channel  1 */ { // SYS_INT_N/SYS_SYNC_N: automatic interrupt on event
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_SYS_INT_N,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 1,
-    },
-    /* channel  2 */ { // SYS_WARMRST_N: automatic interrupt when activated
-      /* port     */ GPIOD,
-      /* pad      */ GPIOD_SYS_WARMRST_N,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_FALLING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 2,
-    },
-    /* channel  3 */ { // PATH_DCSTAT: must be enabled explicitely when charging is in progress to detect unexpected voltage drop
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_PATH_DCSTAT,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_FALLING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 3,
-    },
-    /* channel  5 */ { // COMPASS_DRDY: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_COMPASS_DRDY,
-      /* flags    */ 0,
-      /* mode     */ APAL2CH_EDGE(HMC5883L_LLD_INT_EDGE),
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 4,
-    },
-    /* channel  8 */ { // SYS_PD_N: automatic interrupt when activated
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_SYS_PD_N,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_FALLING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 5,
-    },
-    /* channel  9 */ { // SYS_REG_EN: automatic interrupt when activated
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_SYS_REG_EN,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_FALLING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 6,
-    },
-    /* channel 12 */ { // IR_INT: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_IR_INT,
-      /* flags    */ 0,
-      /* mode     */ APAL2CH_EDGE(VCNL4020_LLD_INT_EDGE),
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 7,
-    },
-    /* channel 13 */ { // GYRO_DRDY: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_GYRO_DRDY,
-      /* flags    */ 0,
-      /* mode     */ APAL2CH_EDGE(L3G4200D_LLD_INT_EDGE),
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 8,
-    },
-    /* channel 14 */ { // SYS_UART_UP: automatic interrupt on event
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_SYS_UART_UP,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 9,
-    },
-    /* channel 15 */ { // ACCEL_INT_N: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_ACCEL_INT_N,
-      /* flags    */ 0,
-      /* mode     */ APAL2CH_EDGE(LIS331DLH_LLD_INT_EDGE),
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 10,
-    },
-};
-
-aos_interrupt_driver_t moduleIntDriver = {
-  /* config     */ NULL,
-  /* interrupts */ 10,
-};
-
 I2CConfig moduleHalI2cCompassConfig = {
   /* I²C mode   */ OPMODE_I2C,
   /* frequency  */ 400000,
@@ -229,70 +129,213 @@ SPIConfig moduleHalSpiGyroscopeConfig = {
  */
 /*===========================================================================*/
 
-apalGpio_t moduleGpioLed = {
+/**
+ * @brief   LED output signal GPIO.
+ */
+static apalGpio_t _gpioLed = {
   /* port */ GPIOA,
   /* pad  */ GPIOA_LED,
 };
+apalControlGpio_t moduleGpioLed = {
+  /* GPIO */ &_gpioLed,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ LED_LLD_GPIO_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioPowerEn = {
-  /* port */GPIOB,
+/**
+ * @brief   POWER_EN output signal GPIO.
+ */
+static apalGpio_t _gpioPowerEn = {
+  /* port */ GPIOB,
   /* pad  */  GPIOB_POWER_EN,
 };
+apalControlGpio_t moduleGpioPowerEn = {
+  /* GPIO */ &_gpioPowerEn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioCompassDrdy = {
+/**
+ * @brief   COMPASS_DRDY output signal GPIO.
+ */
+static apalGpio_t _gpioCompassDrdy = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_COMPASS_DRDY,
 };
+apalControlGpio_t moduleGpioCompassDrdy = {
+  /* GPIO */ &_gpioCompassDrdy,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ (L3G4200D_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ L3G4200D_LLD_INT_EDGE,
+  },
+};
 
- apalGpio_t moduleGpioIrInt = {
+/**
+ * @brief   IR_INT input signal GPIO.
+ */
+static apalGpio_t _gpioIrInt = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_IR_INT,
 };
+apalControlGpio_t moduleGpioIrInt = {
+  /* GPIO */ &_gpioIrInt,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
+  },
+};
 
-apalGpio_t moduleGpioGyroDrdy = {
+/**
+ * @brief   GYRO_DRDY input signal GPIO.
+ */
+static apalGpio_t _gpioGyroDrdy = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_GYRO_DRDY,
 };
+apalControlGpio_t moduleGpioGyroDrdy = {
+  /* GPIO */ &_gpioGyroDrdy,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ (L3G4200D_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ L3G4200D_LLD_INT_EDGE,
+  },
+};
 
-apalGpio_t moduleGpioSysUartUp = {
+/**
+ * @brief   SYS_UART_UP bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysUartUp = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_SYS_UART_UP,
 };
+apalControlGpio_t moduleGpioSysUartUp = {
+  /* GPIO */ &_gpioSysUartUp,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioAccelInt = {
+/**
+ * @brief   ACCEL_INT input signal GPIO.
+ */
+static apalGpio_t _gpioAccelInt = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_ACCEL_INT_N,
 };
+apalControlGpio_t moduleGpioAccelInt = {
+  /* GPIO */ &_gpioAccelInt,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ (LIS331DLH_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ LIS331DLH_LLD_INT_EDGE,
+  },
+};
 
-apalGpio_t moduleGpioSysSync = {
+/**
+ * @brief   SYS_SNYC bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysSync = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_INT_N,
 };
+apalControlGpio_t moduleGpioSysSync = {
+  /* GPIO */ &_gpioSysSync,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioPathDcStat = {
+/**
+ * @brief   PATH_DCSTAT input signal GPIO.
+ */
+static apalGpio_t _gpioPathDcStat = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_PATH_DCSTAT,
 };
+apalControlGpio_t moduleGpioPathDcStat = {
+  /* GPIO */ &_gpioPathDcStat,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ LTC4412_LLD_STAT_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioPathDcEn = {
+/**
+ * @brief   PATH_DCEN output signal GPIO.
+ */
+static apalGpio_t _gpioPathDcEn = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_PATH_DCEN,
 };
+apalControlGpio_t moduleGpioPathDcEn = {
+  /* GPIO */ &_gpioPathDcEn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ LTC4412_LLD_CTRL_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioSysPd = {
+/**
+ * @brief   SYS_PD bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysPd = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_PD_N,
 };
+apalControlGpio_t moduleGpioSysPd = {
+  /* GPIO */ &_gpioSysPd,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioSysRegEn = {
+/**
+ * @brief   SYS_REG_EN input signal GPIO.
+ */
+static apalGpio_t _gpioSysRegEn = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_REG_EN,
 };
+apalControlGpio_t moduleGpioSysRegEn = {
+  /* GPIO */ &_gpioSysRegEn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioSysWarmrst = {
+/**
+ * @brief   SYS_WARMRST bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysWarmrst = {
   /* port */ GPIOD,
   /* pad  */ GPIOD_SYS_WARMRST_N,
 };
+apalControlGpio_t moduleGpioSysWarmrst = {
+  /* GPIO */ &_gpioSysWarmrst,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
 /** @} */
 
@@ -316,33 +359,6 @@ const char* moduleShellPrompt = "DiWheelDrive";
  */
 /*===========================================================================*/
 
-apalControlGpio_t moduleSsspGpioPd = {
-  /* GPIO */ &moduleGpioSysPd,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
-apalControlGpio_t moduleSsspGpioSync = {
-  /* GPIO */ &moduleGpioSysSync,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
-apalControlGpio_t moduleSsspGpioUp = {
-  /* GPIO */ &moduleGpioSysUartUp,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
 /** @} */
 
 /*===========================================================================*/
@@ -353,14 +369,7 @@ apalControlGpio_t moduleSsspGpioUp = {
 /*===========================================================================*/
 
 A3906Driver moduleLldMotors = {
-  /* power enable GPIO  */ {
-    /* GPIO */& moduleGpioPowerEn,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_HIGH,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
+  /* power enable GPIO  */ &moduleGpioPowerEn,
 };
 
 AT24C01BNDriver moduleLldEeprom = {
@@ -384,14 +393,7 @@ L3G4200DDriver moduleLldGyroscope = {
 };
 
 LEDDriver moduleLldStatusLed = {
-  /* LED enable Gpio */ {
-    /* GPIO       */ &moduleGpioLed,
-    /* GPIO meta  */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
+  /* LED enable Gpio */ &moduleGpioLed,
 };
 
 LIS331DLHDriver moduleLldAccelerometer = {
@@ -399,22 +401,8 @@ LIS331DLHDriver moduleLldAccelerometer = {
 };
 
 LTC4412Driver moduleLldPowerPathController = {
-  /* Control GPIO */ {
-    /* GPIO       */ &moduleGpioPathDcEn,
-    /* GPIO meta  */ {
-      /* active state */ APAL_GPIO_ACTIVE_HIGH,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
-  /* Status GPIO */ {
-    /* GPIO       */ &moduleGpioPathDcStat,
-    /* GPIO meta  */ {
-      /* active state */ APAL_GPIO_ACTIVE_HIGH,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_INPUT,
-    },
-  },
+  /* Control GPIO */ &moduleGpioPathDcEn,
+  /* Status GPIO  */ &moduleGpioPathDcStat,
 };
 
 PCA9544ADriver moduleLldI2cMultiplexer = {
@@ -423,14 +411,7 @@ PCA9544ADriver moduleLldI2cMultiplexer = {
 };
 
 TPS62113Driver moduleLldStepDownConverterVdrive = {
-  /* Power enable Gpio */ {
-    /* GPIO       */ &moduleGpioPowerEn,
-    /* GPIO meta  */ {
-      /* 'power on' state */ APAL_GPIO_ACTIVE_HIGH,
-      /* edge             */ APAL_GPIO_EDGE_NONE,
-      /* direction        */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
+  /* Power enable Gpio */ &moduleGpioPowerEn,
 };
 
 VCNL4020Driver moduleLldProximity = {
@@ -474,7 +455,7 @@ static ut_a3906data_t _utA3906Data = {
     /* increment per revolution */ MODULE_HAL_QEI_INCREMENTS_PER_REVOLUTION,
   },
   /* Wheel diameter   */ 0.05571f,
-  /* timeout          */ 10* MICROSECONDS_PER_SECOND,
+  /* timeout          */ 10 * MICROSECONDS_PER_SECOND,
 };
 aos_unittest_t moduleUtAlldA3906  = {
   /* name           */ "A3906",
@@ -517,15 +498,13 @@ static int _utShellCmdCb_AlldHmc5883l(BaseSequentialStream* stream, int argc, ch
 {
   (void)argc;
   (void)argv;
-  aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_COMPASSDRDY);
   aosUtRun(stream, &moduleUtAlldHmc5883l, NULL);
-  aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_COMPASSDRDY);
   return AOS_OK;
 }
 static ut_hmc5883ldata_t _utHmc5883lData = {
   /* HMC driver   */ &moduleLldCompass,
   /* event source */ &aos.events.io,
-  /* event flags  */ (1 << MODULE_GPIO_INT_COMPASSDRDY),
+  /* event flags  */ MODULE_OS_IOEVENTFLAGS_COMPASSDRDY,
   /* timeout      */ MICROSECONDS_PER_SECOND,
 };
 aos_unittest_t moduleUtAlldHmc5883l = {
@@ -571,18 +550,16 @@ static int _utShellCmdCb_AlldL3g4200d(BaseSequentialStream* stream, int argc, ch
 {
   (void)argc;
   (void)argv;
-  aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_GYRODRDY);
   spiStart(((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->l3gd->spid, ((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->spiconf);
   aosUtRun(stream, &moduleUtAlldL3g4200d, NULL);
   spiStop(((ut_l3g4200ddata_t*)moduleUtAlldL3g4200d.data)->l3gd->spid);
-  aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_GYRODRDY);
   return AOS_OK;
 }
 static ut_l3g4200ddata_t _utL3g4200dData = {
   /* driver            */ &moduleLldGyroscope,
   /* SPI configuration */ &moduleHalSpiGyroscopeConfig,
   /* event source */ &aos.events.io,
-  /* event flags  */ (1 << MODULE_GPIO_INT_GYRODRDY),
+  /* event flags  */ MODULE_OS_IOEVENTFLAGS_GYRODRDY,
 };
 aos_unittest_t moduleUtAlldL3g4200d = {
   /* name           */ "L3G4200D",
@@ -621,18 +598,16 @@ static int _utShellCmdCb_AlldLis331dlh(BaseSequentialStream* stream, int argc, c
 {
   (void)argc;
   (void)argv;
-  aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_ACCELINT);
   spiStart(((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->lisd->spid, ((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->spiconf);
   aosUtRun(stream, &moduleUtAlldLis331dlh, NULL);
   spiStop(((ut_lis331dlhdata_t*)moduleUtAlldLis331dlh.data)->lisd->spid);
-  aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_ACCELINT);
   return AOS_OK;
 }
 static ut_lis331dlhdata_t _utLis331dlhData = {
   /* driver            */ &moduleLldAccelerometer,
   /* SPI configuration */ &moduleHalSpiAccelerometerConfig,
   /* event source */ &aos.events.io,
-  /* event flags  */ (1 << MODULE_GPIO_INT_ACCELINT),
+  /* event flags  */ MODULE_OS_IOEVENTFLAGS_ACCELINT,
 };
 aos_unittest_t moduleUtAlldLis331dlh = {
   /* name           */ "LIS331DLH",
@@ -748,11 +723,10 @@ static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, ch
     _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
     pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
     _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
-    aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_IRINT);
     switch (sensor) {
       case FL:
         pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
-        aosUtRun(stream, &moduleUtAlldVcnl4020, "front left snesor");
+        aosUtRun(stream, &moduleUtAlldVcnl4020, "front left sensor");
         break;
       case FR:
         pca9544a_lld_setchannel(&moduleLldI2cMultiplexer, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
@@ -769,7 +743,6 @@ static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, ch
       default:
         break;
     }
-    aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT);
     return AOS_OK;
   }
   // print help
@@ -789,7 +762,7 @@ static ut_vcnl4020data_t _utVcnl4020Data = {
   /* driver       */ &moduleLldProximity,
   /* timeout      */ MICROSECONDS_PER_SECOND,
   /* event source */ &aos.events.io,
-  /* event flags  */ (1 << MODULE_GPIO_INT_IRINT),
+  /* event flags  */ MODULE_OS_IOEVENTFLAGS_IRINT,
 };
 aos_unittest_t moduleUtAlldVcnl4020 = {
   /* name           */ "VCNL4020",
diff --git a/modules/DiWheelDrive_1-1/module.h b/modules/DiWheelDrive_1-1/module.h
index 85d871a..5c73b77 100644
--- a/modules/DiWheelDrive_1-1/module.h
+++ b/modules/DiWheelDrive_1-1/module.h
@@ -36,7 +36,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /*===========================================================================*/
 #include <hal.h>
 #include <hal_qei.h>
-#include <aos_interrupts.h>
 
 /**
  * @brief   CAN driver to use.
@@ -49,17 +48,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 extern CANConfig moduleHalCanConfig;
 
 /**
- * @brief   Interrupt driver (PAL).
- */
-
-extern aos_interrupt_driver_t moduleIntDriver;
-
-/**
- * @brief   Interrupt driver config.
- */
-extern aos_interrupt_cfg_t moduleIntConfig[10];
-
-/**
  * @brief   I2C driver to access the compass.
  */
 #define MODULE_HAL_I2C_COMPASS                  I2CD1
@@ -92,22 +80,22 @@ extern PWMConfig moduleHalPwmDriveConfig;
 /**
  * @brief   Drive PWM channel for the left wheel forward direction.
  */
-#define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_FORWARD     0
+#define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_FORWARD     ((apalPWMchannel_t)0)
 
 /**
  * @brief   Drive PWM channel for the left wheel backward direction.
  */
-#define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_BACKWARD    1
+#define MODULE_HAL_PWM_DRIVE_CHANNEL_LEFT_BACKWARD    ((apalPWMchannel_t)1)
 
 /**
  * @brief   Drive PWM channel for the right wheel forward direction.
  */
-#define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_FORWARD    2
+#define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_FORWARD    ((apalPWMchannel_t)2)
 
 /**
  * @brief   Drive PWM channel for the right wheel backward direction.
  */
-#define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_BACKWARD   3
+#define MODULE_HAL_PWM_DRIVE_CHANNEL_RIGHT_BACKWARD   ((apalPWMchannel_t)3)
 
 /**
  * @brief   Quadrature encooder for the left wheel.
@@ -171,119 +159,69 @@ extern SPIConfig moduleHalSpiGyroscopeConfig;
 #include <amiro-lld.h>
 
 /**
- * @brief   Interrupt channel for the SYS_SYNC signal.
- */
-#define MODULE_GPIO_INT_SYSSYNC          ((uint8_t)1)
-
-/**
- * @brief   Interrupt channel for the SYS_WARMRST signal.
- */
-#define MODULE_GPIO_INT_SYSWARMRST       ((uint8_t)2)
-
-/**
- * @brief   Interrupt channel for the PATH_DCSTAT signal.
- */
-#define MODULE_GPIO_INT_PATHDCSTAT       ((uint8_t)3)
-
-/**
- * @brief   Interrupt channel for the COMPASS_DRDY signal.
- */
-#define MODULE_GPIO_INT_COMPASSDRDY      ((uint8_t)4)
-
-/**
- * @brief   Interrupt channel for the SYS_PD signal.
- */
-#define MODULE_GPIO_INT_SYSPD            ((uint8_t)5)
-
-/**
- * @brief   Interrupt channel for the SYS_REG_EN signal.
- */
-#define MODULE_GPIO_INT_SYSREGEN         ((uint8_t)6)
-
-/**
- * @brief   Interrupt channel for the IR_INT signal.
- */
-#define MODULE_GPIO_INT_IRINT            ((uint8_t)7)
-
-/**
- * @brief   Interrupt channel for the GYRO_DRDY signal.
- */
-#define MODULE_GPIO_INT_GYRODRDY         ((uint8_t)8)
-
-/**
- * @brief   Interrupt channel for the SYS_UART_UP signal.
- */
-#define MODULE_GPIO_INT_SYSUARTUP        ((uint8_t)9)
-
-/**
- * @brief   Interrupt channel for the ACCEL_INT signal.
- */
-#define MODULE_GPIO_INT_ACCELINT         ((uint8_t)10)
-
-/**
  * @brief   LED output signal GPIO.
  */
-extern apalGpio_t moduleGpioLed;
+extern apalControlGpio_t moduleGpioLed;
 
 /**
  * @brief   POWER_EN output signal GPIO.
  */
-extern apalGpio_t moduleGpioPowerEn;
+extern apalControlGpio_t moduleGpioPowerEn;
 
 /**
  * @brief   COMPASS_DRDY input signal GPIO.
  */
-extern apalGpio_t moduleGpioCompassDrdy;
+extern apalControlGpio_t moduleGpioCompassDrdy;
 
 /**
  * @brief   IR_INT input signal GPIO.
  */
-extern apalGpio_t moduleGpioIrInt;
+extern apalControlGpio_t moduleGpioIrInt;
 
 /**
  * @brief   GYRO_DRDY input signal GPIO.
  */
-extern apalGpio_t moduleGpioGyroDrdy;
+extern apalControlGpio_t moduleGpioGyroDrdy;
 
 /**
  * @brief   SYS_UART_UP bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysUartUp;
+extern apalControlGpio_t moduleGpioSysUartUp;
 
 /**
  * @brief   ACCEL_INT input signal GPIO.
  */
-extern apalGpio_t moduleGpioAccelInt;
+extern apalControlGpio_t moduleGpioAccelInt;
 
 /**
  * @brief   SYS_SNYC bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysSync;
+extern apalControlGpio_t moduleGpioSysSync;
 
 /**
  * @brief   PATH_DCSTAT input signal GPIO.
  */
-extern apalGpio_t moduleGpioPathDcStat;
+extern apalControlGpio_t moduleGpioPathDcStat;
 
 /**
  * @brief   PATH_DCEN output signal GPIO.
  */
-extern apalGpio_t moduleGpioPathDcEn;
+extern apalControlGpio_t moduleGpioPathDcEn;
 
 /**
  * @brief   SYS_PD bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysPd;
+extern apalControlGpio_t moduleGpioSysPd;
 
 /**
  * @brief   SYS_REG_EN input signal GPIO.
  */
-extern apalGpio_t moduleGpioSysRegEn;
+extern apalControlGpio_t moduleGpioSysRegEn;
 
 /**
  * @brief   SYS_WARMRST bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysWarmrst;
+extern apalControlGpio_t moduleGpioSysWarmrst;
 
 /** @} */
 
@@ -297,52 +235,52 @@ extern apalGpio_t moduleGpioSysWarmrst;
 /**
  * @brief   Event flag to be set on a SYS_SYNC interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)(1 << MODULE_GPIO_INT_SYSSYNC))
+#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)1 << GPIOC_SYS_INT_N)
 
 /**
  * @brief   Event flag to be set on a SYS_WARMRST interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST       ((eventflags_t)(1 << MODULE_GPIO_INT_SYSWARMRST))
+#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST       ((eventflags_t)1 << GPIOD_SYS_WARMRST_N)
 
 /**
  * @brief   Event flag to be set on a PATH_DCSTAT interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_PATHDCSTAT       ((eventflags_t)(1 << MODULE_GPIO_INT_PATHDCSTAT))
+#define MODULE_OS_IOEVENTFLAGS_PATHDCSTAT       ((eventflags_t)1 << GPIOC_PATH_DCEN)
 
 /**
  * @brief   Event flag to be set on a COMPASS_DRDY interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_COMPASSDRDY      ((eventflags_t)(1 << MODULE_GPIO_INT_COMPASSDRDY))
+#define MODULE_OS_IOEVENTFLAGS_COMPASSDRDY      ((eventflags_t)1 << GPIOB_COMPASS_DRDY)
 
 /**
  * @brief   Event flag to be set on a SYS_PD interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)(1 << MODULE_GPIO_INT_SYSPD))
+#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)1 << GPIOC_SYS_PD_N)
 
 /**
  * @brief   Event flag to be set on a SYS_REG_EN interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSREGEN         ((eventflags_t)(1 << MODULE_GPIO_INT_SYSREGEN))
+#define MODULE_OS_IOEVENTFLAGS_SYSREGEN         ((eventflags_t)1 << GPIOC_SYS_REG_EN)
 
 /**
  * @brief   Event flag to be set on a IR_INT interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_IRINT            ((eventflags_t)(1 << MODULE_GPIO_INT_IRINT))
+#define MODULE_OS_IOEVENTFLAGS_IRINT            ((eventflags_t)1 << GPIOB_IR_INT)
 
 /**
  * @brief   Event flag to be set on a GYRO_DRDY interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_GYRODRDY         ((eventflags_t)(1 << MODULE_GPIO_INT_GYRODRDY))
+#define MODULE_OS_IOEVENTFLAGS_GYRODRDY         ((eventflags_t)1 << GPIOB_GYRO_DRDY)
 
 /**
  * @brief   Event flag to be set on a SYS_UART_UP interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP        ((eventflags_t)(1 << MODULE_GPIO_INT_SYSUARTUP))
+#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP        ((eventflags_t)1 << GPIOB_SYS_UART_UP)
 
 /**
  * @brief   Event flag to be set on a ACCEL_INT interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_ACCELINT         ((eventflags_t)(1 << MODULE_GPIO_INT_ACCELINT))
+#define MODULE_OS_IOEVENTFLAGS_ACCELINT         ((eventflags_t)1 << GPIOB_ACCEL_INT_N)
 
 #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
 /**
@@ -359,6 +297,34 @@ extern const char* moduleShellPrompt;
 }
 
 /**
+ * @brief   Interrupt initialization macro.
+ * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
+ */
+#define MODULE_INIT_INTERRUPTS() {                                            \
+  /* COMPASS_DRDY */                                                          \
+  palSetPadCallback(moduleGpioCompassDrdy.gpio->port, moduleGpioCompassDrdy.gpio->pad, _intCallback, &moduleGpioCompassDrdy.gpio->pad); \
+  palEnablePadEvent(moduleGpioCompassDrdy.gpio->port, moduleGpioCompassDrdy.gpio->pad, APAL2CH_EDGE(moduleGpioCompassDrdy.meta.edge));  \
+  /* IR_INT */                                                                \
+  palSetPadCallback(moduleGpioIrInt.gpio->port, moduleGpioIrInt.gpio->pad, _intCallback, &moduleGpioIrInt.gpio->pad); \
+  palEnablePadEvent(moduleGpioIrInt.gpio->port, moduleGpioIrInt.gpio->pad, APAL2CH_EDGE(moduleGpioIrInt.meta.edge));  \
+  /* GYRO_DRDY */                                                             \
+  palSetPadCallback(moduleGpioGyroDrdy.gpio->port, moduleGpioGyroDrdy.gpio->pad, _intCallback, &moduleGpioGyroDrdy.gpio->pad);  \
+  palEnablePadEvent(moduleGpioGyroDrdy.gpio->port, moduleGpioGyroDrdy.gpio->pad, APAL2CH_EDGE(moduleGpioGyroDrdy.meta.edge));   \
+  /* ACCEL_INT */                                                             \
+  palSetPadCallback(moduleGpioAccelInt.gpio->port, moduleGpioAccelInt.gpio->pad, _intCallback, &moduleGpioAccelInt.gpio->pad);  \
+  palEnablePadEvent(moduleGpioAccelInt.gpio->port, moduleGpioAccelInt.gpio->pad, APAL2CH_EDGE(moduleGpioAccelInt.meta.edge));   \
+  /* PATH_DCSTAT */                                                           \
+  palSetPadCallback(moduleGpioPathDcStat.gpio->port, moduleGpioPathDcStat.gpio->pad, _intCallback, &moduleGpioPathDcStat.gpio->pad);  \
+  palEnablePadEvent(moduleGpioPathDcStat.gpio->port, moduleGpioPathDcStat.gpio->pad, APAL2CH_EDGE(moduleGpioPathDcStat.meta.edge));   \
+  /* SYS_REG_EN */                                                            \
+  palSetPadCallback(moduleGpioSysRegEn.gpio->port, moduleGpioSysRegEn.gpio->pad, _intCallback, &moduleGpioSysRegEn.gpio->pad);  \
+  palEnablePadEvent(moduleGpioSysRegEn.gpio->port, moduleGpioSysRegEn.gpio->pad, APAL2CH_EDGE(moduleGpioSysRegEn.meta.edge));   \
+  /* SYS_WARMRST */                                                           \
+  palSetPadCallback(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, _intCallback, &moduleGpioSysWarmrst.gpio->pad);  \
+  palEnablePadEvent(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, APAL2CH_EDGE(moduleGpioSysWarmrst.meta.edge));   \
+}
+
+/**
  * @brief   Unit test initialization hook.
  */
 #define MODULE_INIT_TESTS() {                                                 \
@@ -431,17 +397,17 @@ extern const char* moduleShellPrompt;
 /**
  * @brief   PD signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioPd;
+#define moduleSsspGpioPd                        moduleGpioSysPd
 
 /**
  * @brief   SYNC signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioSync;
+#define moduleSsspGpioSync                      moduleGpioSysSync
 
 /**
  * @brief   UP signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioUp;
+#define moduleSsspGpioUp                        moduleGpioSysUartUp
 
 /**
  * @brief   Event flags for PD signal events.
diff --git a/modules/LightRing_1-0/alldconf.h b/modules/LightRing_1-0/alldconf.h
index d3445af..57af662 100644
--- a/modules/LightRing_1-0/alldconf.h
+++ b/modules/LightRing_1-0/alldconf.h
@@ -27,6 +27,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define AMIRO_LLD_CFG_VERSION_MINOR         0
 
 /**
+ * @brief   Width of the apalTime_t data type.
+ *
+ * @details Possible values are 8, 16, 32, and 64 bits.
+ *          By definition time is represented ot a microsecond precision.
+ */
+#define AMIROLLD_CFG_TIME_SIZE          32
+
+/**
  * @brief   Enable flag for the AT24C01BN-SH-B EEPROM.
  */
 #define AMIROLLD_CFG_USE_AT24C01BN
diff --git a/modules/LightRing_1-0/chconf.h b/modules/LightRing_1-0/chconf.h
index 68fe112..c8db701 100644
--- a/modules/LightRing_1-0/chconf.h
+++ b/modules/LightRing_1-0/chconf.h
@@ -32,6 +32,8 @@
 #define _CHIBIOS_RT_CONF_
 #define _CHIBIOS_RT_CONF_VER_5_1_
 
+#include <aosconf.h>
+
 /*===========================================================================*/
 /**
  * @name System timers settings
@@ -47,42 +49,7 @@
 #define CH_CFG_ST_RESOLUTION                16
 #endif
 
-/**
- * @brief   System tick frequency.
- * @details Frequency of the system timer that drives the system ticks. This
- *          setting also defines the system tick time unit.
- */
-#if !defined(CH_CFG_ST_FREQUENCY)
-#define CH_CFG_ST_FREQUENCY                 1000000UL
-#endif
-
-/**
- * @brief   Time intervals data size.
- * @note    Allowed values are 16, 32 or 64 bits.
- */
-#if !defined(CH_CFG_INTERVALS_SIZE)
-#define CH_CFG_INTERVALS_SIZE               64
-#endif
-
-/**
- * @brief   Time types data size.
- * @note    Allowed values are 16 or 32 bits.
- */
-#if !defined(CH_CFG_TIME_TYPES_SIZE)
-#define CH_CFG_TIME_TYPES_SIZE              32
-#endif
-
-/**
- * @brief   Time delta constant for the tick-less mode.
- * @note    If this value is zero then the system uses the classic
- *          periodic tick. This value represents the minimum number
- *          of ticks that is safe to specify in a timeout directive.
- *          The value one is not valid, timeouts are rounded up to
- *          this value.
- */
-#if !defined(CH_CFG_ST_TIMEDELTA)
-#define CH_CFG_ST_TIMEDELTA                 10
-#endif
+// more common definition in aos_chconf.h
 
 /** @} */
 
@@ -93,47 +60,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Round robin interval.
- * @details This constant is the number of system ticks allowed for the
- *          threads before preemption occurs. Setting this value to zero
- *          disables the preemption for threads with equal priority and the
- *          round robin becomes cooperative. Note that higher priority
- *          threads can still preempt, the kernel is always preemptive.
- * @note    Disabling the round robin preemption makes the kernel more compact
- *          and generally faster.
- * @note    The round robin preemption is not supported in tickless mode and
- *          must be set to zero in that case.
- */
-#if !defined(CH_CFG_TIME_QUANTUM)
-#define CH_CFG_TIME_QUANTUM                 0
-#endif
-
-/**
- * @brief   Managed RAM size.
- * @details Size of the RAM area to be managed by the OS. If set to zero
- *          then the whole available RAM is used. The core memory is made
- *          available to the heap allocator and/or can be used directly through
- *          the simplified core memory allocator.
- *
- * @note    In order to let the OS manage the whole RAM the linker script must
- *          provide the @p __heap_base__ and @p __heap_end__ symbols.
- * @note    Requires @p CH_CFG_USE_MEMCORE.
- */
-#if !defined(CH_CFG_MEMCORE_SIZE)
-#define CH_CFG_MEMCORE_SIZE                 0
-#endif
-
-/**
- * @brief   Idle thread automatic spawn suppression.
- * @details When this option is activated the function @p chSysInit()
- *          does not spawn the idle thread. The application @p main()
- *          function becomes the idle thread and must implement an
- *          infinite loop.
- */
-#if !defined(CH_CFG_NO_IDLE_THREAD)
-#define CH_CFG_NO_IDLE_THREAD               FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -144,17 +71,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   OS optimization.
- * @details If enabled then time efficient rather than space efficient code
- *          is used when two possible implementations exist.
- *
- * @note    This is not related to the compiler optimization options.
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_OPTIMIZE_SPEED)
-#define CH_CFG_OPTIMIZE_SPEED               TRUE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -165,224 +82,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Time Measurement APIs.
- * @details If enabled then the time measurement APIs are included in
- *          the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_TM)
-#define CH_CFG_USE_TM                       FALSE
-#endif
-
-/**
- * @brief   Threads registry APIs.
- * @details If enabled then the registry APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_REGISTRY)
-#define CH_CFG_USE_REGISTRY                 FALSE
-#endif
-
-/**
- * @brief   Threads synchronization APIs.
- * @details If enabled then the @p chThdWait() function is included in
- *          the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_WAITEXIT)
-#define CH_CFG_USE_WAITEXIT                 TRUE
-#endif
-
-/**
- * @brief   Semaphores APIs.
- * @details If enabled then the Semaphores APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_SEMAPHORES)
-#define CH_CFG_USE_SEMAPHORES               FALSE
-#endif
-
-/**
- * @brief   Semaphores queuing mode.
- * @details If enabled then the threads are enqueued on semaphores by
- *          priority rather than in FIFO order.
- *
- * @note    The default is @p FALSE. Enable this if you have special
- *          requirements.
- * @note    Requires @p CH_CFG_USE_SEMAPHORES.
- */
-#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
-#define CH_CFG_USE_SEMAPHORES_PRIORITY      FALSE
-#endif
-
-/**
- * @brief   Mutexes APIs.
- * @details If enabled then the mutexes APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MUTEXES)
-#define CH_CFG_USE_MUTEXES                  TRUE
-#endif
-
-/**
- * @brief   Enables recursive behavior on mutexes.
- * @note    Recursive mutexes are heavier and have an increased
- *          memory footprint.
- *
- * @note    The default is @p FALSE.
- * @note    Requires @p CH_CFG_USE_MUTEXES.
- */
-#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
-#define CH_CFG_USE_MUTEXES_RECURSIVE        FALSE
-#endif
-
-/**
- * @brief   Conditional Variables APIs.
- * @details If enabled then the conditional variables APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_MUTEXES.
- */
-#if !defined(CH_CFG_USE_CONDVARS)
-#define CH_CFG_USE_CONDVARS                 FALSE
-#endif
-
-/**
- * @brief   Conditional Variables APIs with timeout.
- * @details If enabled then the conditional variables APIs with timeout
- *          specification are included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_CONDVARS.
- */
-#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
-#define CH_CFG_USE_CONDVARS_TIMEOUT         FALSE
-#endif
-
-/**
- * @brief   Events Flags APIs.
- * @details If enabled then the event flags APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_EVENTS)
-#define CH_CFG_USE_EVENTS                   TRUE
-#endif
-
-/**
- * @brief   Events Flags APIs with timeout.
- * @details If enabled then the events APIs with timeout specification
- *          are included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_EVENTS.
- */
-#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
-#define CH_CFG_USE_EVENTS_TIMEOUT           TRUE
-#endif
-
-/**
- * @brief   Synchronous Messages APIs.
- * @details If enabled then the synchronous messages APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MESSAGES)
-#define CH_CFG_USE_MESSAGES                 FALSE
-#endif
-
-/**
- * @brief   Synchronous Messages queuing mode.
- * @details If enabled then messages are served by priority rather than in
- *          FIFO order.
- *
- * @note    The default is @p FALSE. Enable this if you have special
- *          requirements.
- * @note    Requires @p CH_CFG_USE_MESSAGES.
- */
-#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
-#define CH_CFG_USE_MESSAGES_PRIORITY        FALSE
-#endif
-
-/**
- * @brief   Mailboxes APIs.
- * @details If enabled then the asynchronous messages (mailboxes) APIs are
- *          included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_SEMAPHORES.
- */
-#if !defined(CH_CFG_USE_MAILBOXES)
-#define CH_CFG_USE_MAILBOXES                FALSE
-#endif
-
-/**
- * @brief   Core Memory Manager APIs.
- * @details If enabled then the core memory manager APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MEMCORE)
-#define CH_CFG_USE_MEMCORE                  FALSE
-#endif
-
-/**
- * @brief   Heap Allocator APIs.
- * @details If enabled then the memory heap allocator APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
- *          @p CH_CFG_USE_SEMAPHORES.
- * @note    Mutexes are recommended.
- */
-#if !defined(CH_CFG_USE_HEAP)
-#define CH_CFG_USE_HEAP                     FALSE
-#endif
-
-/**
- * @brief   Memory Pools Allocator APIs.
- * @details If enabled then the memory pools allocator APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MEMPOOLS)
-#define CH_CFG_USE_MEMPOOLS                 FALSE
-#endif
-
-/**
- * @brief  Objects FIFOs APIs.
- * @details If enabled then the objects FIFOs APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_OBJ_FIFOS)
-#define CH_CFG_USE_OBJ_FIFOS                FALSE
-#endif
-
-/**
- * @brief   Dynamic Threads APIs.
- * @details If enabled then the dynamic threads creation APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_WAITEXIT.
- * @note    Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
- */
-#if !defined(CH_CFG_USE_DYNAMIC)
-#define CH_CFG_USE_DYNAMIC                  FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -393,60 +93,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Objects Factory APIs.
- * @details If enabled then the objects factory APIs are included in the
- *          kernel.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_CFG_USE_FACTORY)
-#define CH_CFG_USE_FACTORY                  FALSE
-#endif
-
-/**
- * @brief   Maximum length for object names.
- * @details If the specified length is zero then the name is stored by
- *          pointer but this could have unintended side effects.
- */
-#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
-#define CH_CFG_FACTORY_MAX_NAMES_LENGTH     8
-#endif
-
-/**
- * @brief   Enables the registry of generic objects.
- */
-#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
-#define CH_CFG_FACTORY_OBJECTS_REGISTRY     TRUE
-#endif
-
-/**
- * @brief   Enables factory for generic buffers.
- */
-#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
-#define CH_CFG_FACTORY_GENERIC_BUFFERS      TRUE
-#endif
-
-/**
- * @brief   Enables factory for semaphores.
- */
-#if !defined(CH_CFG_FACTORY_SEMAPHORES)
-#define CH_CFG_FACTORY_SEMAPHORES           TRUE
-#endif
-
-/**
- * @brief   Enables factory for mailboxes.
- */
-#if !defined(CH_CFG_FACTORY_MAILBOXES)
-#define CH_CFG_FACTORY_MAILBOXES            TRUE
-#endif
-
-/**
- * @brief   Enables factory for objects FIFOs.
- */
-#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
-#define CH_CFG_FACTORY_OBJ_FIFOS            TRUE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -457,106 +104,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Debug option, kernel statistics.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_STATISTICS)
-#define CH_DBG_STATISTICS                   FALSE
-#endif
-
-/**
- * @brief   Debug option, system state check.
- * @details If enabled the correct call protocol for system APIs is checked
- *          at runtime.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
-#define CH_DBG_SYSTEM_STATE_CHECK           FALSE
-#endif
-
-/**
- * @brief   Debug option, parameters checks.
- * @details If enabled then the checks on the API functions input
- *          parameters are activated.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_CHECKS)
-#define CH_DBG_ENABLE_CHECKS                FALSE
-#endif
-
-/**
- * @brief   Debug option, consistency checks.
- * @details If enabled then all the assertions in the kernel code are
- *          activated. This includes consistency checks inside the kernel,
- *          runtime anomalies and port-defined checks.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_ASSERTS)
-#define CH_DBG_ENABLE_ASSERTS               TRUE
-#endif
-
-/**
- * @brief   Debug option, trace buffer.
- * @details If enabled then the trace buffer is activated.
- *
- * @note    The default is @p CH_DBG_TRACE_MASK_DISABLED.
- */
-#if !defined(CH_DBG_TRACE_MASK)
-#define CH_DBG_TRACE_MASK                   CH_DBG_TRACE_MASK_DISABLED
-#endif
-
-/**
- * @brief   Trace buffer entries.
- * @note    The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
- *          different from @p CH_DBG_TRACE_MASK_DISABLED.
- */
-#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
-#define CH_DBG_TRACE_BUFFER_SIZE            128
-#endif
-
-/**
- * @brief   Debug option, stack checks.
- * @details If enabled then a runtime stack check is performed.
- *
- * @note    The default is @p FALSE.
- * @note    The stack check is performed in a architecture/port dependent way.
- *          It may not be implemented or some ports.
- * @note    The default failure mode is to halt the system with the global
- *          @p panic_msg variable set to @p NULL.
- */
-#if !defined(CH_DBG_ENABLE_STACK_CHECK)
-#define CH_DBG_ENABLE_STACK_CHECK           TRUE
-#endif
-
-/**
- * @brief   Debug option, stacks initialization.
- * @details If enabled then the threads working area is filled with a byte
- *          value when a thread is created. This can be useful for the
- *          runtime measurement of the used stack.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_FILL_THREADS)
-#define CH_DBG_FILL_THREADS                 TRUE
-#endif
-
-/**
- * @brief   Debug option, threads profiling.
- * @details If enabled then a field is added to the @p thread_t structure that
- *          counts the system ticks occurred while executing the thread.
- *
- * @note    The default is @p FALSE.
- * @note    This debug option is not currently compatible with the
- *          tickless mode.
- */
-#if !defined(CH_DBG_THREADS_PROFILING)
-#define CH_DBG_THREADS_PROFILING            FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -567,130 +115,37 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   System structure extension.
- * @details User fields added to the end of the @p ch_system_t structure.
- */
-#define CH_CFG_SYSTEM_EXTRA_FIELDS                                          \
-  /* Add threads custom fields here.*/
+// common definitions in aos_chconf.h
 
-/**
- * @brief   System initialization hook.
- * @details User initialization code added to the @p chSysInit() function
- *          just before interrupts are enabled globally.
- */
-#define CH_CFG_SYSTEM_INIT_HOOK(tp) {                                       \
-  /* Add threads initialization code here.*/                                \
-}
-
-/**
- * @brief   Threads descriptor structure extension.
- * @details User fields added to the end of the @p thread_t structure.
- */
-#define CH_CFG_THREAD_EXTRA_FIELDS                                          \
-  /* Add threads custom fields here.*/
-
-/**
- * @brief   Threads initialization hook.
- * @details User initialization code added to the @p _thread_init() function.
- *
- * @note    It is invoked from within @p _thread_init() and implicitly from all
- *          the threads creation APIs.
- */
-#define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
-  /* Add threads initialization code here.*/                                \
-}
-
-/**
- * @brief   Threads finalization hook.
- * @details User finalization code added to the @p chThdExit() API.
- */
-#define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
-  /* Add threads finalization code here.*/                                  \
-}
-
-/**
- * @brief   Context switch hook.
- * @details This hook is invoked just before switching between threads.
- */
-#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
-  /* Context switch code here.*/                                            \
-}
-
-/**
- * @brief   ISR enter hook.
- */
-#define CH_CFG_IRQ_PROLOGUE_HOOK() {                                        \
-  /* IRQ prologue code here.*/                                              \
-}
-
-/**
- * @brief   ISR exit hook.
- */
-#define CH_CFG_IRQ_EPILOGUE_HOOK() {                                        \
-  /* IRQ epilogue code here.*/                                              \
-}
-
-/**
- * @brief   Idle thread enter hook.
- * @note    This hook is invoked within a critical zone, no OS functions
- *          should be invoked from here.
- * @note    This macro can be used to activate a power saving mode.
- */
-#define CH_CFG_IDLE_ENTER_HOOK() {                                          \
-  /* Idle-enter code here.*/                                                \
-}
+/** @} */
 
+/*===========================================================================*/
 /**
- * @brief   Idle thread leave hook.
- * @note    This hook is invoked within a critical zone, no OS functions
- *          should be invoked from here.
- * @note    This macro can be used to deactivate a power saving mode.
+ * @name Port-specific settings (override port settings defaulted in chcore.h).
+ * @{
  */
-#define CH_CFG_IDLE_LEAVE_HOOK() {                                          \
-  /* Idle-leave code here.*/                                                \
-}
+/*===========================================================================*/
 
 /**
- * @brief   Idle Loop hook.
- * @details This hook is continuously invoked by the idle thread loop.
+ * @brief   NVIC VTOR initialization offset.
+ * @details On initialization, the code at this address in the flash memory will be executed.
  */
-#define CH_CFG_IDLE_LOOP_HOOK() {                                           \
-  /* Idle loop code here.*/                                                 \
-}
+#define CORTEX_VTOR_INIT 0x00006000U
 
-/**
- * @brief   System tick event hook.
- * @details This hook is invoked in the system tick handler immediately
- *          after processing the virtual timers queue.
- */
-#define CH_CFG_SYSTEM_TICK_HOOK() {                                         \
-  /* System tick event code here.*/                                         \
-}
+/** @} */
 
+/*===========================================================================*/
 /**
- * @brief   System halt hook.
- * @details This hook is invoked in case to a system halting error before
- *          the system is halted.
+ * @name other
+ * @{
  */
-#define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
-  /* System halt code here.*/                                               \
-}
+/*===========================================================================*/
 
-/**
- * @brief   Trace hook.
- * @details This hook is invoked each time a new record is written in the
- *          trace buffer.
- */
-#define CH_CFG_TRACE_HOOK(tep) {                                            \
-  /* Trace code here.*/                                                     \
-}
+// common definitions in aos_chconf.h
 
 /** @} */
 
-/*===========================================================================*/
-/* Port-specific settings (override port settings defaulted in chcore.h).    */
-/*===========================================================================*/
+#include <aos_chconf.h>
 
 #endif  /* CHCONF_H */
 
diff --git a/modules/LightRing_1-0/halconf.h b/modules/LightRing_1-0/halconf.h
index c9bae1c..9f13718 100644
--- a/modules/LightRing_1-0/halconf.h
+++ b/modules/LightRing_1-0/halconf.h
@@ -30,151 +30,190 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef _HALCONF_H_
 #define _HALCONF_H_
 
+#define _CHIBIOS_HAL_CONF_
+#define _CHIBIOS_HAL_CONF_VER_6_0_
+
+#include "mcuconf.h"
+
 /**
  * @brief   Enables the PAL subsystem.
  */
 #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
-#define HAL_USE_PAL                 TRUE
+#define HAL_USE_PAL                         TRUE
 #endif
 
 /**
  * @brief   Enables the ADC subsystem.
  */
 #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
-#define HAL_USE_ADC                 FALSE
+#define HAL_USE_ADC                         FALSE
 #endif
 
 /**
  * @brief   Enables the CAN subsystem.
  */
 #if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
-#define HAL_USE_CAN                 TRUE
+#define HAL_USE_CAN                         TRUE
+#endif
+
+/**
+ * @brief   Enables the cryptographic subsystem.
+ */
+#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
+#define HAL_USE_CRY                         FALSE
 #endif
 
 /**
  * @brief   Enables the DAC subsystem.
  */
 #if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
-#define HAL_USE_DAC                 FALSE
+#define HAL_USE_DAC                         FALSE
 #endif
 
 /**
  * @brief   Enables the EXT subsystem.
  */
 #if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
-#define HAL_USE_EXT                 FALSE
+#define HAL_USE_EXT                         FALSE
 #endif
 
 /**
  * @brief   Enables the GPT subsystem.
  */
 #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT                 FALSE
+#define HAL_USE_GPT                         FALSE
 #endif
 
 /**
  * @brief   Enables the I2C subsystem.
  */
 #if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C                 TRUE
+#define HAL_USE_I2C                         TRUE
 #endif
 
 /**
  * @brief   Enables the I2S subsystem.
  */
 #if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
-#define HAL_USE_I2S                 FALSE
+#define HAL_USE_I2S                         FALSE
 #endif
 
 /**
  * @brief   Enables the ICU subsystem.
  */
 #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
-#define HAL_USE_ICU                 FALSE
+#define HAL_USE_ICU                         FALSE
 #endif
 
 /**
  * @brief   Enables the MAC subsystem.
  */
 #if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
-#define HAL_USE_MAC                 FALSE
+#define HAL_USE_MAC                         FALSE
 #endif
 
 /**
  * @brief   Enables the MMC_SPI subsystem.
  */
 #if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_MMC_SPI             FALSE
+#define HAL_USE_MMC_SPI                     FALSE
 #endif
 
 /**
  * @brief   Enables the PWM subsystem.
  */
 #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM                 FALSE
+#define HAL_USE_PWM                         FALSE
+#endif
+
+/**
+ * @brief   Enables the QSPI subsystem.
+ */
+#if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
+#define HAL_USE_QSPI                        FALSE
 #endif
 
 /**
  * @brief   Enables the RTC subsystem.
  */
 #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
-#define HAL_USE_RTC                 TRUE
+#define HAL_USE_RTC                         TRUE
 #endif
 
 /**
  * @brief   Enables the SDC subsystem.
  */
 #if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
-#define HAL_USE_SDC                 FALSE
+#define HAL_USE_SDC                         FALSE
 #endif
 
 /**
  * @brief   Enables the SERIAL subsystem.
  */
 #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL              TRUE
+#define HAL_USE_SERIAL                      TRUE
 #endif
 
 /**
  * @brief   Enables the SERIAL over USB subsystem.
  */
 #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL_USB          FALSE
+#define HAL_USE_SERIAL_USB                  FALSE
 #endif
 
 /**
  * @brief   Enables the SPI subsystem.
  */
 #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI                 TRUE
+#define HAL_USE_SPI                         TRUE
 #endif
 
 /**
  * @brief   Enables the UART subsystem.
  */
 #if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
-#define HAL_USE_UART                FALSE
+#define HAL_USE_UART                        FALSE
 #endif
 
 /**
  * @brief   Enables the USB subsystem.
  */
 #if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
-#define HAL_USE_USB                 FALSE
+#define HAL_USE_USB                         FALSE
 #endif
 
 /**
  * @brief   Enables the WDG subsystem.
  */
 #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
-#define HAL_USE_WDG                 FALSE
+#define HAL_USE_WDG                         FALSE
 #endif
 
 /**
  * @brief   Enables the QEI subsystem.
  */
 #if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
-#define HAL_USE_QEI                 FALSE
+#define HAL_USE_QEI                         FALSE
+#endif
+
+/*===========================================================================*/
+/* PAL driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
+#define PAL_USE_CALLBACKS                   TRUE
+#endif
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
+#define PAL_USE_WAIT                        FALSE
 #endif
 
 /*===========================================================================*/
@@ -186,7 +225,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
-#define ADC_USE_WAIT                FALSE
+#define ADC_USE_WAIT                        FALSE
 #endif
 
 /**
@@ -194,7 +233,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define ADC_USE_MUTUAL_EXCLUSION    FALSE
+#define ADC_USE_MUTUAL_EXCLUSION            FALSE
 #endif
 
 /*===========================================================================*/
@@ -205,7 +244,56 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Sleep mode related APIs inclusion switch.
  */
 #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
-#define CAN_USE_SLEEP_MODE          FALSE
+#define CAN_USE_SLEEP_MODE                  FALSE
+#endif
+
+/**
+ * @brief   Enforces the driver to use direct callbacks rather than OSAL events.
+ */
+#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
+#define CAN_ENFORCE_USE_CALLBACKS           FALSE
+#endif
+
+/*===========================================================================*/
+/* CRY driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables the SW fall-back of the cryptographic driver.
+ * @details When enabled, this option, activates a fall-back software
+ *          implementation for algorithms not supported by the underlying
+ *          hardware.
+ * @note    Fall-back implementations may not be present for all algorithms.
+ */
+#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
+#define HAL_CRY_USE_FALLBACK                FALSE
+#endif
+
+/**
+ * @brief   Makes the driver forcibly use the fall-back implementations.
+ */
+#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
+#define HAL_CRY_ENFORCE_FALLBACK            FALSE
+#endif
+
+/*===========================================================================*/
+/* DAC driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
+#define DAC_USE_WAIT                        TRUE
+#endif
+
+/**
+ * @brief   Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define DAC_USE_MUTUAL_EXCLUSION            TRUE
 #endif
 
 /*===========================================================================*/
@@ -216,7 +304,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Enables the mutual exclusion APIs on the I2C bus.
  */
 #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define I2C_USE_MUTUAL_EXCLUSION    TRUE
+#define I2C_USE_MUTUAL_EXCLUSION            TRUE
 #endif
 
 /*===========================================================================*/
@@ -224,17 +312,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /*===========================================================================*/
 
 /**
- * @brief   Enables an event sources for incoming packets.
+ * @brief   Enables the zero-copy API.
  */
 #if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
-#define MAC_USE_ZERO_COPY           FALSE
+#define MAC_USE_ZERO_COPY                   FALSE
 #endif
 
 /**
  * @brief   Enables an event sources for incoming packets.
  */
 #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
-#define MAC_USE_EVENTS              FALSE
+#define MAC_USE_EVENTS                      FALSE
 #endif
 
 /*===========================================================================*/
@@ -250,7 +338,27 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          use a DMA channel and heavily loads the CPU.
  */
 #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
-#define MMC_NICE_WAITING            FALSE
+#define MMC_NICE_WAITING                    FALSE
+#endif
+
+/*===========================================================================*/
+/* QSPI driver related settings.                                             */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(QSPI_USE_WAIT) || defined(__DOXYGEN__)
+#define QSPI_USE_WAIT                       TRUE
+#endif
+
+/**
+ * @brief   Enables the @p qspiAcquireBus() and @p qspiReleaseBus() APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(QSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define QSPI_USE_MUTUAL_EXCLUSION           TRUE
 #endif
 
 /*===========================================================================*/
@@ -262,7 +370,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Attempts are performed at 10mS intervals.
  */
 #if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
-#define SDC_INIT_RETRY              100
+#define SDC_INIT_RETRY                      100
 #endif
 
 /**
@@ -271,7 +379,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          at @p FALSE.
  */
 #if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
-#define SDC_MMC_SUPPORT             FALSE
+#define SDC_MMC_SUPPORT                     FALSE
 #endif
 
 /**
@@ -281,7 +389,21 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          lower priority, this may slow down the driver a bit however.
  */
 #if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
-#define SDC_NICE_WAITING            FALSE
+#define SDC_NICE_WAITING                    FALSE
+#endif
+
+/**
+ * @brief   OCR initialization constant for V20 cards.
+ */
+#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
+#define SDC_INIT_OCR_V20                    0x50FF8000U
+#endif
+
+/**
+ * @brief   OCR initialization constant for non-V20 cards.
+ */
+#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
+#define SDC_INIT_OCR                        0x80100000U
 #endif
 
 /*===========================================================================*/
@@ -294,7 +416,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          default configuration.
  */
 #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
-#define SERIAL_DEFAULT_BITRATE      115200
+#define SERIAL_DEFAULT_BITRATE              115200
 #endif
 
 /**
@@ -305,7 +427,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          buffers.
  */
 #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_BUFFERS_SIZE         16
+#define SERIAL_BUFFERS_SIZE                 16
 #endif
 
 /*===========================================================================*/
@@ -320,7 +442,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          buffers.
  */
 #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_SIZE     256
+#define SERIAL_USB_BUFFERS_SIZE             256
 #endif
 
 /**
@@ -328,7 +450,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    The default is 2 buffers.
  */
 #if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_NUMBER   2
+#define SERIAL_USB_BUFFERS_NUMBER           2
 #endif
 
 /*===========================================================================*/
@@ -340,15 +462,32 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
-#define SPI_USE_WAIT                TRUE
+#define SPI_USE_WAIT                        TRUE
 #endif
 
 /**
+ * @brief   Enables circular transfers APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
+#define SPI_USE_CIRCULAR                    FALSE
+#endif
+
+
+/**
  * @brief   Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define SPI_USE_MUTUAL_EXCLUSION    TRUE
+#define SPI_USE_MUTUAL_EXCLUSION            TRUE
+#endif
+
+/**
+ * @brief   Handling method for SPI CS line.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
+#define SPI_SELECT_MODE                     SPI_SELECT_MODE_PAD
 #endif
 
 /*===========================================================================*/
@@ -360,7 +499,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
-#define UART_USE_WAIT               FALSE
+#define UART_USE_WAIT                       FALSE
 #endif
 
 /**
@@ -368,7 +507,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define UART_USE_MUTUAL_EXCLUSION   FALSE
+#define UART_USE_MUTUAL_EXCLUSION           FALSE
 #endif
 
 /*===========================================================================*/
@@ -380,7 +519,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
-#define USB_USE_WAIT                FALSE
+#define USB_USE_WAIT                        FALSE
 #endif
 
 #endif /* _HALCONF_H_ */
diff --git a/modules/LightRing_1-0/mcuconf.h b/modules/LightRing_1-0/mcuconf.h
index 6381f70..68e1fd3 100644
--- a/modules/LightRing_1-0/mcuconf.h
+++ b/modules/LightRing_1-0/mcuconf.h
@@ -59,6 +59,21 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_PLS                           STM32_PLS_LEV0
 
 /*
+ * IRQ system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY            6
+#define STM32_IRQ_EXTI1_PRIORITY            6
+#define STM32_IRQ_EXTI2_PRIORITY            6
+#define STM32_IRQ_EXTI3_PRIORITY            6
+#define STM32_IRQ_EXTI4_PRIORITY            6
+#define STM32_IRQ_EXTI5_9_PRIORITY          6
+#define STM32_IRQ_EXTI10_15_PRIORITY        6
+#define STM32_IRQ_EXTI16_PRIORITY           6
+#define STM32_IRQ_EXTI17_PRIORITY           6
+#define STM32_IRQ_EXTI18_PRIORITY           6
+#define STM32_IRQ_EXTI19_PRIORITY           6
+
+/*
  * ADC driver system settings.
  */
 #define STM32_ADC_USE_ADC1                  FALSE
@@ -72,21 +87,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_CAN_CAN1_IRQ_PRIORITY         11
 
 /*
- * EXT driver system settings.
- */
-#define STM32_EXT_EXTI0_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI1_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI2_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI3_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI4_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI5_9_IRQ_PRIORITY      6
-#define STM32_EXT_EXTI10_15_IRQ_PRIORITY    6
-#define STM32_EXT_EXTI16_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI17_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI18_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI19_IRQ_PRIORITY       6
-
-/*
  * GPT driver system settings.
  */
 #define STM32_GPT_USE_TIM1                  TRUE
@@ -113,7 +113,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_I2C_I2C1_DMA_PRIORITY         3
 #define STM32_I2C_I2C2_DMA_PRIORITY         3
 #define STM32_I2C_DMA_ERROR_HOOK(i2cp)      osalSysHalt("DMA failure")
-#define STM32_I2C_USE_DMA                   FALSE
 
 /*
  * ICU driver system settings.
diff --git a/modules/LightRing_1-0/module.c b/modules/LightRing_1-0/module.c
index dd2b229..16611b0 100644
--- a/modules/LightRing_1-0/module.c
+++ b/modules/LightRing_1-0/module.c
@@ -18,26 +18,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "module.h"
 
+#include <amiroos.h>
+
 /*===========================================================================*/
 /**
  * @name Module specific functions
  * @{
  */
 /*===========================================================================*/
-#include <amiroos.h>
-
-/**
- * @brief   Interrupt service routine callback for I/O interrupt signals.
- *
- * @param   args      Channel on which the interrupt was encountered.
- */
-static void _modulePalIsrCallback(void *args) {
-  chSysLockFromISR();
-  chEvtBroadcastFlagsI(&aos.events.io, (1 << (*(uint16_t*)args)));
-  chSysUnlockFromISR();
-
-  return;
-}
 
 /** @} */
 
@@ -53,62 +41,6 @@ CANConfig moduleHalCanConfig = {
   /* btr  */ CAN_BTR_SJW(1) | CAN_BTR_TS2(2) | CAN_BTR_TS1(13) | CAN_BTR_BRP(1),
 };
 
-aos_interrupt_cfg_t moduleIntConfig[6] = {
-    /* channel  1 */ { // SYS_INT_N/SYS_SYNC_N: automatic interrupt on event
-      /* port     */ GPIOD,
-      /* pad      */ GPIOD_SYS_INT_N,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 1,
-    },
-    /* channel  2 */ { // LASER_OC_N: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_LASER_OC_N,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_FALLING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 2,
-    },
-    /* channel  3 */ { // SYS_UART_DN: automatic interrupt on event
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_SYS_UART_DN,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 3,
-    },
-    /* channel  4 */ { // WL_GDO0: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_WL_GDO0,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 4,
-    },
-    /* channel  5 */ { // WL_GDO2: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_WL_GDO2,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 5,
-    },
-    /* channel  6 */ { // SYS_PD_N: automatic interrupt on event
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_SYS_PD_N,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_FALLING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 6,
-    },
-};
-
-aos_interrupt_driver_t moduleIntDriver = {
-  /* config     */ NULL,
-  /* interrupts */ 6,
-};
-
 I2CConfig moduleHalI2cEepromConfig = {
   /* I²C mode   */ OPMODE_I2C,
   /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
@@ -138,50 +70,149 @@ SPIConfig moduleHalSpiLightConfig = {
  */
 /*===========================================================================*/
 
-apalGpio_t moduleGpioLightBlank = {
+/**
+ * @brief   LIGHT_BANK output signal GPIO.
+ */
+static apalGpio_t _gpioLightBlank = {
   /* port */ GPIOA,
   /* pad  */ GPIOA_LIGHT_BLANK,
 };
+apalControlGpio_t moduleGpioLightBlank = {
+  /* GPIO */ &_gpioLightBlank,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ TLC5947_LLD_BLANK_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioLaserEn = {
+/**
+ * @brief   LASER_EN output signal GPIO.
+ */
+static apalGpio_t _gpioLaserEn = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_LASER_EN,
 };
+apalControlGpio_t moduleGpioLaserEn = {
+  /* GPIO */ &_gpioLaserEn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ TPS2051B_LLD_ENABLE_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioLaserOc = {
+/**
+ * @brief   LASER_OC input signal GPIO.
+ */
+static apalGpio_t _gpioLaserOc = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_LASER_OC_N,
 };
+apalControlGpio_t moduleGpioLaserOc = {
+  /* GPIO */ &_gpioLaserOc,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ TPS2051B_LLD_OVERCURRENT_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioSysUartDn = {
+/**
+ * @brief   SYS_UART_DN bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysUartDn = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_SYS_UART_DN,
 };
+apalControlGpio_t moduleGpioSysUartDn = {
+  /* GPIO */ &_gpioSysUartDn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioWlGdo2 = {
+/**
+ * @brief   WL_GDO2 input signal GPIO.
+ */
+static apalGpio_t _gpioWlGdo2 = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_WL_GDO2,
 };
+apalControlGpio_t moduleGpioWlGdo2 = {
+  /* GPIO */ &_gpioWlGdo2,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioWlGdo0= {
+/**
+ * @brief   WL_GDO0 input signal GPIO.
+ */
+static apalGpio_t _gpioWlGdo0= {
   /* port */ GPIOB,
   /* pad  */ GPIOB_WL_GDO0,
 };
+apalControlGpio_t moduleGpioWlGdo0 = {
+  /* GPIO */ &_gpioWlGdo0,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioLightXlat = {
+/**
+ * @brief   LIGHT_XLAT output signal GPIO.
+ */
+static apalGpio_t _gpioLightXlat = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_LIGHT_XLAT,
 };
+apalControlGpio_t moduleGpioLightXlat = {
+  /* GPIO */ &_gpioLightXlat,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ TLC5947_LLD_XLAT_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioSysPd = {
+/**
+ * @brief   SYS_PD bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysPd = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_PD_N,
 };
+apalControlGpio_t moduleGpioSysPd = {
+  /* GPIO */ &_gpioSysPd,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioSysSync = {
+/**
+ * @brief   SYS_SYNC bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysSync = {
   /* port */ GPIOD,
   /* pad  */ GPIOD_SYS_INT_N,
 };
+apalControlGpio_t moduleGpioSysSync = {
+  /* GPIO */ &_gpioSysSync,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
 /** @} */
 
@@ -205,33 +236,6 @@ const char* moduleShellPrompt = "LightRing";
  */
 /*===========================================================================*/
 
-apalControlGpio_t moduleSsspGpioPd = {
-  /* GPIO */ &moduleGpioSysPd,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
-apalControlGpio_t moduleSsspGpioSync = {
-  /* GPIO */ &moduleGpioSysSync,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
-apalControlGpio_t moduleSsspGpioDn = {
-  /* GPIO */ &moduleGpioSysUartDn,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
 /** @} */
 
 /*===========================================================================*/
@@ -248,41 +252,13 @@ AT24C01BNDriver moduleLldEeprom = {
 
 TLC5947Driver moduleLldLedPwm = {
   /* SPI driver         */ &MODULE_HAL_SPI_LIGHT,
-  /* BLANK signal GPIO  */ {
-    /* GPIO */ &moduleGpioLightBlank,
-    /* meta */ {
-      /* active state */ TLC5947_LLD_BLANK_ACTIVE_STATE,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
-  /* XLAT signal GPIO   */ {
-    /* GPIO */ &moduleGpioLightXlat,
-    /* meta */ {
-      /* active state */ TLC5947_LLD_XLAT_ACTIVE_STATE,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
+  /* BLANK signal GPIO  */ &moduleGpioLightBlank,
+  /* XLAT signal GPIO   */ &moduleGpioLightXlat,
 };
 
 TPS2051BDriver moduleLldPowerSwitchLaser = {
-  /* laser enable gpio */ {
-    /* GPIO */ &moduleGpioLaserEn,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_HIGH,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
-  /* laser overcurrent gpio */ {
-    /* GPIO         */ &moduleGpioLaserOc,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_INPUT,
-    },
-  },
+  /* laser enable GPIO      */ &moduleGpioLaserEn,
+  /* laser overcurrent GPIO */ &moduleGpioLaserOc,
 };
 
 /** @} */
diff --git a/modules/LightRing_1-0/module.h b/modules/LightRing_1-0/module.h
index 7b4a9d1..e463279 100644
--- a/modules/LightRing_1-0/module.h
+++ b/modules/LightRing_1-0/module.h
@@ -35,7 +35,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 /*===========================================================================*/
 #include <hal.h>
-#include <aos_interrupts.h>
 
 /**
  * @brief   CAN driver to use.
@@ -48,17 +47,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 extern CANConfig moduleHalCanConfig;
 
 /**
- * @brief   Interrupt driver (PAL).
- */
-
-extern aos_interrupt_driver_t moduleIntDriver;
-
-/**
- * @brief   Interrupt driver config.
- */
-extern aos_interrupt_cfg_t moduleIntConfig[6];
-
-/**
  * @brief   I2C driver to access the EEPROM.
  */
 #define MODULE_HAL_I2C_EEPROM                   I2CD2
@@ -104,79 +92,49 @@ extern SPIConfig moduleHalSpiLightConfig;
 #include <amiro-lld.h>
 
 /**
- * @brief   Interrupt channel for the SYS_SYNC signal.
- */
-#define MODULE_GPIO_INT_SYSSYNC          ((uint8_t)1)
-
-/**
- * @brief   Interrupt channel for the LASER_OC signal.
- */
-#define MODULE_GPIO_INT_LASEROC          ((uint8_t)2)
-
-/**
- * @brief   Interrupt channel for the SYS_UART_DN signal.
- */
-#define MODULE_GPIO_INT_SYSUARTDN        ((uint8_t)3)
-
-/**
- * @brief   Interrupt channel for the WL_GDO2 signal.
- */
-#define MODULE_GPIO_INT_WLGDO2           ((uint8_t)4)
-
-/**
- * @brief   Interrupt channel for the WL_GDO0 signal.
- */
-#define MODULE_GPIO_INT_WLGDO0           ((uint8_t)5)
-
-/**
- * @brief   Interrupt channel for the SYS_PD signal.
- */
-#define MODULE_GPIO_INT_SYSPD            ((uint8_t)6)
-
-/**
  * @brief   LIGHT_BANK output signal GPIO.
  */
-extern apalGpio_t moduleGpioLightBlank;
+extern apalControlGpio_t moduleGpioLightBlank;
 
 /**
  * @brief   LASER_EN output signal GPIO.
  */
-extern apalGpio_t moduleGpioLaserEn;
+extern apalControlGpio_t moduleGpioLaserEn;
 
 /**
  * @brief   LASER_OC input signal GPIO.
  */
-extern apalGpio_t moduleGpioLaserOc;
+extern apalControlGpio_t moduleGpioLaserOc;
 
 /**
  * @brief   SYS_UART_DN bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysUartDn;
+extern apalControlGpio_t moduleGpioSysUartDn;
 
 /**
  * @brief   WL_GDO2 input signal GPIO.
  */
-extern apalGpio_t moduleGpioWlGdo2;
+extern apalControlGpio_t moduleGpioWlGdo2;
 
 /**
  * @brief   WL_GDO0 input signal GPIO.
  */
-extern apalGpio_t moduleGpioWlGdo0;
+extern apalControlGpio_t moduleGpioWlGdo0;
 
 /**
  * @brief   LIGHT_XLAT output signal GPIO.
  */
-extern apalGpio_t moduleGpioLightXlat;
+extern apalControlGpio_t moduleGpioLightXlat;
 
 /**
  * @brief   SYS_PD bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysPd;
+extern apalControlGpio_t moduleGpioSysPd;
 
 /**
  * @brief   SYS_SYNC bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysSync;
+extern apalControlGpio_t moduleGpioSysSync;
 
 /** @} */
 
@@ -190,32 +148,32 @@ extern apalGpio_t moduleGpioSysSync;
 /**
  * @brief   Event flag to be set on a LASER_OC interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_LASEROC          ((eventflags_t)(1 << MODULE_GPIO_INT_LASEROC))
+#define MODULE_OS_IOEVENTFLAGS_LASEROC          ((eventflags_t)1 << GPIOB_LASER_OC_N)
 
 /**
  * @brief   Event flag to be set on a SYS_UART_DN interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN        ((eventflags_t)(1 << MODULE_GPIO_INT_SYSUARTDN))
+#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN        ((eventflags_t)1 << GPIOB_SYS_UART_DN)
 
 /**
  * @brief   Event flag to be set on a WL_GDO2 interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_WLGDO2           ((eventflags_t)(1 << MODULE_GPIO_INT_WLGDO2))
+#define MODULE_OS_IOEVENTFLAGS_WLGDO2           ((eventflags_t)1 << GPIOB_WL_GDO2)
 
 /**
  * @brief   Event flag to be set on a WL_GDO0 interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_WLGDO0           ((eventflags_t)(1 << MODULE_GPIO_INT_WLGDO0))
+#define MODULE_OS_IOEVENTFLAGS_WLGDO0           ((eventflags_t)1 << GPIOB_WL_GDO0)
 
 /**
  * @brief   Event flag to be set on a SYS_PD interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)(1 << MODULE_GPIO_INT_SYSPD))
+#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)1 << GPIOC_SYS_PD_N)
 
 /**
  * @brief   Event flag to be set on a SYS_SYNC interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)(1 << MODULE_GPIO_INT_SYSSYNC))
+#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)1 << GPIOD_SYS_INT_N)
 
 #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
 /**
@@ -225,6 +183,22 @@ extern const char* moduleShellPrompt;
 #endif
 
 /**
+ * @brief   Interrupt initialization macro.
+ * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
+ */
+#define MODULE_INIT_INTERRUPTS() {                                            \
+  /* LASER_OC */                                                              \
+  palSetPadCallback(moduleGpioLaserOc.gpio->port, moduleGpioLaserOc.gpio->pad, _intCallback, &moduleGpioLaserOc.gpio->pad); \
+  palEnablePadEvent(moduleGpioLaserOc.gpio->port, moduleGpioLaserOc.gpio->pad, APAL2CH_EDGE(moduleGpioLaserOc.meta.edge));  \
+  /* WL_GDO2 */                                                               \
+  palSetPadCallback(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, _intCallback, &moduleGpioWlGdo2.gpio->pad);  \
+  palEnablePadEvent(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, APAL2CH_EDGE(moduleGpioWlGdo2.meta.edge));   \
+  /* WL_GDO0 */                                                               \
+  palSetPadCallback(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, _intCallback, &moduleGpioWlGdo0.gpio->pad);  \
+  /*palEnablePadEvent(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, APAL2CH_EDGE(moduleGpioWlGdo0.meta.edge)); // this is broken for some reason*/   \
+}
+
+/**
  * @brief   Unit test initialization hook.
  */
 #define MODULE_INIT_TESTS() {                                                 \
@@ -271,17 +245,17 @@ extern const char* moduleShellPrompt;
 /**
  * @brief   PD signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioPd;
+#define moduleSsspGpioPd                        moduleGpioSysPd
 
 /**
  * @brief   SYNC signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioSync;
+#define moduleSsspGpioSync                      moduleGpioSysSync
 
 /**
  * @brief   DN signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioDn;
+#define moduleSsspGpioDn                        moduleGpioSysUartDn
 
 /**
  * @brief   Event flags for PD signal events.
diff --git a/modules/Makefile b/modules/Makefile
index 99be89b..843a136 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -32,13 +32,12 @@ endif
 CLEANTRGS = $(MODULES:%=clean_%)
 FLASHTRGS = $(MODULES:%=flash_%)
 
-.PHONY: all $(MODULES) flash $(FLASHTRGS) clean $(CLEANTRGS)
+.PHONY: all $(MODULES) $(FLASHTRGS) clean $(CLEANTRGS)
 
 all: $(MODULES)
 $(MODULES):
 	$(MAKE) -C $(MODULES_DIR)$@
 
-flash: $(FLASHTRGS)
 $(FLASHTRGS):
 	$(MAKE) -C $(MODULES_DIR)$(@:flash_%=%) flash
 
diff --git a/modules/PowerManagement_1-1/alldconf.h b/modules/PowerManagement_1-1/alldconf.h
index 14572d2..68aa18a 100644
--- a/modules/PowerManagement_1-1/alldconf.h
+++ b/modules/PowerManagement_1-1/alldconf.h
@@ -27,6 +27,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define AMIRO_LLD_CFG_VERSION_MINOR         0
 
 /**
+ * @brief   Width of the apalTime_t data type.
+ *
+ * @details Possible values are 8, 16, 32, and 64 bits.
+ *          By definition time is represented ot a microsecond precision.
+ */
+#define AMIROLLD_CFG_TIME_SIZE          32
+
+/**
  * @brief   Enable flag for the AT24C01BN-SH-B EEPROM.
  */
 #define AMIROLLD_CFG_USE_AT24C01BN
diff --git a/modules/PowerManagement_1-1/chconf.h b/modules/PowerManagement_1-1/chconf.h
index 9cff1c4..0b12069 100644
--- a/modules/PowerManagement_1-1/chconf.h
+++ b/modules/PowerManagement_1-1/chconf.h
@@ -32,6 +32,8 @@
 #define _CHIBIOS_RT_CONF_
 #define _CHIBIOS_RT_CONF_VER_5_1_
 
+#include <aosconf.h>
+
 /*===========================================================================*/
 /**
  * @name System timers settings
@@ -47,42 +49,7 @@
 #define CH_CFG_ST_RESOLUTION                32
 #endif
 
-/**
- * @brief   System tick frequency.
- * @details Frequency of the system timer that drives the system ticks. This
- *          setting also defines the system tick time unit.
- */
-#if !defined(CH_CFG_ST_FREQUENCY)
-#define CH_CFG_ST_FREQUENCY                 1000000UL
-#endif
-
-/**
- * @brief   Time intervals data size.
- * @note    Allowed values are 16, 32 or 64 bits.
- */
-#if !defined(CH_CFG_INTERVALS_SIZE)
-#define CH_CFG_INTERVALS_SIZE               64
-#endif
-
-/**
- * @brief   Time types data size.
- * @note    Allowed values are 16 or 32 bits.
- */
-#if !defined(CH_CFG_TIME_TYPES_SIZE)
-#define CH_CFG_TIME_TYPES_SIZE              32
-#endif
-
-/**
- * @brief   Time delta constant for the tick-less mode.
- * @note    If this value is zero then the system uses the classic
- *          periodic tick. This value represents the minimum number
- *          of ticks that is safe to specify in a timeout directive.
- *          The value one is not valid, timeouts are rounded up to
- *          this value.
- */
-#if !defined(CH_CFG_ST_TIMEDELTA)
-#define CH_CFG_ST_TIMEDELTA                 10
-#endif
+// more common definition in aos_chconf.h
 
 /** @} */
 
@@ -93,47 +60,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Round robin interval.
- * @details This constant is the number of system ticks allowed for the
- *          threads before preemption occurs. Setting this value to zero
- *          disables the preemption for threads with equal priority and the
- *          round robin becomes cooperative. Note that higher priority
- *          threads can still preempt, the kernel is always preemptive.
- * @note    Disabling the round robin preemption makes the kernel more compact
- *          and generally faster.
- * @note    The round robin preemption is not supported in tickless mode and
- *          must be set to zero in that case.
- */
-#if !defined(CH_CFG_TIME_QUANTUM)
-#define CH_CFG_TIME_QUANTUM                 0
-#endif
-
-/**
- * @brief   Managed RAM size.
- * @details Size of the RAM area to be managed by the OS. If set to zero
- *          then the whole available RAM is used. The core memory is made
- *          available to the heap allocator and/or can be used directly through
- *          the simplified core memory allocator.
- *
- * @note    In order to let the OS manage the whole RAM the linker script must
- *          provide the @p __heap_base__ and @p __heap_end__ symbols.
- * @note    Requires @p CH_CFG_USE_MEMCORE.
- */
-#if !defined(CH_CFG_MEMCORE_SIZE)
-#define CH_CFG_MEMCORE_SIZE                 0
-#endif
-
-/**
- * @brief   Idle thread automatic spawn suppression.
- * @details When this option is activated the function @p chSysInit()
- *          does not spawn the idle thread. The application @p main()
- *          function becomes the idle thread and must implement an
- *          infinite loop.
- */
-#if !defined(CH_CFG_NO_IDLE_THREAD)
-#define CH_CFG_NO_IDLE_THREAD               FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -144,17 +71,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   OS optimization.
- * @details If enabled then time efficient rather than space efficient code
- *          is used when two possible implementations exist.
- *
- * @note    This is not related to the compiler optimization options.
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_OPTIMIZE_SPEED)
-#define CH_CFG_OPTIMIZE_SPEED               TRUE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -165,224 +82,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Time Measurement APIs.
- * @details If enabled then the time measurement APIs are included in
- *          the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_TM)
-#define CH_CFG_USE_TM                       FALSE
-#endif
-
-/**
- * @brief   Threads registry APIs.
- * @details If enabled then the registry APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_REGISTRY)
-#define CH_CFG_USE_REGISTRY                 FALSE
-#endif
-
-/**
- * @brief   Threads synchronization APIs.
- * @details If enabled then the @p chThdWait() function is included in
- *          the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_WAITEXIT)
-#define CH_CFG_USE_WAITEXIT                 TRUE
-#endif
-
-/**
- * @brief   Semaphores APIs.
- * @details If enabled then the Semaphores APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_SEMAPHORES)
-#define CH_CFG_USE_SEMAPHORES               FALSE
-#endif
-
-/**
- * @brief   Semaphores queuing mode.
- * @details If enabled then the threads are enqueued on semaphores by
- *          priority rather than in FIFO order.
- *
- * @note    The default is @p FALSE. Enable this if you have special
- *          requirements.
- * @note    Requires @p CH_CFG_USE_SEMAPHORES.
- */
-#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
-#define CH_CFG_USE_SEMAPHORES_PRIORITY      FALSE
-#endif
-
-/**
- * @brief   Mutexes APIs.
- * @details If enabled then the mutexes APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MUTEXES)
-#define CH_CFG_USE_MUTEXES                  TRUE
-#endif
-
-/**
- * @brief   Enables recursive behavior on mutexes.
- * @note    Recursive mutexes are heavier and have an increased
- *          memory footprint.
- *
- * @note    The default is @p FALSE.
- * @note    Requires @p CH_CFG_USE_MUTEXES.
- */
-#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
-#define CH_CFG_USE_MUTEXES_RECURSIVE        FALSE
-#endif
-
-/**
- * @brief   Conditional Variables APIs.
- * @details If enabled then the conditional variables APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_MUTEXES.
- */
-#if !defined(CH_CFG_USE_CONDVARS)
-#define CH_CFG_USE_CONDVARS                 FALSE
-#endif
-
-/**
- * @brief   Conditional Variables APIs with timeout.
- * @details If enabled then the conditional variables APIs with timeout
- *          specification are included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_CONDVARS.
- */
-#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
-#define CH_CFG_USE_CONDVARS_TIMEOUT         FALSE
-#endif
-
-/**
- * @brief   Events Flags APIs.
- * @details If enabled then the event flags APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_EVENTS)
-#define CH_CFG_USE_EVENTS                   TRUE
-#endif
-
-/**
- * @brief   Events Flags APIs with timeout.
- * @details If enabled then the events APIs with timeout specification
- *          are included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_EVENTS.
- */
-#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
-#define CH_CFG_USE_EVENTS_TIMEOUT           TRUE
-#endif
-
-/**
- * @brief   Synchronous Messages APIs.
- * @details If enabled then the synchronous messages APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MESSAGES)
-#define CH_CFG_USE_MESSAGES                 FALSE
-#endif
-
-/**
- * @brief   Synchronous Messages queuing mode.
- * @details If enabled then messages are served by priority rather than in
- *          FIFO order.
- *
- * @note    The default is @p FALSE. Enable this if you have special
- *          requirements.
- * @note    Requires @p CH_CFG_USE_MESSAGES.
- */
-#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
-#define CH_CFG_USE_MESSAGES_PRIORITY        FALSE
-#endif
-
-/**
- * @brief   Mailboxes APIs.
- * @details If enabled then the asynchronous messages (mailboxes) APIs are
- *          included in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_SEMAPHORES.
- */
-#if !defined(CH_CFG_USE_MAILBOXES)
-#define CH_CFG_USE_MAILBOXES                FALSE
-#endif
-
-/**
- * @brief   Core Memory Manager APIs.
- * @details If enabled then the core memory manager APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MEMCORE)
-#define CH_CFG_USE_MEMCORE                  FALSE
-#endif
-
-/**
- * @brief   Heap Allocator APIs.
- * @details If enabled then the memory heap allocator APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
- *          @p CH_CFG_USE_SEMAPHORES.
- * @note    Mutexes are recommended.
- */
-#if !defined(CH_CFG_USE_HEAP)
-#define CH_CFG_USE_HEAP                     FALSE
-#endif
-
-/**
- * @brief   Memory Pools Allocator APIs.
- * @details If enabled then the memory pools allocator APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_MEMPOOLS)
-#define CH_CFG_USE_MEMPOOLS                 FALSE
-#endif
-
-/**
- * @brief  Objects FIFOs APIs.
- * @details If enabled then the objects FIFOs APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#if !defined(CH_CFG_USE_OBJ_FIFOS)
-#define CH_CFG_USE_OBJ_FIFOS                FALSE
-#endif
-
-/**
- * @brief   Dynamic Threads APIs.
- * @details If enabled then the dynamic threads creation APIs are included
- *          in the kernel.
- *
- * @note    The default is @p TRUE.
- * @note    Requires @p CH_CFG_USE_WAITEXIT.
- * @note    Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
- */
-#if !defined(CH_CFG_USE_DYNAMIC)
-#define CH_CFG_USE_DYNAMIC                  FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -393,60 +93,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Objects Factory APIs.
- * @details If enabled then the objects factory APIs are included in the
- *          kernel.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_CFG_USE_FACTORY)
-#define CH_CFG_USE_FACTORY                  FALSE
-#endif
-
-/**
- * @brief   Maximum length for object names.
- * @details If the specified length is zero then the name is stored by
- *          pointer but this could have unintended side effects.
- */
-#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
-#define CH_CFG_FACTORY_MAX_NAMES_LENGTH     8
-#endif
-
-/**
- * @brief   Enables the registry of generic objects.
- */
-#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
-#define CH_CFG_FACTORY_OBJECTS_REGISTRY     TRUE
-#endif
-
-/**
- * @brief   Enables factory for generic buffers.
- */
-#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
-#define CH_CFG_FACTORY_GENERIC_BUFFERS      TRUE
-#endif
-
-/**
- * @brief   Enables factory for semaphores.
- */
-#if !defined(CH_CFG_FACTORY_SEMAPHORES)
-#define CH_CFG_FACTORY_SEMAPHORES           TRUE
-#endif
-
-/**
- * @brief   Enables factory for mailboxes.
- */
-#if !defined(CH_CFG_FACTORY_MAILBOXES)
-#define CH_CFG_FACTORY_MAILBOXES            TRUE
-#endif
-
-/**
- * @brief   Enables factory for objects FIFOs.
- */
-#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
-#define CH_CFG_FACTORY_OBJ_FIFOS            TRUE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -457,106 +104,7 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Debug option, kernel statistics.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_STATISTICS)
-#define CH_DBG_STATISTICS                   FALSE
-#endif
-
-/**
- * @brief   Debug option, system state check.
- * @details If enabled the correct call protocol for system APIs is checked
- *          at runtime.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
-#define CH_DBG_SYSTEM_STATE_CHECK           FALSE
-#endif
-
-/**
- * @brief   Debug option, parameters checks.
- * @details If enabled then the checks on the API functions input
- *          parameters are activated.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_CHECKS)
-#define CH_DBG_ENABLE_CHECKS                FALSE
-#endif
-
-/**
- * @brief   Debug option, consistency checks.
- * @details If enabled then all the assertions in the kernel code are
- *          activated. This includes consistency checks inside the kernel,
- *          runtime anomalies and port-defined checks.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_ASSERTS)
-#define CH_DBG_ENABLE_ASSERTS               TRUE
-#endif
-
-/**
- * @brief   Debug option, trace buffer.
- * @details If enabled then the trace buffer is activated.
- *
- * @note    The default is @p CH_DBG_TRACE_MASK_DISABLED.
- */
-#if !defined(CH_DBG_TRACE_MASK)
-#define CH_DBG_TRACE_MASK                   CH_DBG_TRACE_MASK_DISABLED
-#endif
-
-/**
- * @brief   Trace buffer entries.
- * @note    The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
- *          different from @p CH_DBG_TRACE_MASK_DISABLED.
- */
-#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
-#define CH_DBG_TRACE_BUFFER_SIZE            128
-#endif
-
-/**
- * @brief   Debug option, stack checks.
- * @details If enabled then a runtime stack check is performed.
- *
- * @note    The default is @p FALSE.
- * @note    The stack check is performed in a architecture/port dependent way.
- *          It may not be implemented or some ports.
- * @note    The default failure mode is to halt the system with the global
- *          @p panic_msg variable set to @p NULL.
- */
-#if !defined(CH_DBG_ENABLE_STACK_CHECK)
-#define CH_DBG_ENABLE_STACK_CHECK           TRUE
-#endif
-
-/**
- * @brief   Debug option, stacks initialization.
- * @details If enabled then the threads working area is filled with a byte
- *          value when a thread is created. This can be useful for the
- *          runtime measurement of the used stack.
- *
- * @note    The default is @p FALSE.
- */
-#if !defined(CH_DBG_FILL_THREADS)
-#define CH_DBG_FILL_THREADS                 TRUE
-#endif
-
-/**
- * @brief   Debug option, threads profiling.
- * @details If enabled then a field is added to the @p thread_t structure that
- *          counts the system ticks occurred while executing the thread.
- *
- * @note    The default is @p FALSE.
- * @note    This debug option is not currently compatible with the
- *          tickless mode.
- */
-#if !defined(CH_DBG_THREADS_PROFILING)
-#define CH_DBG_THREADS_PROFILING            FALSE
-#endif
+// common definitions in aos_chconf.h
 
 /** @} */
 
@@ -567,130 +115,13 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   System structure extension.
- * @details User fields added to the end of the @p ch_system_t structure.
- */
-#define CH_CFG_SYSTEM_EXTRA_FIELDS                                          \
-  /* Add threads custom fields here.*/
-
-/**
- * @brief   System initialization hook.
- * @details User initialization code added to the @p chSysInit() function
- *          just before interrupts are enabled globally.
- */
-#define CH_CFG_SYSTEM_INIT_HOOK(tp) {                                       \
-  /* Add threads initialization code here.*/                                \
-}
-
-/**
- * @brief   Threads descriptor structure extension.
- * @details User fields added to the end of the @p thread_t structure.
- */
-#define CH_CFG_THREAD_EXTRA_FIELDS                                          \
-  /* Add threads custom fields here.*/
-
-/**
- * @brief   Threads initialization hook.
- * @details User initialization code added to the @p _thread_init() function.
- *
- * @note    It is invoked from within @p _thread_init() and implicitly from all
- *          the threads creation APIs.
- */
-#define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
-  /* Add threads initialization code here.*/                                \
-}
-
-/**
- * @brief   Threads finalization hook.
- * @details User finalization code added to the @p chThdExit() API.
- */
-#define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
-  /* Add threads finalization code here.*/                                  \
-}
-
-/**
- * @brief   Context switch hook.
- * @details This hook is invoked just before switching between threads.
- */
-#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
-  /* Context switch code here.*/                                            \
-}
-
-/**
- * @brief   ISR enter hook.
- */
-#define CH_CFG_IRQ_PROLOGUE_HOOK() {                                        \
-  /* IRQ prologue code here.*/                                              \
-}
-
-/**
- * @brief   ISR exit hook.
- */
-#define CH_CFG_IRQ_EPILOGUE_HOOK() {                                        \
-  /* IRQ epilogue code here.*/                                              \
-}
-
-/**
- * @brief   Idle thread enter hook.
- * @note    This hook is invoked within a critical zone, no OS functions
- *          should be invoked from here.
- * @note    This macro can be used to activate a power saving mode.
- */
-#define CH_CFG_IDLE_ENTER_HOOK() {                                          \
-  /* Idle-enter code here.*/                                                \
-}
-
-/**
- * @brief   Idle thread leave hook.
- * @note    This hook is invoked within a critical zone, no OS functions
- *          should be invoked from here.
- * @note    This macro can be used to deactivate a power saving mode.
- */
-#define CH_CFG_IDLE_LEAVE_HOOK() {                                          \
-  /* Idle-leave code here.*/                                                \
-}
-
-/**
- * @brief   Idle Loop hook.
- * @details This hook is continuously invoked by the idle thread loop.
- */
-#define CH_CFG_IDLE_LOOP_HOOK() {                                           \
-  /* Idle loop code here.*/                                                 \
-}
-
-/**
- * @brief   System tick event hook.
- * @details This hook is invoked in the system tick handler immediately
- *          after processing the virtual timers queue.
- */
-#define CH_CFG_SYSTEM_TICK_HOOK() {                                         \
-  /* System tick event code here.*/                                         \
-}
-
-/**
- * @brief   System halt hook.
- * @details This hook is invoked in case to a system halting error before
- *          the system is halted.
- */
-#define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
-  /* System halt code here.*/                                               \
-}
-
-/**
- * @brief   Trace hook.
- * @details This hook is invoked each time a new record is written in the
- *          trace buffer.
- */
-#define CH_CFG_TRACE_HOOK(tep) {                                            \
-  /* Trace code here.*/                                                     \
-}
+// common definitions in aos_chconf.h
 
 /** @} */
 
 /*===========================================================================*/
 /**
- * @name Port specific settings
+ * @name Port-specific settings (override port settings defaulted in chcore.h).
  * @{
  */
 /*===========================================================================*/
@@ -710,13 +141,12 @@
  */
 /*===========================================================================*/
 
-/**
- * @brief   Flag to enable/disable floating point support in chprinf()
- */
-#define CHPRINTF_USE_FLOAT                  TRUE
+// common definitions in aos_chconf.h
 
 /** @} */
 
+#include <aos_chconf.h>
+
 #endif  /* CHCONF_H */
 
 /** @} */
diff --git a/modules/PowerManagement_1-1/halconf.h b/modules/PowerManagement_1-1/halconf.h
index ed81a78..21db907 100644
--- a/modules/PowerManagement_1-1/halconf.h
+++ b/modules/PowerManagement_1-1/halconf.h
@@ -30,151 +30,190 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef _HALCONF_H_
 #define _HALCONF_H_
 
+#define _CHIBIOS_HAL_CONF_
+#define _CHIBIOS_HAL_CONF_VER_6_0_
+
+#include "mcuconf.h"
+
 /**
  * @brief   Enables the PAL subsystem.
  */
 #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
-#define HAL_USE_PAL                 TRUE
+#define HAL_USE_PAL                         TRUE
 #endif
 
 /**
  * @brief   Enables the ADC subsystem.
  */
 #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
-#define HAL_USE_ADC                 TRUE
+#define HAL_USE_ADC                         TRUE
 #endif
 
 /**
  * @brief   Enables the CAN subsystem.
  */
 #if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
-#define HAL_USE_CAN                 TRUE
+#define HAL_USE_CAN                         TRUE
+#endif
+
+/**
+ * @brief   Enables the cryptographic subsystem.
+ */
+#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
+#define HAL_USE_CRY                         FALSE
 #endif
 
 /**
  * @brief   Enables the DAC subsystem.
  */
 #if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
-#define HAL_USE_DAC                 FALSE
+#define HAL_USE_DAC                         FALSE
 #endif
 
 /**
  * @brief   Enables the EXT subsystem.
  */
 #if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
-#define HAL_USE_EXT                 FALSE
+#define HAL_USE_EXT                         FALSE
 #endif
 
 /**
  * @brief   Enables the GPT subsystem.
  */
 #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT                 FALSE
+#define HAL_USE_GPT                         FALSE
 #endif
 
 /**
  * @brief   Enables the I2C subsystem.
  */
 #if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C                 TRUE
+#define HAL_USE_I2C                         TRUE
 #endif
 
 /**
  * @brief   Enables the I2S subsystem.
  */
 #if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
-#define HAL_USE_I2S                 FALSE
+#define HAL_USE_I2S                         FALSE
 #endif
 
 /**
  * @brief   Enables the ICU subsystem.
  */
 #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
-#define HAL_USE_ICU                 FALSE
+#define HAL_USE_ICU                         FALSE
 #endif
 
 /**
  * @brief   Enables the MAC subsystem.
  */
 #if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
-#define HAL_USE_MAC                 FALSE
+#define HAL_USE_MAC                         FALSE
 #endif
 
 /**
  * @brief   Enables the MMC_SPI subsystem.
  */
 #if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_MMC_SPI             FALSE
+#define HAL_USE_MMC_SPI                     FALSE
 #endif
 
 /**
  * @brief   Enables the PWM subsystem.
  */
 #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM                 TRUE
+#define HAL_USE_PWM                         TRUE
+#endif
+
+/**
+ * @brief   Enables the QSPI subsystem.
+ */
+#if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
+#define HAL_USE_QSPI                        FALSE
 #endif
 
 /**
  * @brief   Enables the RTC subsystem.
  */
 #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
-#define HAL_USE_RTC                 TRUE
+#define HAL_USE_RTC                         TRUE
 #endif
 
 /**
  * @brief   Enables the SDC subsystem.
  */
 #if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
-#define HAL_USE_SDC                 FALSE
+#define HAL_USE_SDC                         FALSE
 #endif
 
 /**
  * @brief   Enables the SERIAL subsystem.
  */
 #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL              TRUE
+#define HAL_USE_SERIAL                      TRUE
 #endif
 
 /**
  * @brief   Enables the SERIAL over USB subsystem.
  */
 #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL_USB          FALSE
+#define HAL_USE_SERIAL_USB                  FALSE
 #endif
 
 /**
  * @brief   Enables the SPI subsystem.
  */
 #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI                 TRUE
+#define HAL_USE_SPI                         TRUE
 #endif
 
 /**
  * @brief   Enables the UART subsystem.
  */
 #if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
-#define HAL_USE_UART                FALSE
+#define HAL_USE_UART                        FALSE
 #endif
 
 /**
  * @brief   Enables the USB subsystem.
  */
 #if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
-#define HAL_USE_USB                 FALSE
+#define HAL_USE_USB                         FALSE
 #endif
 
 /**
  * @brief   Enables the WDG subsystem.
  */
 #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
-#define HAL_USE_WDG                 FALSE
+#define HAL_USE_WDG                         FALSE
 #endif
 
 /**
  * @brief   Enables the QEI subsystem.
  */
 #if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
-#define HAL_USE_QEI                 FALSE
+#define HAL_USE_QEI                         FALSE
+#endif
+
+/*===========================================================================*/
+/* PAL driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
+#define PAL_USE_CALLBACKS                   TRUE
+#endif
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
+#define PAL_USE_WAIT                        FALSE
 #endif
 
 /*===========================================================================*/
@@ -186,7 +225,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
-#define ADC_USE_WAIT                TRUE
+#define ADC_USE_WAIT                        TRUE
 #endif
 
 /**
@@ -194,7 +233,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define ADC_USE_MUTUAL_EXCLUSION    FALSE
+#define ADC_USE_MUTUAL_EXCLUSION            FALSE
 #endif
 
 /*===========================================================================*/
@@ -205,7 +244,56 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Sleep mode related APIs inclusion switch.
  */
 #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
-#define CAN_USE_SLEEP_MODE          FALSE
+#define CAN_USE_SLEEP_MODE                  FALSE
+#endif
+
+/**
+ * @brief   Enforces the driver to use direct callbacks rather than OSAL events.
+ */
+#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
+#define CAN_ENFORCE_USE_CALLBACKS           FALSE
+#endif
+
+/*===========================================================================*/
+/* CRY driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables the SW fall-back of the cryptographic driver.
+ * @details When enabled, this option, activates a fall-back software
+ *          implementation for algorithms not supported by the underlying
+ *          hardware.
+ * @note    Fall-back implementations may not be present for all algorithms.
+ */
+#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
+#define HAL_CRY_USE_FALLBACK                FALSE
+#endif
+
+/**
+ * @brief   Makes the driver forcibly use the fall-back implementations.
+ */
+#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
+#define HAL_CRY_ENFORCE_FALLBACK            FALSE
+#endif
+
+/*===========================================================================*/
+/* DAC driver related settings.                                              */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
+#define DAC_USE_WAIT                        TRUE
+#endif
+
+/**
+ * @brief   Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define DAC_USE_MUTUAL_EXCLUSION            TRUE
 #endif
 
 /*===========================================================================*/
@@ -216,7 +304,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @brief   Enables the mutual exclusion APIs on the I2C bus.
  */
 #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define I2C_USE_MUTUAL_EXCLUSION    TRUE
+#define I2C_USE_MUTUAL_EXCLUSION            TRUE
 #endif
 
 /*===========================================================================*/
@@ -224,17 +312,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /*===========================================================================*/
 
 /**
- * @brief   Enables an event sources for incoming packets.
+ * @brief   Enables the zero-copy API.
  */
 #if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
-#define MAC_USE_ZERO_COPY           FALSE
+#define MAC_USE_ZERO_COPY                   FALSE
 #endif
 
 /**
  * @brief   Enables an event sources for incoming packets.
  */
 #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
-#define MAC_USE_EVENTS              FALSE
+#define MAC_USE_EVENTS                      FALSE
 #endif
 
 /*===========================================================================*/
@@ -250,7 +338,27 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          use a DMA channel and heavily loads the CPU.
  */
 #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
-#define MMC_NICE_WAITING            FALSE
+#define MMC_NICE_WAITING                    FALSE
+#endif
+
+/*===========================================================================*/
+/* QSPI driver related settings.                                             */
+/*===========================================================================*/
+
+/**
+ * @brief   Enables synchronous APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(QSPI_USE_WAIT) || defined(__DOXYGEN__)
+#define QSPI_USE_WAIT                       TRUE
+#endif
+
+/**
+ * @brief   Enables the @p qspiAcquireBus() and @p qspiReleaseBus() APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(QSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define QSPI_USE_MUTUAL_EXCLUSION           TRUE
 #endif
 
 /*===========================================================================*/
@@ -262,7 +370,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Attempts are performed at 10mS intervals.
  */
 #if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
-#define SDC_INIT_RETRY              100
+#define SDC_INIT_RETRY                      100
 #endif
 
 /**
@@ -271,7 +379,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          at @p FALSE.
  */
 #if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
-#define SDC_MMC_SUPPORT             FALSE
+#define SDC_MMC_SUPPORT                     FALSE
 #endif
 
 /**
@@ -281,7 +389,21 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          lower priority, this may slow down the driver a bit however.
  */
 #if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
-#define SDC_NICE_WAITING            FALSE
+#define SDC_NICE_WAITING                    FALSE
+#endif
+
+/**
+ * @brief   OCR initialization constant for V20 cards.
+ */
+#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
+#define SDC_INIT_OCR_V20                    0x50FF8000U
+#endif
+
+/**
+ * @brief   OCR initialization constant for non-V20 cards.
+ */
+#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
+#define SDC_INIT_OCR                        0x80100000U
 #endif
 
 /*===========================================================================*/
@@ -294,7 +416,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          default configuration.
  */
 #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
-#define SERIAL_DEFAULT_BITRATE      115200
+#define SERIAL_DEFAULT_BITRATE              115200
 #endif
 
 /**
@@ -305,7 +427,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          buffers.
  */
 #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_BUFFERS_SIZE         16
+#define SERIAL_BUFFERS_SIZE                 16
 #endif
 
 /*===========================================================================*/
@@ -320,7 +442,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          buffers.
  */
 #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_SIZE     256
+#define SERIAL_USB_BUFFERS_SIZE             256
 #endif
 
 /**
@@ -328,7 +450,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    The default is 2 buffers.
  */
 #if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
-#define SERIAL_USB_BUFFERS_NUMBER   2
+#define SERIAL_USB_BUFFERS_NUMBER           2
 #endif
 
 /*===========================================================================*/
@@ -340,15 +462,32 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
-#define SPI_USE_WAIT                TRUE
+#define SPI_USE_WAIT                        TRUE
 #endif
 
 /**
+ * @brief   Enables circular transfers APIs.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
+#define SPI_USE_CIRCULAR                    FALSE
+#endif
+
+
+/**
  * @brief   Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define SPI_USE_MUTUAL_EXCLUSION    TRUE
+#define SPI_USE_MUTUAL_EXCLUSION            TRUE
+#endif
+
+/**
+ * @brief   Handling method for SPI CS line.
+ * @note    Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
+#define SPI_SELECT_MODE                     SPI_SELECT_MODE_PAD
 #endif
 
 /*===========================================================================*/
@@ -360,7 +499,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
-#define UART_USE_WAIT               FALSE
+#define UART_USE_WAIT                       FALSE
 #endif
 
 /**
@@ -368,7 +507,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define UART_USE_MUTUAL_EXCLUSION   FALSE
+#define UART_USE_MUTUAL_EXCLUSION           FALSE
 #endif
 
 /*===========================================================================*/
@@ -380,7 +519,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * @note    Disabling this option saves both code and data space.
  */
 #if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
-#define USB_USE_WAIT                FALSE
+#define USB_USE_WAIT                        FALSE
 #endif
 
 #endif /* _HALCONF_H_ */
diff --git a/modules/PowerManagement_1-1/mcuconf.h b/modules/PowerManagement_1-1/mcuconf.h
index fd198b9..b09231c 100644
--- a/modules/PowerManagement_1-1/mcuconf.h
+++ b/modules/PowerManagement_1-1/mcuconf.h
@@ -74,6 +74,24 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_BKPRAM_ENABLE                 FALSE
 
 /*
+ * EXT driver system settings.
+ */
+#define STM32_IRQ_EXTI0_PRIORITY            6
+#define STM32_IRQ_EXTI1_PRIORITY            6
+#define STM32_IRQ_EXTI2_PRIORITY            6
+#define STM32_IRQ_EXTI3_PRIORITY            6
+#define STM32_IRQ_EXTI4_PRIORITY            6
+#define STM32_IRQ_EXTI5_9_PRIORITY          6
+#define STM32_IRQ_EXTI10_15_PRIORITY        6
+#define STM32_IRQ_EXTI16_PRIORITY           6
+#define STM32_IRQ_EXTI17_PRIORITY           15
+#define STM32_IRQ_EXTI18_PRIORITY           6
+#define STM32_IRQ_EXTI19_PRIORITY           6
+#define STM32_IRQ_EXTI20_PRIORITY           6
+#define STM32_IRQ_EXTI21_PRIORITY           15
+#define STM32_IRQ_EXTI22_PRIORITY           15
+
+/*
  * ADC driver system settings.
  */
 #define STM32_ADC_ADCPRE                    ADC_CCR_ADCPRE_DIV4
@@ -113,24 +131,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_DAC_DAC1_CH2_DMA_STREAM       STM32_DMA_STREAM_ID(1, 6)
 
 /*
- * EXT driver system settings.
- */
-#define STM32_EXT_EXTI0_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI1_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI2_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI3_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI4_IRQ_PRIORITY        6
-#define STM32_EXT_EXTI5_9_IRQ_PRIORITY      6
-#define STM32_EXT_EXTI10_15_IRQ_PRIORITY    6
-#define STM32_EXT_EXTI16_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI17_IRQ_PRIORITY       15
-#define STM32_EXT_EXTI18_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI19_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI20_IRQ_PRIORITY       6
-#define STM32_EXT_EXTI21_IRQ_PRIORITY       15
-#define STM32_EXT_EXTI22_IRQ_PRIORITY       15
-
-/*
  * GPT driver system settings.
  */
 #define STM32_GPT_USE_TIM1                  FALSE
@@ -178,7 +178,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define STM32_I2C_I2C2_DMA_PRIORITY         3
 #define STM32_I2C_I2C3_DMA_PRIORITY         3
 #define STM32_I2C_DMA_ERROR_HOOK(i2cp)      osalSysHalt("DMA failure")
-#define STM32_I2C_USE_DMA                   TRUE
 
 /*
  * I2S driver system settings.
diff --git a/modules/PowerManagement_1-1/module.c b/modules/PowerManagement_1-1/module.c
index 2c0146b..1fa2112 100644
--- a/modules/PowerManagement_1-1/module.c
+++ b/modules/PowerManagement_1-1/module.c
@@ -18,26 +18,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "module.h"
 
+#include <amiroos.h>
+
 /*===========================================================================*/
 /**
  * @name Module specific functions
  * @{
  */
 /*===========================================================================*/
-#include <amiroos.h>
-
-/**
- * @brief   Interrupt service routine callback for I/O interrupt signals.
- *
- * @param   args      Channel on which the interrupt was encountered.
- */
-static void _modulePalIsrCallback(void *args) {
-  chSysLockFromISR();
-  chEvtBroadcastFlagsI(&aos.events.io, (1 << (*(uint16_t*)args)));
-  chSysUnlockFromISR();
-
-  return;
-}
 
 /** @} */
 
@@ -69,126 +57,6 @@ CANConfig moduleHalCanConfig = {
   /* btr  */ CAN_BTR_SJW(1) | CAN_BTR_TS2(3) | CAN_BTR_TS1(15) | CAN_BTR_BRP(1),
 };
 
-aos_interrupt_cfg_t moduleIntConfig[14] = {
-    /* channel  1 */ { // IR_INT1_N: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_IR_INT1_N,
-      /* flags    */ 0,
-      /* mode     */ APAL2CH_EDGE(VCNL4020_LLD_INT_EDGE),
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 1,
-    },
-    /* channel  2 */ { // GAUGE_BATLOW1: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_GAUGE_BATLOW1,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_RISING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 2,
-    },
-    /* channel  3 */ { // GAUGE_BATGD1_N: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_GAUGE_BATGD1_N,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_RISING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 3,
-    },
-    /* channel  4 */ { // SYS_UART_DN: automatic interrupt on event
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_SYS_UART_DN,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 4,
-    },
-    /* channel  5 */ { // IR_INT2_N: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_IR_INT2_N,
-      /* flags    */ 0,
-      /* mode     */ APAL2CH_EDGE(VCNL4020_LLD_INT_EDGE),
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 5,
-    },
-    /* channel  6 */ { // TOUCH_INT: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_TOUCH_INT_N,
-      /* flags    */ 0,
-      /* mode     */ APAL2CH_EDGE(MPR121_LLD_INT_EDGE),
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 6,
-    },
-    /* channel  7 */ { // GAUGE_BATLOW2: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_GAUGE_BATLOW2,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_RISING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 7,
-    },
-    /* channel  8 */ { // GAUGE_BATGD2_N: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_GAUGE_BATGD2_N,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_RISING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 8,
-    },
-    /* channel  9 */ { // PATH_DC: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_PATH_DC,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 9,
-    },
-    /* channel 10 */ { // SYS_SPI_DIR: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_SYS_SPI_DIR,
-      /* flags    */ 0,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 10,
-    },
-    /* channel 11 */ { // SYS_SYNC_N: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_SYS_INT_N, // TODO: check this
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 11,
-    },
-    /* channel 12 */ { // SYS_PD_N: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_SYS_PD_N,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_FALLING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 12,
-    },
-    /* channel 13 */ { // SYS_WARMRST_N: must be enabled explicitely
-      /* port     */ GPIOC,
-      /* pad      */ GPIOC_SYS_WARMRST_N,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_FALLING_EDGE,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 13,
-    },
-    /* channel 14 */ { // SYS_UART_UP: must be enabled explicitely
-      /* port     */ GPIOB,
-      /* pad      */ GPIOB_SYS_UART_UP,
-      /* flags    */ AOS_INTERRUPT_AUTOSTART,
-      /* mode     */ PAL_EVENT_MODE_BOTH_EDGES,
-      /* callback */ _modulePalIsrCallback,
-      /* cb arg   */ 14,
-    },
-};
-
-aos_interrupt_driver_t moduleIntDriver = {
-  /* config     */ NULL,
-  /* interrupts */ 14,
-};
-
 I2CConfig moduleHalI2cProxPm18Pm33GaugeRearConfig = {
   /* I²C mode   */ OPMODE_I2C,
   /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
@@ -246,125 +114,389 @@ SerialConfig moduleHalProgIfConfig = {
  */
 /*===========================================================================*/
 
-apalGpio_t moduleGpioSysRegEn = {
+/**
+ * @brief   SYS_REG_EN output signal GPIO.
+ */
+static apalGpio_t _gpioSysRegEn = {
   /* port */ GPIOA,
   /* pad  */ GPIOA_SYS_REG_EN,
 };
+apalControlGpio_t moduleSysRegEn = {
+  /* GPIO */ &_gpioSysRegEn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioIrInt1 = {
+/**
+ * @brief   IR_INT1 input signal GPIO.
+ */
+static apalGpio_t _gpioIrInt1 = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_IR_INT1_N,
 };
+apalControlGpio_t moduleGpioIrInt1 = {
+  /* GPIO */ &_gpioIrInt1,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
+  },
+};
 
-apalGpio_t moduleGpioPowerEn = {
+/**
+ * @brief   POWER_EN output signal GPIO.
+ */
+static apalGpio_t _gpioPowerEn = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_POWER_EN,
 };
+apalControlGpio_t moduleGpioPowerEn = {
+  /* GPIO */ &_gpioPowerEn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioSysUartDn = {
+/**
+ * @brief   SYS_UART_DN bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysUartDn = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_SYS_UART_DN,
 };
+apalControlGpio_t moduleGpioSysUartDn = {
+  /* GPIO */ &_gpioSysUartDn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioChargeStat2A = {
+/**
+ * @brief   CHARGE_STAT2A input signal GPIO.
+ */
+static apalGpio_t _gpioChargeStat2A = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_CHARGE_STAT2A,
 };
+apalControlGpio_t moduleGpioChargeStat2A = {
+  /* GPIO */ &_gpioChargeStat2A,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ BQ24103A_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioGaugeBatLow2 = {
+/**
+ * @brief   GAUGE_BATLOW2 input signal GPIO.
+ */
+static apalGpio_t _gpioGaugeBatLow2 = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_GAUGE_BATLOW2,
 };
+apalControlGpio_t moduleGpioGaugeBatLow2 = {
+  /* GPIO */ &_gpioGaugeBatLow2,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioGaugeBatGd2 = {
+/**
+ * @brief   GAUGE_BATGD2 input signal GPIO.
+ */
+static apalGpio_t _gpioGaugeBatGd2 = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_GAUGE_BATGD2_N,
 };
+apalControlGpio_t moduleGpioGaugeBatGd2 = {
+  /* GPIO */ &_gpioGaugeBatGd2,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioLed = {
+/**
+ * @brief   LED output signal GPIO.
+ */
+static apalGpio_t _gpioLed = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_LED,
 };
+apalControlGpio_t moduleGpioLed = {
+  /* GPIO */ &_gpioLed,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ LED_LLD_GPIO_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioSysUartUp = {
+/**
+ * @brief   SYS_UART_UP bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysUartUp = {
   /* port */ GPIOB,
   /* pad  */ GPIOB_SYS_UART_UP,
 };
+apalControlGpio_t moduleGpioSysUartUp = {
+  /* GPIO */ &_gpioSysUartUp,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioChargeStat1A = {
+/**
+ * @brief   CHARGE_STAT1A input signal GPIO.
+ */
+static apalGpio_t _gpioChargeStat1A = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_CHARGE_STAT1A,
 };
+apalControlGpio_t moduleGpioChargeStat1A = {
+  /* GPIO */ &_gpioChargeStat1A,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ BQ24103A_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioGaugeBatLow1 = {
+/**
+ * @brief   GAUGE_BATLOW1 input signal GPIO.
+ */
+static apalGpio_t _gpioGaugeBatLow1 = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_GAUGE_BATLOW1,
 };
+apalControlGpio_t moduleGpioGaugeBatLow1 = {
+  /* GPIO */ &_gpioGaugeBatLow1,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioGaugeBatGd1 = {
+/**
+ * @brief   GAUGE_BATGD1 input signal GPIO.
+ */
+static apalGpio_t _gpioGaugeBatGd1 = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_GAUGE_BATGD1_N,
 };
+apalControlGpio_t moduleGpioGaugeBatGd1 = {
+  /* GPIO */ &_gpioGaugeBatGd1,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioChargeEn1 = {
+/**
+ * @brief   CHARG_EN1 output signal GPIO.
+ */
+static apalGpio_t _gpioChargeEn1 = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_CHARGE_EN1_N,
 };
+apalControlGpio_t moduleGpioChargeEn1 = {
+  /* GPIO */ &_gpioChargeEn1,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ BQ24103A_LLD_ENABLED_GPIO_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioIrInt2 = {
+/**
+ * @brief   IR_INT2 input signal GPIO.
+ */
+static apalGpio_t _gpioIrInt2 = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_IR_INT2_N,
 };
+apalControlGpio_t moduleGpioIrInt2 = {
+  /* GPIO */ &_gpioIrInt2,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
+  },
+};
 
-apalGpio_t moduleGpioTouchInt = {
+/**
+ * @brief   TOUCH_INT input signal GPIO.
+ */
+static apalGpio_t _gpioTouchInt = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_TOUCH_INT_N,
 };
+apalControlGpio_t moduleGpioTouchInt = {
+  /* GPIO */ &_gpioTouchInt,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ MPR121_LLD_INT_EDGE,
+  },
+};
 
-apalGpio_t moduleGpioSysDone = {
+/**
+ * @brief   SYS_DONE input signal GPIO.
+ */
+static apalGpio_t _gpioSysDone = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_DONE,
 };
+apalControlGpio_t moduleGpioSysDone = {
+  /* GPIO */ &_gpioSysDone,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioSysProg = {
+/**
+ * @brief   SYS_PROG output signal GPIO.
+ */
+static apalGpio_t _gpioSysProg = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_PROG_N,
 };
+apalControlGpio_t moduleGpioSysProg = {
+  /* GPIO */ &_gpioSysProg,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioPathDc = {
+/**
+ * @brief   PATH_DC input signal GPIO.
+ */
+static apalGpio_t _gpioPathDc = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_PATH_DC,
 };
+apalControlGpio_t moduleGpioPathDc = {
+  /* GPIO */ &_gpioPathDc,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioSysSpiDir = {
+/**
+ * @brief   SYS_SPI_DIR bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysSpiDir = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_SPI_DIR,
 };
+apalControlGpio_t moduleGpioSysSpiDir = {
+  /* GPIO */ &_gpioSysSpiDir,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_FALLING,
+  },
+};
 
-apalGpio_t moduleGpioSysSync = {
+/**
+ * @brief   SYS_SYNC bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysSync = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_INT_N,
 };
+apalControlGpio_t moduleGpioSysSync = {
+  /* GPIO */ &_gpioSysSync,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioSysPd = {
+/**
+ * @brief   SYS_PD bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysPd = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_PD_N,
 };
+apalControlGpio_t moduleGpioSysPd = {
+  /* GPIO */ &_gpioSysPd,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioSysWarmrst = {
+/**
+ * @brief   SYS_WARMRST bidirectional signal GPIO.
+ */
+static apalGpio_t _gpioSysWarmrst = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_SYS_WARMRST_N,
 };
+apalControlGpio_t moduleGpioSysWarmrst = {
+  /* GPIO */ &_gpioSysWarmrst,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
+  },
+};
 
-apalGpio_t moduleGpioBtRst = {
+/**
+ * @brief   BT_RST output signal GPIO.
+ */
+static apalGpio_t _gpioBtRst = {
   /* port */ GPIOC,
   /* pad  */ GPIOC_BT_RST,
 };
+apalControlGpio_t moduleGpioBtRst = {
+  /* GPIO */ &_gpioBtRst,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
-apalGpio_t moduleGpioChargeEn2 = {
+/**
+ * @brief   CHARGE_EN2 output signal GPIO.
+ */
+static apalGpio_t _gpioChargeEn2 = {
   /* port */ GPIOD,
   /* pad  */ GPIOD_CHARGE_EN2_N,
 };
+apalControlGpio_t moduleGpioChargeEn2 = {
+  /* GPIO */ &_gpioChargeEn2,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ BQ24103A_LLD_ENABLED_GPIO_ACTIVE_STATE,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
 
 /** @} */
 
@@ -388,42 +520,6 @@ const char* moduleShellPrompt = "PowerManagement";
  */
 /*===========================================================================*/
 
-apalControlGpio_t moduleSsspGpioPd = {
-  /* GPIO */ &moduleGpioSysPd,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
-apalControlGpio_t moduleSsspGpioSync = {
-  /* GPIO */ &moduleGpioSysSync,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
-apalControlGpio_t moduleSsspGpioDn = {
-  /* GPIO */ &moduleGpioSysUartDn,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
-apalControlGpio_t moduleSsspGpioUp = {
-  /* GPIO */ &moduleGpioSysUartUp,
-  /* meta */ {
-    /* active state */ APAL_GPIO_ACTIVE_LOW,
-    /* edge         */ APAL_GPIO_EDGE_FALLING,
-    /* direction    */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
-  },
-};
-
 /** @} */
 
 /*===========================================================================*/
@@ -439,81 +535,25 @@ AT24C01BNDriver moduleLldEeprom = {
 };
 
 BQ24103ADriver moduleLldBatteryChargerFront = {
-  /* charge enable GPIO */ {
-    /* GPIO */ &moduleGpioChargeEn1,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
-  /* charge status GPIO */ {
-    /* GPIO */ &moduleGpioChargeStat1A,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_INPUT,
-    },
-  },
+  /* charge enable GPIO */ &moduleGpioChargeEn1,
+  /* charge status GPIO */ &moduleGpioChargeStat1A,
 };
 
 BQ24103ADriver moduleLldBatteryChargerRear = {
-  /* charge enable GPIO */ {
-    /* GPIO */ &moduleGpioChargeEn2,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
-  /* charge status GPIO */ {
-    /* GPIO */ &moduleGpioChargeStat2A,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_INPUT,
-    },
-  },
+  /* charge enable GPIO */ &moduleGpioChargeEn2,
+  /* charge status GPIO */ &moduleGpioChargeStat2A,
 };
 
 BQ27500Driver moduleLldFuelGaugeFront = {
-  /* I2C driver       */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
-  /* battery low GPIO */ {
-    /* GPIO */ &moduleGpioGaugeBatLow1,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_HIGH,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_INPUT,
-    },
-  },
-  /* battery good GPIO */ {
-    /* GPIO */ &moduleGpioGaugeBatGd1,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_INPUT,
-    },
-  },
+  /* I2C driver         */ &MODULE_HAL_I2C_PROX_PM42_PM50_PMVDD_EEPROM_TOUCH_GAUGEFRONT,
+  /* battery low GPIO   */ &moduleGpioGaugeBatLow1,
+  /* battery good GPIO  */ &moduleGpioGaugeBatGd1,
 };
 
 BQ27500Driver moduleLldFuelGaugeRear = {
-  /* I2C driver       */ &MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR,
-  /* battery low GPIO */ {
-    /* GPIO */ &moduleGpioGaugeBatLow2,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_HIGH,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_INPUT,
-    },
-  },
-  /* battery good GPIO */ {
-    /* GPIO */ &moduleGpioGaugeBatGd2,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_INPUT,
-    },
-  },
+  /* I2C driver         */ &MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR,
+  /* battery low GPIO   */ &moduleGpioGaugeBatLow2,
+  /* battery good GPIO  */ &moduleGpioGaugeBatGd2,
 };
 
 INA219Driver moduleLldPowerMonitorVdd = {
@@ -552,14 +592,7 @@ INA219Driver moduleLldPowerMonitorVio50 = {
 };
 
 LEDDriver moduleLldStatusLed = {
-  /* LED GPIO */ {
-    /* GPIO */ &moduleGpioLed,
-    /* meta */ {
-      /* active state */ APAL_GPIO_ACTIVE_LOW,
-      /* edge         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
+  /* LED GPIO */ &moduleGpioLed,
 };
 
 MPR121Driver moduleLldTouch = {
@@ -577,14 +610,7 @@ PCA9544ADriver moduleLldI2cMultiplexer2 = {
 };
 
 TPS62113Driver moduleLldStepDownConverter = {
-  /* Power enable GPIO */ {
-    /* GPIO       */ &moduleGpioPowerEn,
-    /* GPIO meta  */ {
-      /* active state */ APAL_GPIO_ACTIVE_HIGH,
-      /* egde         */ APAL_GPIO_EDGE_NONE,
-      /* direction    */ APAL_GPIO_DIRECTION_OUTPUT,
-    },
-  },
+  /* Power enable GPIO */ &moduleGpioPowerEn,
 };
 
 VCNL4020Driver moduleLldProximity1 = {
@@ -899,16 +925,14 @@ static int _utShellCmdCb_AlldMpr121(BaseSequentialStream* stream, int argc, char
 {
   (void)argc;
   (void)argv;
-  aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_TOUCHINT);
   aosUtRun(stream, &moduleUtAlldMpr121, NULL);
-  aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_TOUCHINT);
   return AOS_OK;
 }
 static ut_mpr121data_t _utAlldMpr121Data= {
   /* MPR121 driver  */ &moduleLldTouch,
   /* timeout        */ MICROSECONDS_PER_SECOND,
   /* event source   */ &aos.events.io,
-  /* event flags    */ (1 << MODULE_GPIO_INT_TOUCHINT),
+  /* event flags    */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
 };
 aos_unittest_t moduleUtAlldMpr121 = {
   /* name           */ "MPR121",
@@ -1082,8 +1106,7 @@ static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, ch
       case WNW:
         mux = &moduleLldI2cMultiplexer1;
         ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity1;
-        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = (1 << MODULE_GPIO_INT_IRINT2);
-        aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_IRINT2);
+        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2;
         break;
       case NNW:
       case NNE:
@@ -1091,8 +1114,7 @@ static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, ch
       case ESE:
         mux = &moduleLldI2cMultiplexer2;
         ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity2;
-        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = (1 << MODULE_GPIO_INT_IRINT1);
-        aosIntEnable(&moduleIntDriver, MODULE_GPIO_INT_IRINT1);
+        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1;
         break;
       default:
         break;
@@ -1109,42 +1131,34 @@ static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, ch
       case NNE:
         pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
         aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northeast sensor");
-        aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT1);
         break;
       case ENE:
         pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
         aosUtRun(stream, &moduleUtAlldVcnl4020, "east-northeast sensor");
-        aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT1);
         break;
       case ESE:
         pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
         aosUtRun(stream, &moduleUtAlldVcnl4020, "north-southeast sensor");
-        aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT1);
         break;
       case SSE:
         pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
         aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southeast sensor");
-        aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT2);
         break;
       case SSW:
         pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
         aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southwest sensor");
-        aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT2);
         break;
       case WSW:
         pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
         aosUtRun(stream, &moduleUtAlldVcnl4020, "west-southwest sensor");
-        aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT2);
         break;
       case WNW:
         pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
         aosUtRun(stream, &moduleUtAlldVcnl4020, "west-northwest sensor");
-        aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT2);
         break;
       case NNW:
         pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
         aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northwest sensor");
-        aosIntDisable(&moduleIntDriver, MODULE_GPIO_INT_IRINT1);
         break;
       default:
         break;
diff --git a/modules/PowerManagement_1-1/module.h b/modules/PowerManagement_1-1/module.h
index 6716029..f28e147 100644
--- a/modules/PowerManagement_1-1/module.h
+++ b/modules/PowerManagement_1-1/module.h
@@ -62,7 +62,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 /*===========================================================================*/
 #include <hal.h>
-#include <aos_interrupts.h>
 
 /**
  * @brief   ADC driver for reading the system voltage.
@@ -85,17 +84,6 @@ extern ADCConversionGroup moduleHalAdcVsysConversionGroup;
 extern CANConfig moduleHalCanConfig;
 
 /**
- * @brief   Interrupt driver (PAL).
- */
-
-extern aos_interrupt_driver_t moduleIntDriver;
-
-/**
- * @brief   Interrupt driver config.
- */
-extern aos_interrupt_cfg_t moduleIntConfig[14];
-
-/**
  * @brief   I2C driver to access multiplexer, proximity sensors 1 to 4, power monitors for VIO1.8 and VIO 3.3, and fuel gauge (rear battery).
  */
 #define MODULE_HAL_I2C_PROX_PM18_PM33_GAUGEREAR I2CD1
@@ -156,194 +144,124 @@ extern SerialConfig moduleHalProgIfConfig;
 #include <amiro-lld.h>
 
 /**
- * @brief   Interrupt channel for the IR_INT1 and CHARGE_STAT1A signals.
- */
-#define MODULE_GPIO_INT_IRINT1           ((uint8_t)1)
-
-/**
- * @brief   Interrupt channel for the GAUGE_BATLOW1 signal.
- */
-#define MODULE_GPIO_INT_GAUGEBATLOW1     ((uint8_t)2)
-
-/**
- * @brief   Interrupt channel for the GAUGE_BATGD1 signal.
- */
-#define MODULE_GPIO_INT_GAUGEBATGD1      ((uint8_t)3)
-
-/**
- * @brief   Interrupt channel for the SYS_UART_DN signal.
- */
-#define MODULE_GPIO_INT_SYSUARTDN        ((uint8_t)4)
-
-/**
- * @brief   Interrupt channel for the IR_INT2 and CHARGE_STAT2A signals.
- */
-#define MODULE_GPIO_INT_IRINT2           ((uint8_t)5)
-
-/**
- * @brief   Interrupt channel for the TOUCH_INT signal.
- */
-#define MODULE_GPIO_INT_TOUCHINT         ((uint8_t)6)
-
-/**
- * @brief   Interrupt channel for the GAUGE_BATLOW2 signal.
- */
-#define MODULE_GPIO_INT_GAUGEBATLOW2     ((uint8_t)7)
-
-/**
- * @brief   Interrupt channel for the GAUGE_BATGD2 signal.
- */
-#define MODULE_GPIO_INT_GAUGEBATGD2      ((uint8_t)8)
-
-/**
- * @brief   Interrupt channel for the PATH_DC signal.
- */
-#define MODULE_GPIO_INT_PATHDC           ((uint8_t)9)
-
-/**
- * @brief   Interrupt channel for the SYS_SPI_DIR signal.
- */
-#define MODULE_GPIO_INT_SYSSPIDIR        ((uint8_t)10)
-
-/**
- * @brief   Interrupt channel for the SYS_SYNC signal.
- */
-#define MODULE_GPIO_INT_SYSSYNC          ((uint8_t)11)
-
-/**
- * @brief   Interrupt channel for the SYS_PD signal.
- */
-#define MODULE_GPIO_INT_SYSPD            ((uint8_t)12)
-
-/**
- * @brief   Interrupt channel for the SYS_WARMRST signal.
- */
-#define MODULE_GPIO_INT_SYSWARMRST       ((uint8_t)13)
-
-/**
- * @brief   Interrupt channel for the SYS_UART_UP signal.
- */
-#define MODULE_GPIO_INT_SYSUARTUP        ((uint8_t)14)
-
-/**
  * @brief   SYS_REG_EN output signal GPIO.
  */
-extern apalGpio_t moduleGpioSysRegEn;
+extern apalControlGpio_t moduleGpioSysRegEn;
 
 /**
  * @brief   IR_INT1 input signal GPIO.
  */
-extern apalGpio_t moduleGpioIrInt1;
+extern apalControlGpio_t moduleGpioIrInt1;
 
 /**
  * @brief   POWER_EN output signal GPIO.
  */
-extern apalGpio_t moduleGpioPowerEn;
+extern apalControlGpio_t moduleGpioPowerEn;
 
 /**
  * @brief   SYS_UART_DN bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysUartDn;
+extern apalControlGpio_t moduleGpioSysUartDn;
 
 /**
  * @brief   CHARGE_STAT2A input signal GPIO.
  */
-extern apalGpio_t moduleGpioChargeStat2A;
+extern apalControlGpio_t moduleGpioChargeStat2A;
 
 /**
  * @brief   GAUGE_BATLOW2 input signal GPIO.
  */
-extern apalGpio_t moduleGpioGaugeBatLow2;
+extern apalControlGpio_t moduleGpioGaugeBatLow2;
 
 /**
  * @brief   GAUGE_BATGD2 input signal GPIO.
  */
-extern apalGpio_t moduleGpioGaugeBatGd2;
+extern apalControlGpio_t moduleGpioGaugeBatGd2;
 
 /**
  * @brief   LED output signal GPIO.
  */
-extern apalGpio_t moduleGpioLed;
+extern apalControlGpio_t moduleGpioLed;
 
 /**
  * @brief   SYS_UART_UP bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysUartUp;
+extern apalControlGpio_t moduleGpioSysUartUp;
 
 /**
  * @brief   CHARGE_STAT1A input signal GPIO.
  */
-extern apalGpio_t moduleGpioChargeStat1A;
+extern apalControlGpio_t moduleGpioChargeStat1A;
 
 /**
  * @brief   GAUGE_BATLOW1 input signal GPIO.
  */
-extern apalGpio_t moduleGpioGaugeBatLow1;
+extern apalControlGpio_t moduleGpioGaugeBatLow1;
 
 /**
  * @brief   GAUGE_BATGD1 input signal GPIO.
  */
-extern apalGpio_t moduleGpioGaugeBatGd1;
+extern apalControlGpio_t moduleGpioGaugeBatGd1;
 
 /**
  * @brief   CHARG_EN1 output signal GPIO.
  */
-extern apalGpio_t moduleGpioChargeEn1;
+extern apalControlGpio_t moduleGpioChargeEn1;
 
 /**
  * @brief   IR_INT2 input signal GPIO.
  */
-extern apalGpio_t moduleGpioIrInt2;
+extern apalControlGpio_t moduleGpioIrInt2;
 
 /**
  * @brief   TOUCH_INT input signal GPIO.
  */
-extern apalGpio_t moduleGpioTouchInt;
+extern apalControlGpio_t moduleGpioTouchInt;
 
 /**
  * @brief   SYS_DONE input signal GPIO.
  */
-extern apalGpio_t moduleGpioSysDone;
+extern apalControlGpio_t moduleGpioSysDone;
 
 /**
  * @brief   SYS_PROG output signal GPIO.
  */
-extern apalGpio_t moduleGpioSysProg;
+extern apalControlGpio_t moduleGpioSysProg;
 
 /**
  * @brief   PATH_DC input signal GPIO.
  */
-extern apalGpio_t moduleGpioPathDc;
+extern apalControlGpio_t moduleGpioPathDc;
 
 /**
  * @brief   SYS_SPI_DIR bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysSpiDir;
+extern apalControlGpio_t moduleGpioSysSpiDir;
 
 /**
  * @brief   SYS_SYNC bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysSync;
+extern apalControlGpio_t moduleGpioSysSync;
 
 /**
  * @brief   SYS_PD bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysPd;
+extern apalControlGpio_t moduleGpioSysPd;
 
 /**
  * @brief   SYS_WARMRST bidirectional signal GPIO.
  */
-extern apalGpio_t moduleGpioSysWarmrst;
+extern apalControlGpio_t moduleGpioSysWarmrst;
 
 /**
  * @brief   BT_RST output signal GPIO.
  */
-extern apalGpio_t moduleGpioBtRst;
+extern apalControlGpio_t moduleGpioBtRst;
 
 /**
  * @brief   CHARGE_EN2 output signal GPIO.
  */
-extern apalGpio_t moduleGpioChargeEn2;
+extern apalControlGpio_t moduleGpioChargeEn2;
 
 /** @} */
 
@@ -357,72 +275,72 @@ extern apalGpio_t moduleGpioChargeEn2;
 /**
  * @brief   Event flag to be set on a IR_INT1 / CHARGE_STAT1A interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_IRINT1           ((eventflags_t)1 << MODULE_GPIO_INT_IRINT1)
+#define MODULE_OS_IOEVENTFLAGS_IRINT1           ((eventflags_t)1 << GPIOB_IR_INT1_N)
 
 /**
  * @brief   Event flag to be set on a GAUGE_BATLOW1 interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW1     ((eventflags_t)1 << MODULE_GPIO_INT_GAUGEBATLOW1)
+#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW1     ((eventflags_t)1 << GPIOC_GAUGE_BATLOW1)
 
 /**
  * @brief   Event flag to be set on a GAUGE_BATGD1 interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD1      ((eventflags_t)1 << MODULE_GPIO_INT_GAUGEBATGD1)
+#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD1      ((eventflags_t)1 << GPIOC_GAUGE_BATGD1_N)
 
 /**
  * @brief   Event flag to be set on a SYS_UART_DN interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN        ((eventflags_t)1 << MODULE_GPIO_INT_SYSUARTDN)
+#define MODULE_OS_IOEVENTFLAGS_SYSUARTDN        ((eventflags_t)1 << GPIOB_SYS_UART_DN)
 
 /**
  * @brief   Event flag to be set on a IR_INT2 / CHARGE_STAT2A interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_IRINT2           ((eventflags_t)1 << MODULE_GPIO_INT_IRINT2)
+#define MODULE_OS_IOEVENTFLAGS_IRINT2           ((eventflags_t)1 << GPIOC_IR_INT2_N)
 
 /**
  * @brief   Event flag to be set on a TOUCH_INT interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_TOUCHINT         ((eventflags_t)1 << MODULE_GPIO_INT_TOUCHINT)
+#define MODULE_OS_IOEVENTFLAGS_TOUCHINT         ((eventflags_t)1 << GPIOC_TOUCH_INT_N)
 
 /**
  * @brief   Event flag to be set on a GAUGE_BATLOW2 interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW2     ((eventflags_t)1 << MODULE_GPIO_INT_GAUGEBATLOW2)
+#define MODULE_OS_IOEVENTFLAGS_GAUGEBATLOW2     ((eventflags_t)1 << GPIOB_GAUGE_BATLOW2)
 
 /**
  * @brief   Event flag to be set on a GAUGE_BATGD2 interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD2      ((eventflags_t)1 << MODULE_GPIO_INT_GAUGEBATGD2)
+#define MODULE_OS_IOEVENTFLAGS_GAUGEBATGD2      ((eventflags_t)1 << GPIOB_GAUGE_BATGD2_N)
 
 /**
  * @brief   Event flag to be set on a PATH_DC interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_PATHDC           ((eventflags_t)1 << MODULE_GPIO_INT_PATHDC)
+#define MODULE_OS_IOEVENTFLAGS_PATHDC           ((eventflags_t)1 << GPIOC_PATH_DC)
 
 /**
  * @brief   Event flag to be set on a SYS_SPI_DIR interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSSPIDIR        ((eventflags_t)1 << MODULE_GPIO_INT_SYSSPIDIR)
+#define MODULE_OS_IOEVENTFLAGS_SYSSPIDIR        ((eventflags_t)1 << GPIOC_SYS_SPI_DIR)
 
 /**
  * @brief   Event flag to be set on a SYS_SYNC interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)1 << MODULE_GPIO_INT_SYSSYNC)
+#define MODULE_OS_IOEVENTFLAGS_SYSSYNC          ((eventflags_t)1 << GPIOC_SYS_INT_N)
 
 /**
  * @brief   Event flag to be set on a SYS_PD interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)1 << MODULE_GPIO_INT_SYSPD)
+#define MODULE_OS_IOEVENTFLAGS_SYSPD            ((eventflags_t)1 << GPIOC_SYS_PD_N)
 
 /**
  * @brief   Event flag to be set on a SYS_WARMRST interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST       ((eventflags_t)1 << MODULE_GPIO_INT_SYSWARMRST)
+#define MODULE_OS_IOEVENTFLAGS_SYSWARMRST       ((eventflags_t)1 << GPIOC_SYS_WARMRST_N)
 
 /**
  * @brief   Event flag to be set on a SYS_UART_UP interrupt.
  */
-#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP        ((eventflags_t)1 << MODULE_GPIO_INT_SYSUARTUP)
+#define MODULE_OS_IOEVENTFLAGS_SYSUARTUP        ((eventflags_t)1 << GPIOB_SYS_UART_UP)
 
 #if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
 /**
@@ -432,6 +350,43 @@ extern const char* moduleShellPrompt;
 #endif
 
 /**
+ * @brief   Interrupt initialization macro.
+ * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
+ */
+#define MODULE_INIT_INTERRUPTS() {                                            \
+  /* IR_INT1 */                                                               \
+  palSetPadCallback(moduleGpioIrInt1.gpio->port, moduleGpioIrInt1.gpio->pad, _intCallback, &moduleGpioIrInt1.gpio->pad); \
+  palEnablePadEvent(moduleGpioIrInt1.gpio->port, moduleGpioIrInt1.gpio->pad, APAL2CH_EDGE(moduleGpioIrInt1.meta.edge));  \
+  /* GAUGE_BATLOW2 */                                                         \
+  palSetPadCallback(moduleGpioGaugeBatLow2.gpio->port, moduleGpioGaugeBatLow2.gpio->pad, _intCallback, &moduleGpioGaugeBatLow2.gpio->pad);  \
+  palEnablePadEvent(moduleGpioGaugeBatLow2.gpio->port, moduleGpioGaugeBatLow2.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatLow2.meta.edge));   \
+  /* GAUGE_BATGD2 */                                                          \
+  palSetPadCallback(moduleGpioGaugeBatGd2.gpio->port, moduleGpioGaugeBatGd2.gpio->pad, _intCallback, &moduleGpioGaugeBatGd2.gpio->pad); \
+  palEnablePadEvent(moduleGpioGaugeBatGd2.gpio->port, moduleGpioGaugeBatGd2.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatGd2.meta.edge));  \
+  /* GAUGE_BATLOW1 */                                                         \
+  palSetPadCallback(moduleGpioGaugeBatLow1.gpio->port, moduleGpioGaugeBatLow1.gpio->pad, _intCallback, &moduleGpioGaugeBatLow1.gpio->pad);  \
+  palEnablePadEvent(moduleGpioGaugeBatLow1.gpio->port, moduleGpioGaugeBatLow1.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatLow1.meta.edge));   \
+  /* GAUGE_BATGD1 */                                                          \
+  palSetPadCallback(moduleGpioGaugeBatGd1.gpio->port, moduleGpioGaugeBatGd1.gpio->pad, _intCallback, &moduleGpioGaugeBatGd1.gpio->pad); \
+  palEnablePadEvent(moduleGpioGaugeBatGd1.gpio->port, moduleGpioGaugeBatGd1.gpio->pad, APAL2CH_EDGE(moduleGpioGaugeBatGd1.meta.edge));  \
+  /* IR_INT1 */                                                               \
+  palSetPadCallback(moduleGpioIrInt2.gpio->port, moduleGpioIrInt2.gpio->pad, _intCallback, &moduleGpioIrInt1.gpio->pad); \
+  palEnablePadEvent(moduleGpioIrInt2.gpio->port, moduleGpioIrInt2.gpio->pad, APAL2CH_EDGE(moduleGpioIrInt1.meta.edge));  \
+  /* TOUCH_INT */                                                             \
+  palSetPadCallback(moduleGpioTouchInt.gpio->port, moduleGpioTouchInt.gpio->pad, _intCallback, &moduleGpioTouchInt.gpio->pad); \
+  palEnablePadEvent(moduleGpioTouchInt.gpio->port, moduleGpioTouchInt.gpio->pad, APAL2CH_EDGE(moduleGpioTouchInt.meta.edge));  \
+  /* PATH_DC */                                                               \
+  palSetPadCallback(moduleGpioPathDc.gpio->port, moduleGpioPathDc.gpio->pad, _intCallback, &moduleGpioPathDc.gpio->pad);  \
+  palEnablePadEvent(moduleGpioPathDc.gpio->port, moduleGpioPathDc.gpio->pad, APAL2CH_EDGE(moduleGpioPathDc.meta.edge));   \
+  /* SYS_SPI_DIR */                                                           \
+  palSetPadCallback(moduleGpioSysSpiDir.gpio->port, moduleGpioSysSpiDir.gpio->pad, _intCallback, &moduleGpioSysSpiDir.gpio->pad); \
+  palEnablePadEvent(moduleGpioSysSpiDir.gpio->port, moduleGpioSysSpiDir.gpio->pad, APAL2CH_EDGE(moduleGpioSysSpiDir.meta.edge));  \
+  /* SYS_WARMRST */                                                           \
+  palSetPadCallback(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, _intCallback, &moduleGpioSysWarmrst.gpio->pad);  \
+  palEnablePadEvent(moduleGpioSysWarmrst.gpio->port, moduleGpioSysWarmrst.gpio->pad, APAL2CH_EDGE(moduleGpioSysWarmrst.meta.edge));   \
+}
+
+/**
  * @brief   Unit test initialization hook.
  */
 #define MODULE_INIT_TESTS() {                                                 \
@@ -508,22 +463,22 @@ extern const char* moduleShellPrompt;
 /**
  * @brief   PD signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioPd;
+#define moduleSsspGpioPd                        moduleGpioSysPd
 
 /**
  * @brief   SYNC signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioSync;
+#define moduleSsspGpioSync                       moduleGpioSysSync
 
 /**
  * @brief   DN signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioDn;
+#define moduleSsspGpioDn                        moduleGpioSysUartDn
 
 /**
  * @brief   UP signal GPIO.
  */
-extern apalControlGpio_t moduleSsspGpioUp;
+#define moduleSsspGpioUp                        moduleGpioSysUartUp
 
 /**
  * @brief   Event flags for PD signal events.
diff --git a/modules/aos_chconf.h b/modules/aos_chconf.h
index 823a1e4..5e5204f 100644
--- a/modules/aos_chconf.h
+++ b/modules/aos_chconf.h
@@ -36,10 +36,48 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /*===========================================================================*/
 /**
  * @name System timers settings
+ * @{
  */
 /*===========================================================================*/
 
-// These settings are specific to each module.
+/**
+ * @brief   System tick frequency.
+ * @details Frequency of the system timer that drives the system ticks. This
+ *          setting also defines the system tick time unit.
+ */
+#if !defined(CH_CFG_ST_FREQUENCY)
+#define CH_CFG_ST_FREQUENCY                 1000000UL
+#endif
+
+/**
+ * @brief   Time intervals data size.
+ * @note    Allowed values are 16, 32 or 64 bits.
+ */
+#if !defined(CH_CFG_INTERVALS_SIZE)
+#define CH_CFG_INTERVALS_SIZE               32
+#endif
+
+/**
+ * @brief   Time types data size.
+ * @note    Allowed values are 16 or 32 bits.
+ */
+#if !defined(CH_CFG_TIME_TYPES_SIZE)
+#define CH_CFG_TIME_TYPES_SIZE              32
+#endif
+
+/**
+ * @brief   Time delta constant for the tick-less mode.
+ * @note    If this value is zero then the system uses the classic
+ *          periodic tick. This value represents the minimum number
+ *          of ticks that is safe to specify in a timeout directive.
+ *          The value one is not valid, timeouts are rounded up to
+ *          this value.
+ */
+#if !defined(CH_CFG_ST_TIMEDELTA)
+#define CH_CFG_ST_TIMEDELTA                 20
+#endif
+
+/** @} */
 
 /*===========================================================================*/
 /**
@@ -244,14 +282,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define CH_CFG_USE_MAILBOXES                FALSE
 
 /**
- * @brief   I/O Queues APIs.
- * @details If enabled then the I/O queues APIs are included in the kernel.
- *
- * @note    The default is @p TRUE.
- */
-#define CH_CFG_USE_QUEUES                   FALSE
-
-/**
  * @brief   Core Memory Manager APIs.
  * @details If enabled then the core memory manager APIs are included
  *          in the kernel.
@@ -282,6 +312,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define CH_CFG_USE_MEMPOOLS                 FALSE
 
 /**
+ * @brief  Objects FIFOs APIs.
+ * @details If enabled then the objects FIFOs APIs are included
+ *          in the kernel.
+ *
+ * @note    The default is @p TRUE.
+ */
+#if !defined(CH_CFG_USE_OBJ_FIFOS)
+#define CH_CFG_USE_OBJ_FIFOS                FALSE
+#endif
+
+/**
  * @brief   Dynamic Threads APIs.
  * @details If enabled then the dynamic threads creation APIs are included
  *          in the kernel.
@@ -296,6 +337,70 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 /*===========================================================================*/
 /**
+ * @name Objects factory options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief   Objects Factory APIs.
+ * @details If enabled then the objects factory APIs are included in the
+ *          kernel.
+ *
+ * @note    The default is @p FALSE.
+ */
+#if !defined(CH_CFG_USE_FACTORY)
+#define CH_CFG_USE_FACTORY                  FALSE
+#endif
+
+/**
+ * @brief   Maximum length for object names.
+ * @details If the specified length is zero then the name is stored by
+ *          pointer but this could have unintended side effects.
+ */
+#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
+#define CH_CFG_FACTORY_MAX_NAMES_LENGTH     8
+#endif
+
+/**
+ * @brief   Enables the registry of generic objects.
+ */
+#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
+#define CH_CFG_FACTORY_OBJECTS_REGISTRY     TRUE
+#endif
+
+/**
+ * @brief   Enables factory for generic buffers.
+ */
+#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
+#define CH_CFG_FACTORY_GENERIC_BUFFERS      TRUE
+#endif
+
+/**
+ * @brief   Enables factory for semaphores.
+ */
+#if !defined(CH_CFG_FACTORY_SEMAPHORES)
+#define CH_CFG_FACTORY_SEMAPHORES           TRUE
+#endif
+
+/**
+ * @brief   Enables factory for mailboxes.
+ */
+#if !defined(CH_CFG_FACTORY_MAILBOXES)
+#define CH_CFG_FACTORY_MAILBOXES            TRUE
+#endif
+
+/**
+ * @brief   Enables factory for objects FIFOs.
+ */
+#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
+#define CH_CFG_FACTORY_OBJ_FIFOS            TRUE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
  * @name Debug options
  * @{
  */
@@ -422,6 +527,22 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /*===========================================================================*/
 
 /**
+ * @brief   System structure extension.
+ * @details User fields added to the end of the @p ch_system_t structure.
+ */
+#define CH_CFG_SYSTEM_EXTRA_FIELDS                                          \
+  /* Add threads custom fields here.*/
+
+/**
+ * @brief   System initialization hook.
+ * @details User initialization code added to the @p chSysInit() function
+ *          just before interrupts are enabled globally.
+ */
+#define CH_CFG_SYSTEM_INIT_HOOK() {                                         \
+  /* Add threads initialization code here.*/                                \
+}
+
+/**
  * @brief   Threads descriptor structure extension.
  * @details User fields added to the end of the @p thread_t structure.
  */
@@ -430,9 +551,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
  * @brief   Threads initialization hook.
- * @details User initialization code added to the @p chThdInit() API.
+ * @details User initialization code added to the @p _thread_init() function.
  *
- * @note    It is invoked from within @p chThdInit() and implicitly from all
+ * @note    It is invoked from within @p _thread_init() and implicitly from all
  *          the threads creation APIs.
  */
 #define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
@@ -442,10 +563,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * @brief   Threads finalization hook.
  * @details User finalization code added to the @p chThdExit() API.
- *
- * @note    It is inserted into lock zone.
- * @note    It is also invoked when the threads simply return in order to
- *          terminate.
  */
 #define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
   /* Add threads finalization code here.*/                                  \
@@ -516,8 +633,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *          the system is halted.
  */
 #define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
-  extern void aosPrintHaltErrorCode(const char* reason);                       \
-  aosPrintHaltErrorCode(reason);                                               \
+  extern void aosPrintHaltErrorCode(const char* reason);                    \
+  aosPrintHaltErrorCode(reason);                                            \
 }
 
 /**
@@ -547,7 +664,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /*===========================================================================*/
 
 /**
- * @brief   Flag to enable/disable floating point support in chprinf()
+ * @brief   Flag to enable/disable floating point support in chprintf() and all deriviates.
  */
 #define CHPRINTF_USE_FLOAT                  TRUE
 
diff --git a/os/core/core.mk b/os/core/core.mk
index ea94bd8..9bc01a8 100644
--- a/os/core/core.mk
+++ b/os/core/core.mk
@@ -37,8 +37,7 @@ AMIROOSCORECSRC = $(AMIROOS_CORE_DIR)src/aos_debug.c \
                   $(AMIROOS_CORE_DIR)src/aos_thread.c \
                   $(AMIROOS_CORE_DIR)src/aos_time.c \
                   $(AMIROOS_CORE_DIR)src/aos_timer.c \
-                  $(AMIROOS_CORE_DIR)src/aos_unittest.c \
-                  $(AMIROOS_CORE_DIR)src/aos_interrupts.c \
+                  $(AMIROOS_CORE_DIR)src/aos_unittest.c
 
 # C++ source files
 AMIROOSCORECPPSRC = $(AMIROOS_CORE_DIR)src/aos_main.cpp
diff --git a/os/core/inc/aos_interrupts.h b/os/core/inc/aos_interrupts.h
deleted file mode 100644
index cd5075c..0000000
--- a/os/core/inc/aos_interrupts.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
-Copyright (C) 2016..2018  Thomas Schöpping et al.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY) without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/.
-*/
-
-#ifndef _AMIROOS_INTERRUPTS_H_
-#define _AMIROOS_INTERRUPTS_H_
-
-#include <hal.h>
-
-/**
- * @brief   Interrupt configuration flag to autostart the interrupt when the interrupt system is started.
- */
-#define AOS_INTERRUPT_AUTOSTART 0x1u
-
-/**
- * @brief   Interrupt configuration structure.
- */
-typedef struct {
-  ioportid_t    port;      /**< Gpio port id. */
-  uint8_t       pad;       /**< Gpio pad.     */
-  uint8_t       flags;     /**< Interrupt configuration flags. */
-  uint8_t       eventmode; /**< Pal event mode. */
-  palcallback_t cb;        /**< Pal callback function. */
-  uint8_t       cb_arg;    /**< Argument for the callback function. */
-} aos_interrupt_cfg_t;
-
-/**
- * @brief   Interrupt driver structure.
- */
-typedef struct {
-  aos_interrupt_cfg_t *interrupts; /**< Array of interrupt configurations. */
-  uint8_t len;                     /**< Length of the interrupt configuration array. */
-} aos_interrupt_driver_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-  void aosIntDriverInit(aos_interrupt_driver_t *intd, aos_interrupt_cfg_t *interrupt_cfg);
-  void aosIntDriverStart(aos_interrupt_driver_t *intd);
-  void aosIntDriverStop(aos_interrupt_driver_t *intd);
-  void aosIntEnable(aos_interrupt_driver_t *intd, uint8_t channel);
-  void aosIntDisable(aos_interrupt_driver_t *intd, uint8_t channel);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _AMIROOS_INTERRUPTS_H_ */
diff --git a/os/core/inc/aos_system.h b/os/core/inc/aos_system.h
index f229939..6e61599 100644
--- a/os/core/inc/aos_system.h
+++ b/os/core/inc/aos_system.h
@@ -23,7 +23,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <amiro-lld.h>
 #include <aos_shell.h>
 #include <aos_time.h>
-#include <aos_interrupts.h>
 #include <chprintf.h>
 
 /**
@@ -191,7 +190,7 @@ extern "C" {
   void aosSysShutdownInit(aos_shutdown_t shutdown);
   void aosSysStop(void);
   void aosSysDeinit(void);
-  void aosSysShutdownFinal(aos_interrupt_driver_t* intDrv, aos_shutdown_t shutdown);
+  void aosSysShutdownFinal(aos_shutdown_t shutdown);
 #ifdef __cplusplus
 }
 #endif
diff --git a/os/core/inc/aos_thread.h b/os/core/inc/aos_thread.h
index 1f369c8..774b6c7 100644
--- a/os/core/inc/aos_thread.h
+++ b/os/core/inc/aos_thread.h
@@ -25,67 +25,67 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * @brief   Minimum thread priority.
  */
-#define AOS_THD_LOWPRIO_MIN     ((tprio_t)(LOWPRIO))
+#define AOS_THD_LOWPRIO_MIN           ((tprio_t)(LOWPRIO))
 
 /**
  * @brief   Maximum priority for background threads.
  */
-#define AOS_THD_LOWPRIO_MAX     ((tprio_t)(LOWPRIO + ((NORMALPRIO - LOWPRIO) / 2)))
+#define AOS_THD_LOWPRIO_MAX           ((tprio_t)(LOWPRIO + ((NORMALPRIO - LOWPRIO) / 2)))
 
 /**
  * @brief   Minimum priority for normal/standard threads.
  */
-#define AOS_THD_NORMALPRIO_MIN  ((tprio_t)(AOS_THD_LOWPRIO_MAX + 1))
+#define AOS_THD_NORMALPRIO_MIN        ((tprio_t)(AOS_THD_LOWPRIO_MAX + 1))
 
 /**
  * @brief   Maximum priority for normal/standard threads.
  */
-#define AOS_THD_NORMALPRIO_MAX  ((tprio_t)(NORMALPRIO))
+#define AOS_THD_NORMALPRIO_MAX        ((tprio_t)(NORMALPRIO))
 
 /**
  * @brief   Minimum priority for important threads.
  */
-#define AOS_THD_HIGHPRIO_MIN    ((tprio_t)(NORMALPRIO + 1))
+#define AOS_THD_HIGHPRIO_MIN          ((tprio_t)(NORMALPRIO + 1))
 
 /**
  * @brief   Maximum priority for important threads.
  */
-#define AOS_THD_HIGHPRIO_MAX    ((tprio_t)(NORMALPRIO + ((HIGHPRIO - NORMALPRIO) / 2)))
+#define AOS_THD_HIGHPRIO_MAX          ((tprio_t)(NORMALPRIO + ((HIGHPRIO - NORMALPRIO) / 2)))
 
 /**
  * @brief   Minimum priority for real-time threads.
  */
-#define AOS_THD_RTPRIO_MIN      ((tprio_t)(AOS_THD_HIGHPRIO_MAX + 1))
+#define AOS_THD_RTPRIO_MIN            ((tprio_t)(AOS_THD_HIGHPRIO_MAX + 1))
 
 /**
  * @brief   Maximum priority for real-time threads.
  */
-#define AOS_THD_RTPRIO_MAX      ((tprio_t)(HIGHPRIO - 1))
+#define AOS_THD_RTPRIO_MAX            ((tprio_t)(HIGHPRIO - 1))
 
 /**
  * @brief   Priority for the system control thread.
  */
-#define AOS_THD_CTRLPRIO     ((tprio_t)(HIGHPRIO))
+#define AOS_THD_CTRLPRIO              ((tprio_t)(HIGHPRIO))
 
 /**
  * @brief   Maximum timeframe that can be slept in system ticks.
  */
-#define AOS_THD_MAX_SLEEP_ST    TIME_MAX_INTERVAL
+#define AOS_THD_MAX_SLEEP_ST          TIME_MAX_INTERVAL
 
 /**
  * @brief   Maximum timeframe that can be slept in seconds.
  */
-#define AOS_THD_MAX_SLEEP_S     (TIME_I2S(AOS_THD_MAX_SLEEP_ST) - 1)
+#define AOS_THD_MAX_SLEEP_S           (chTimeI2S(AOS_THD_MAX_SLEEP_ST) - 1)
 
 /**
  * @brief   Maximum timeframe that can be slept in milliseconds.
  */
-#define AOS_THD_MAX_SLEEP_MS    (TIME_I2MS(AOS_THD_MAX_SLEEP_ST) - 1)
+#define AOS_THD_MAX_SLEEP_MS          (chTimeI2MS(AOS_THD_MAX_SLEEP_ST) - 1)
 
 /**
  * @brief   Maximum timeframe that can be slept in microseconds.
  */
-#define AOS_THD_MAX_SLEEP_US    (TIME_I2US(AOS_THD_MAX_SLEEP_ST) - 1)
+#define AOS_THD_MAX_SLEEP_US          (chTimeI2US(AOS_THD_MAX_SLEEP_ST) - 1)
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/os/core/inc/aos_timer.h b/os/core/inc/aos_timer.h
index d784b34..f2cb49f 100644
--- a/os/core/inc/aos_timer.h
+++ b/os/core/inc/aos_timer.h
@@ -30,17 +30,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * @brief   Maximum timer interval that can be set in seconds.
  */
-#define AOS_TIMER_MAX_INTERVAL_S      (TIME_I2S(AOS_TIMER_MAX_INTERVAL_ST) - 1)
+#define AOS_TIMER_MAX_INTERVAL_S      (chTimeI2S(AOS_TIMER_MAX_INTERVAL_ST) - 1)
 
 /**
  * @brief   Maximum timer interval that can be set in milliseconds.
  */
-#define AOS_TIMER_MAX_INTERVAL_MS     (TIME_I2MS(AOS_TIMER_MAX_INTERVAL_ST) - 1)
+#define AOS_TIMER_MAX_INTERVAL_MS     (chTimeI2MS(AOS_TIMER_MAX_INTERVAL_ST) - 1)
 
 /**
  * @brief   Maximum timer interval that can be set in microseconds.
  */
-#define AOS_TIMER_MAX_INTERVAL_US     (TIME_I2US(AOS_TIMER_MAX_INTERVAL_ST) - 1)
+#define AOS_TIMER_MAX_INTERVAL_US     (chTimeI2US(AOS_TIMER_MAX_INTERVAL_ST) - 1)
 
 /**
  * @brief   Timer stucture.
diff --git a/os/core/src/aos_interrupts.c b/os/core/src/aos_interrupts.c
deleted file mode 100644
index d5ee819..0000000
--- a/os/core/src/aos_interrupts.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
-Copyright (C) 2016..2018  Thomas Schöpping et al.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <aos_interrupts.h>
-
-/**
- * @brief   Initializes the interrupt driver.
- *
- * @param[out]  intd            Interrupt driver object.
- * @param[in]   interrupt_cfg   Interrupt configuration to be used to initialize the driver.
- */
-void aosIntDriverInit(aos_interrupt_driver_t *intd, aos_interrupt_cfg_t *interrupt_cfg) {
-  intd->interrupts = interrupt_cfg;
-}
-
-/**
- * @brief   Starts the interrupt system by setting the pad callbacks and starting the pad events.
- *
- * @param[in]   intd    Interrupt driver with an interrupt configuration that specifies which interrupts to start.
- */
-void aosIntDriverStart(aos_interrupt_driver_t *intd) {
-  irqInit();
-  for (uint8_t i = 0; i < intd->len; i++) {
-    chSysLock();
-    palSetPadCallbackI(intd->interrupts[i].port, intd->interrupts[i].pad, intd->interrupts[i].cb, &intd->interrupts[i].cb_arg);
-    if (intd->interrupts[i].flags & AOS_INTERRUPT_AUTOSTART) {
-      palEnablePadEventI(intd->interrupts[i].port, intd->interrupts[i].pad, intd->interrupts[i].eventmode);
-    }
-    chSysUnlock();
-  }
-}
-
-/**
- * @brief   Stops the interrupt system.
- *
- * @param[in]   intd   All events associated with this driver will be disabled.
- */
-void aosIntDriverStop(aos_interrupt_driver_t *intd) {
-  for (uint8_t i = 0; i < intd->len; i++) {
-    palDisablePadEvent(intd->interrupts[i].port, intd->interrupts[i].pad);
-  }
-  irqDeinit();
-}
-
-/**
- * @brief   Enables the events on a specified channel.
- *
- * @param[in]   intd    Interrupt driver object.
- * @param[in]   channel Channel of the interrupt to enable.
- */
-void aosIntEnable(aos_interrupt_driver_t *intd, uint8_t channel) {
-  channel -= 1;
-  palEnablePadEvent(intd->interrupts[channel].port, intd->interrupts[channel].pad, intd->interrupts[channel].eventmode);
-}
-
-/**
- * @brief   Disables the events on a specified channel.
- *
- * @param[in]   intd    Interrupt driver object.
- * @param[in]   channel Channel of the interrupt to disable.
- */
-void aosIntDisable(aos_interrupt_driver_t *intd, uint8_t channel) {
-  channel -= 1;
-  palDisablePadEvent(intd->interrupts[channel].port, intd->interrupts[channel].pad);
-}
diff --git a/os/core/src/aos_iostream.c b/os/core/src/aos_iostream.c
index 7cb166a..1b9d4b7 100644
--- a/os/core/src/aos_iostream.c
+++ b/os/core/src/aos_iostream.c
@@ -120,20 +120,13 @@ static size_t _channelreadt(void *instance, uint8_t *bp, size_t n, sysinterval_t
 /**
  * @brief   Implementation of the BaseAsynchronousChannel ctl() method.
  */
-static msg_t _channelctl(void *instance, unsigned int operation, void *arg) {
-  (void) instance;
-
-  switch (operation) {
-  case CHN_CTL_NOP:
-    osalDbgCheck(arg == NULL);
-    break;
-  case CHN_CTL_INVALID:
-    osalDbgAssert(false, "invalid CTL operation");
-    break;
-  default:
-    break;
+static msg_t _channelctl(void *instance, unsigned int operation, void *arg)
+{
+  if (((AosIOChannel*)instance)->flags & AOS_IOCHANNEL_OUTPUT_ENABLE) {
+    return chnControl(((AosIOChannel*)instance)->asyncchannel, operation, arg));
+  } else {
+    return MSG_OK;
   }
-  return MSG_OK;
 }
 
 /**
diff --git a/os/core/src/aos_main.cpp b/os/core/src/aos_main.cpp
index 9141f09..8d3e80b 100644
--- a/os/core/src/aos_main.cpp
+++ b/os/core/src/aos_main.cpp
@@ -111,7 +111,7 @@ AMIROOS_CFG_MAIN_EXTRA_STATIC_VARIABLES
 static inline void _unexpectedEventError(const eventmask_t mask, const eventflags_t flags)
 {
 #if (AMIROOS_CFG_DBG == true)
-  aosprintf("unexpected/unknown event received. mask: 0x%08X; flags: 0x%08X\n", mask, flags);
+  aosprintf("CTRL: unexpected/unknown event received. mask: 0x%08X; flags: 0x%08X\n", mask, flags);
 #else
   (void)(mask);
   (void)(flags);
@@ -366,7 +366,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
     if (flags.wfe) {
       // wait for any event to occur
       aosDbgPrintf("WFE...");
-      eventmask = chEvtWaitAnyTimeout(ALL_EVENTS, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT));
+      eventmask = chEvtWaitAnyTimeout(ALL_EVENTS, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT));
       aosDbgPrintf("\t0x%08X", eventmask);
     } else {
       aosDbgPrintf("WFE skipped");
@@ -483,13 +483,13 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           flags.wfe_next = false;
 #else
           // set the timeout timer
-          chVTSet(&timerTimeout, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
+          chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
           // proceed
           stage = STAGE_3_3_WAITFORFIRSTID;
 #endif
 #else
           // set the timeout timer
-          chVTSet(&timerTimeout, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
+          chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
 #endif
         }
 
@@ -515,7 +515,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
             flags.wfe_next = false;
 #else
             // set the timeout timer
-            chVTSet(&timerTimeout, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
+            chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
             // proceed
             stage = STAGE_3_3_WAITFORFIRSTID;
 #endif
@@ -556,7 +556,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           stage = STAGE_3_3_WAITFORID;
 #else
           // set the delay timer so the UP signal is activated later
-          chVTSet(&timerDelay, TIME_US2I(AMIROOS_CFG_SSSP_SIGNALDELAY), _ssspTimerCallback, &eventSourceDelay);
+          chVTSet(&timerDelay, chTimeUS2I(AMIROOS_CFG_SSSP_SIGNALDELAY), _ssspTimerCallback, &eventSourceDelay);
 #endif
         }
 
@@ -597,7 +597,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
               // store received ID
               lastid = _deserialize(canRxFrame.data8, 4);
               // restart timeout timer
-              chVTSet(&timerTimeout, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
+              chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
               // proceed
               stage = STAGE_3_3_WAITFORIDORSIG;
             } else {
@@ -633,7 +633,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
               // store received ID
               lastid = _deserialize(canRxFrame.data8, 4);
               // restart timeout timer
-              chVTSet(&timerTimeout, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
+              chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
             } else {
               aosDbgPrintf("ERR: invalid ID\n");
               // abort
@@ -664,7 +664,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
             break;
           }
           // set delay timer
-          chVTSet(&timerDelay, TIME_US2I(AMIROOS_CFG_SSSP_SIGNALDELAY), _ssspTimerCallback, &eventSourceDelay);
+          chVTSet(&timerDelay, chTimeUS2I(AMIROOS_CFG_SSSP_SIGNALDELAY), _ssspTimerCallback, &eventSourceDelay);
         }
 
         // if a delay event occurred
@@ -678,7 +678,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           aosDbgPrintf("S-\n");
           apalControlGpioSet(&moduleSsspGpioSync, APAL_GPIO_OFF);
           // reset the timeout timer
-          chVTSet(&timerTimeout, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
+          chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
           chEvtWaitAnyTimeout(eventListenerTimeout.events, TIME_IMMEDIATE);
           eventmask &= ~(eventListenerTimeout.events);
           // proceed
@@ -707,7 +707,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
             aosDbgPrintf("ID (%u)\n", lastid);
 #endif
             // restart timeout timer
-            chVTSet(&timerTimeout, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
+            chVTSet(&timerTimeout, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceTimeout);
             chEvtWaitAnyTimeout(eventListenerTimeout.events, TIME_IMMEDIATE);
             eventmask &= ~(eventListenerTimeout.events);
           }
@@ -728,7 +728,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
           chEvtWaitAnyTimeout(eventListenerTimeout.events, TIME_IMMEDIATE);
           eventmask &= ~(eventListenerTimeout.events);
           //set the delay timer
-          chVTSet(&timerDelay, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceDelay);
+          chVTSet(&timerDelay, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT), _ssspTimerCallback, &eventSourceDelay);
         }
 
         // if a CAN event was received
@@ -809,7 +809,7 @@ aos_shutdown_t _ssspModuleStackInitialization(void)
 
     // apply wfe value for next iteration
     flags.wfe = flags.wfe_next;
-  }
+  } /* end of FSM loop */
   aosDbgPrintf("\n");
 
   // unregister all events (timeout, delay, CAN receive)
@@ -919,7 +919,15 @@ int main(void)
 #endif
 
   /* event associations */
-  chEvtRegisterMask(&aos.events.io, &_eventListenerIO, IOEVENT_MASK);
+#if (AMIROOS_CFG_SSSP_STACK_START == true) && (AMIROOS_CFG_SSSP_STACK_END == true)
+  chEvtRegisterMaskWithFlags(&aos.events.io, &_eventListenerIO, IOEVENT_MASK, MODULE_SSSP_EVENTFLAGS_PD | MODULE_SSSP_EVENTFLAGS_SYNC);
+#elif (AMIROOS_CFG_SSSP_STACK_START == true)
+  chEvtRegisterMaskWithFlags(&aos.events.io, &_eventListenerIO, IOEVENT_MASK, MODULE_SSSP_EVENTFLAGS_PD | MODULE_SSSP_EVENTFLAGS_SYNC | MODULE_SSSP_EVENTFLAGS_UP);
+#elif (AMIROOS_CFG_SSSP_STACK_END == true)
+  chEvtRegisterMaskWithFlags(&aos.events.io, &_eventListenerIO, IOEVENT_MASK, MODULE_SSSP_EVENTFLAGS_PD | MODULE_SSSP_EVENTFLAGS_SYNC | MODULE_SSSP_EVENTFLAGS_DN);
+#else
+  chEvtRegisterMaskWithFlags(&aos.events.io, &_eventListenerIO, IOEVENT_MASK, MODULE_SSSP_EVENTFLAGS_PD | MODULE_SSSP_EVENTFLAGS_SYNC | MODULE_SSSP_EVENTFLAGS_DN | MODULE_SSSP_EVENTFLAGS_UP);
+#endif
   chEvtRegisterMask(&aos.events.os, &_eventListenerOS, OSEVENT_MASK);
 
 #if defined(AMIROOS_CFG_MAIN_INIT_HOOK_5)
@@ -1057,7 +1065,7 @@ int main(void)
 
     aosDbgPrintf("receiving current date/time...\t");
     // receive message
-    if (canReceiveTimeout(&MODULE_HAL_CAN, CAN_ANY_MAILBOX, &frame, TIME_US2I(AOS_SYSTEM_SSSP_TIMEOUT)) == MSG_OK) {
+    if (canReceiveTimeout(&MODULE_HAL_CAN, CAN_ANY_MAILBOX, &frame, chTimeUS2I(AOS_SYSTEM_SSSP_TIMEOUT)) == MSG_OK) {
       // validate message
       if (frame.DLC == 8 &&
           frame.RTR == CAN_RTR_DATA &&
@@ -1111,7 +1119,7 @@ int main(void)
   while (shutdown == AOS_SHUTDOWN_NONE) {
     // wait for an event
 #if (AMIROOS_CFG_MAIN_LOOP_TIMEOUT != 0)
-    eventmask = chEvtWaitOneTimeout(ALL_EVENTS, TIME_US2I(AMIROOS_CFG_MAIN_LOOP_TIMEOUT));
+    eventmask = chEvtWaitOneTimeout(ALL_EVENTS, chTimeUS2I(AMIROOS_CFG_MAIN_LOOP_TIMEOUT));
 #else
     eventmask = chEvtWaitOne(ALL_EVENTS);
 #endif
@@ -1243,7 +1251,7 @@ int main(void)
 #endif
 
   // finally hand over to bootloader
-  aosSysShutdownFinal(&moduleIntDriver, shutdown);
+  aosSysShutdownFinal(shutdown);
 
   /*
    * ##########################################################################
diff --git a/os/core/src/aos_shell.c b/os/core/src/aos_shell.c
index 978b477..0d88548 100644
--- a/os/core/src/aos_shell.c
+++ b/os/core/src/aos_shell.c
@@ -1503,7 +1503,7 @@ THD_FUNCTION(aosShellThread, shell)
       default:
       {
         // print an error message
-        chprintf((BaseSequentialStream*)&((aos_shell_t*)shell)->stream, "\nERROR: unknown event received (0x%08X)\n", eventmask);
+        chprintf((BaseSequentialStream*)&((aos_shell_t*)shell)->stream, "\nSHELL: ERROR: unknown event received (0x%08X)\n", eventmask);
         break;
       }
 
diff --git a/os/core/src/aos_system.c b/os/core/src/aos_system.c
index 3e370d8..a3a1aa3 100644
--- a/os/core/src/aos_system.c
+++ b/os/core/src/aos_system.c
@@ -31,7 +31,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /**
  * @brief   Period of the system timer.
  */
-#define SYSTIMER_PERIOD               (TIME_MAX_INTERVAL - CH_CFG_ST_TIMEDELTA)
+#define SYSTIMER_PERIOD               (TIME_MAX_SYSTIME - CH_CFG_ST_TIMEDELTA)
 
 /**
  * @brief   Width of the printable system info text.
@@ -576,47 +576,38 @@ static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char*
   (void)argc;
   (void)argv;
 
-  tprio_t prio = chThdGetPriorityX();
-  chThdSetPriority(HIGHPRIO - 5); // some tests increase priorirty by 5, so this is the maximum priority permitted
   msg_t retval = test_execute(stream, &rt_test_suite);
-  chThdSetPriority(prio);
 
   return retval;
 }
 #endif /* AMIROOS_CFG_TESTS_ENABLE == true */
 
 /**
- * @brief   Callback function for the PD signal interrupt.
+ * @brief   Generic callback function for GPIO interrupts.
  *
- * @param[in] extp      Pointer to the interrupt driver object.
- * @param[in] channel   Interrupt channel identifier.
+ * @param[in] args   Pointer to the GPIO pad identifier.
  */
-static void _signalPdCallback(void *args)
+static void _intCallback(void* args)
 {
-  (void)args;
+  aosDbgCheck((args != NULL) && (*((iopadid_t*)args) < sizeof(eventflags_t) * 8));
 
   chSysLockFromISR();
-  chEvtBroadcastFlagsI(&aos.events.io, 0);
+  chEvtBroadcastFlagsI(&aos.events.io, (eventflags_t)1 << *((iopadid_t*)args));
   chSysUnlockFromISR();
 
   return;
 }
 
+#if (AMIROOS_CFG_SSSP_MASTER != true) || defined(__DOXYGEN__)
 /**
  * @brief   Callback function for the Sync signal interrupt.
  *
- * @param[in] extp      Pointer to the interrupt driver object.
- * @param[in] channel   Interrupt channel identifier.
+ * @param[in] args   Pointer to the GPIO pad identifier.
  */
 static void _signalSyncCallback(void *args)
 {
-  (void)args;
+  aosDbgCheck((args != NULL) && (*((iopadid_t*)args) < sizeof(eventflags_t) * 8));
 
-#if (AMIROOS_CFG_SSSP_MASTER == true)
-  chSysLockFromISR();
-  chEvtBroadcastFlagsI(&aos.events.io, 0);
-  chSysUnlockFromISR();
-#else
   apalControlGpioState_t s_state;
   aos_timestamp_t uptime;
 
@@ -644,12 +635,12 @@ static void _signalSyncCallback(void *args)
     }
   }
   // broadcast event
-  chEvtBroadcastFlagsI(&aos.events.io, 0);
+  chEvtBroadcastFlagsI(&aos.events.io, (eventflags_t)1 << *((iopadid_t*)args));
   chSysUnlockFromISR();
-#endif
 
   return;
 }
+#endif
 
 /**
  * @brief   Callback function for the uptime accumulation timer.
@@ -664,7 +655,7 @@ static void _uptimeCallback(void* par)
   // read current time in system ticks
   register const systime_t st = chVTGetSystemTimeX();
   // update the uptime variables
-  _uptime += TIME_I2US(st - _synctime);
+  _uptime += chTimeI2US(chTimeDiffX(_synctime, st));
   _synctime = st;
   // enable the timer again
   chVTSetI(&_systimer, SYSTIMER_PERIOD, &_uptimeCallback, NULL);
@@ -696,12 +687,12 @@ static void _sysSyncTimerCallback(void* par)
     // reconfigure the timer precisely, because the logically falling edge (next interrupt) snychronizes the system time
     _syssynctime += AMIROOS_CFG_SSSP_SYSSYNCPERIOD;
     aosSysGetUptimeX(&uptime);
-    chVTSetI(&_syssynctimer, TIME_US2I(_syssynctime - uptime), _sysSyncTimerCallback, NULL);
+    chVTSetI(&_syssynctimer, chTimeUS2I(_syssynctime - uptime), _sysSyncTimerCallback, NULL);
   }
   // if S was toggled from on to off
   else /* if (s_state == APAL_GPIO_OFF) */ {
     // reconfigure the timer (lazy)
-    chVTSetI(&_syssynctimer, TIME_US2I(AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2), _sysSyncTimerCallback, NULL);
+    chVTSetI(&_syssynctimer, chTimeUS2I(AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2), _sysSyncTimerCallback, NULL);
   }
   chSysUnlockFromISR();
 
@@ -721,10 +712,10 @@ void aosSysInit(const char* shellPrompt)
 void aosSysInit(void)
 #endif
 {
-  // set control thread to maximum priority
+  /* set control thread to maximum priority */
   chThdSetPriority(AOS_THD_CTRLPRIO);
 
-  // set local variables
+  /* set local variables */
   chVTObjectInit(&_systimer);
   _synctime = 0;
   _uptime = 0;
@@ -736,23 +727,41 @@ void aosSysInit(void)
   _syssyncskew = 0.0f;
 #endif
 
-  // set aos configuration
+  /* initialize aos configuration */
   aos.sssp.stage = AOS_SSSP_STARTUP_2_1;
   aos.sssp.moduleId = 0;
   aosIOStreamInit(&aos.iostream);
   chEvtObjectInit(&aos.events.io);
   chEvtObjectInit(&aos.events.os);
 
-  // setup external interrupt system
-  aosIntDriverInit(&moduleIntDriver, moduleIntConfig);
-  chSysLock();
-  palSetPadCallbackI(moduleGpioSysPd.port, moduleGpioSysPd.pad, _signalPdCallback, NULL);
-  palSetPadCallbackI(moduleGpioSysSync.port, moduleGpioSysSync.pad, _signalSyncCallback, NULL);
-  chSysUnlock();
-  aosIntDriverStart(&moduleIntDriver);
+  /* interrupt setup */
+  // PD signal
+  palSetPadCallback(moduleSsspGpioPd.gpio->port, moduleSsspGpioPd.gpio->pad, _intCallback, &moduleSsspGpioPd.gpio->pad);
+  palEnablePadEvent(moduleSsspGpioPd.gpio->port, moduleSsspGpioPd.gpio->pad, APAL2CH_EDGE(moduleSsspGpioPd.meta.edge));
+  // SYNC signal
+#if (AMIROOS_CFG_SSSP_MASTER == true)
+  palSetPadCallback(moduleSsspGpioSync.gpio->port, moduleSsspGpioSync.gpio->pad, _intCallback, &moduleSsspGpioSync.gpio->pad);
+#else
+  palSetPadCallback(moduleSsspGpioSync.gpio->port, moduleSsspGpioSync.gpio->pad, _signalSyncCallback, &moduleSsspGpioSync.gpio->pad);
+#endif
+  palEnablePadEvent(moduleSsspGpioSync.gpio->port, moduleSsspGpioSync.gpio->pad, APAL2CH_EDGE(moduleSsspGpioSync.meta.edge));
+#if (AMIROOS_CFG_SSSP_STACK_START != true)
+  // DN signal
+  palSetPadCallback(moduleSsspGpioDn.gpio->port, moduleSsspGpioDn.gpio->pad, _intCallback, &moduleSsspGpioDn.gpio->pad);
+  palEnablePadEvent(moduleSsspGpioDn.gpio->port, moduleSsspGpioDn.gpio->pad, APAL2CH_EDGE(moduleSsspGpioDn.meta.edge));
+#endif
+#if (AMIROOS_CFG_SSSP_STACK_END != true)
+  // UP signal
+  palSetPadCallback(moduleSsspGpioUp.gpio->port, moduleSsspGpioUp.gpio->pad, _intCallback, &moduleSsspGpioUp.gpio->pad);
+  palEnablePadEvent(moduleSsspGpioUp.gpio->port, moduleSsspGpioUp.gpio->pad, APAL2CH_EDGE(moduleSsspGpioUp.meta.edge));
+#endif
+#ifdef MODULE_INIT_INTERRUPTS
+  // further interrupt signals
+  MODULE_INIT_INTERRUPTS();
+#endif
 
 #if (AMIROOS_CFG_SHELL_ENABLE == true)
-  // init shell
+  /* init shell */
   aosShellInit(&aos.shell,
                &aos.events.os,
                shellPrompt,
@@ -788,7 +797,7 @@ inline void aosSysStart(void)
     aos_timestamp_t t;
     aosSysGetUptimeX(&t);
     t = AMIROOS_CFG_SSSP_SYSSYNCPERIOD - (t % AMIROOS_CFG_SSSP_SYSSYNCPERIOD);
-    chVTSetI(&_syssynctimer, TIME_US2I((t > (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2)) ? (t - (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2)) : (t + (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2))), _sysSyncTimerCallback, NULL);
+    chVTSetI(&_syssynctimer, chTimeUS2I((t > (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2)) ? (t - (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2)) : (t + (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2))), _sysSyncTimerCallback, NULL);
     chSysUnlock();
   }
 #endif
@@ -865,7 +874,7 @@ inline void aosSysGetUptimeX(aos_timestamp_t* ut)
 {
   aosDbgCheck(ut != NULL);
 
-  *ut = _uptime + TIME_I2US(chVTGetSystemTimeX() - _synctime);
+  *ut = _uptime + chTimeI2US(chTimeDiffX(_synctime, chVTGetSystemTimeX()));
 
   return;
 }
@@ -987,17 +996,15 @@ void aosSysDeinit(void)
  * @brief   Finally shuts down the system and calls the bootloader callback function.
  * @note    This function should be called from the thtead with highest priority.
  *
- * @param[in] extDrv      Pointer to the interrupt driver.
  * @param[in] shutdown    Type of shutdown.
  */
-void aosSysShutdownFinal(aos_interrupt_driver_t* intDrv, aos_shutdown_t shutdown)
+void aosSysShutdownFinal(aos_shutdown_t shutdown)
 {
   // check arguments
-  aosDbgCheck(intDrv != NULL);
   aosDbgCheck(shutdown != AOS_SHUTDOWN_NONE);
 
-  // stop external interrupt system
-  aosIntDriverStop(intDrv);
+  // disable all interrupts
+  irqDeinit();
 
   // update the system SSSP stage
   aos.sssp.stage = AOS_SSSP_SHUTDOWN_1_3;
diff --git a/os/core/src/aos_thread.c b/os/core/src/aos_thread.c
index 768854b..5535e0f 100644
--- a/os/core/src/aos_thread.c
+++ b/os/core/src/aos_thread.c
@@ -34,13 +34,13 @@ void aosThdSleepUntilS(const aos_timestamp_t* t)
 
   // while the remaining time is too long, it must be split into multiple sleeps
   while ( (*t > uptime) && ((*t - uptime) > AOS_THD_MAX_SLEEP_US) ) {
-    chThdSleepS(TIME_US2I(AOS_THD_MAX_SLEEP_US));
+    chThdSleepS(chTimeUS2I(AOS_THD_MAX_SLEEP_US));
     aosSysGetUptimeX(&uptime);
   }
 
   // sleep the remaining time
   if (*t > uptime) {
-    systime_t rest = TIME_US2I(*t - uptime);
+    sysinterval_t rest = chTimeUS2I(*t - uptime);
     if (rest > TIME_IMMEDIATE) {
       chThdSleepS(rest);
     }
diff --git a/os/core/src/aos_timer.c b/os/core/src/aos_timer.c
index 531ec13..91e4982 100644
--- a/os/core/src/aos_timer.c
+++ b/os/core/src/aos_timer.c
@@ -45,9 +45,9 @@ static inline void _setupTimer(aos_timer_t* timer)
   if ( (timer->wkuptime > uptime) && ((timer->wkuptime - uptime) > TIME_IMMEDIATE) ) {
     // split the time delta if necessary
     if ((timer->wkuptime - uptime) > AOS_TIMER_MAX_INTERVAL_US) {
-      chVTSetI(&(timer->vt), TIME_US2I(AOS_TIMER_MAX_INTERVAL_US), _intermediateCb, timer);
+      chVTSetI(&(timer->vt), chTimeUS2I(AOS_TIMER_MAX_INTERVAL_US), _intermediateCb, timer);
     } else {
-      chVTSetI(&(timer->vt), TIME_US2I(timer->wkuptime - uptime), _fireCb, timer);
+      chVTSetI(&(timer->vt), chTimeUS2I(timer->wkuptime - uptime), _fireCb, timer);
     }
   } else {
     vtfunc_t fn = timer->callback;
diff --git a/os/unittests/lld/src/ut_lld_adc.c b/os/unittests/lld/src/ut_lld_adc.c
index dc5923f..05721f7 100644
--- a/os/unittests/lld/src/ut_lld_adc.c
+++ b/os/unittests/lld/src/ut_lld_adc.c
@@ -115,7 +115,7 @@ aos_utresult_t utAdcFunc(BaseSequentialStream* stream, aos_unittest_t* ut)
   conversionGroup.ltr = _adcWdgThreshold;
   _listener = chThdGetSelfX();
   adcStartConversion(((ut_adcdata_t*)(ut->data))->driver, &conversionGroup, buffer, 1);
-  eventmask = chEvtWaitOneTimeout(_adcWdgEventmask, TIME_S2I(5));
+  eventmask = chEvtWaitOneTimeout(_adcWdgEventmask, chTimeS2I(5));
   if (eventmask == _adcWdgEventmask) {
     aosUtPassedMsg(stream, &result, "%fV %c 9V\n", _adc2volt(buffer[0]), (buffer[0] > _adcWdgThreshold) ? '>' : '<');
     wdgpassed = true;
@@ -139,7 +139,7 @@ aos_utresult_t utAdcFunc(BaseSequentialStream* stream, aos_unittest_t* ut)
       aosThdMSleep(100); // wait some time so the ADC wil trigger again immediately due to noise
       _listener = chThdGetSelfX();
       adcStartConversion(((ut_adcdata_t*)(ut->data))->driver, &conversionGroup, buffer, 1);
-      eventmask = chEvtWaitOneTimeout(_adcWdgEventmask, TIME_S2I(10));
+      eventmask = chEvtWaitOneTimeout(_adcWdgEventmask, chTimeS2I(10));
       if (eventmask == _adcWdgEventmask) {
         aosUtPassedMsg(stream, &result, "%fV %c 9V\n", _adc2volt(buffer[0]), (buffer[0] > _adcWdgThreshold) ? '>' : '<');
       } else {
diff --git a/os/unittests/periphery-lld/src/ut_alld_hmc5883l.c b/os/unittests/periphery-lld/src/ut_alld_hmc5883l.c
index 17e1c34..eb4b7ca 100644
--- a/os/unittests/periphery-lld/src/ut_alld_hmc5883l.c
+++ b/os/unittests/periphery-lld/src/ut_alld_hmc5883l.c
@@ -159,7 +159,7 @@ aos_utresult_t utAlldHmc5883lFunc(BaseSequentialStream* stream, aos_unittest_t*
 
   chprintf(stream, "interrupt (full data read)...\n");
   status |= hmc5883l_lld_read_data(((ut_hmc5883ldata_t*)ut->data)->driver, mdata, ((ut_hmc5883ldata_t*)ut->data)->timeout);
-  event_mask = chEvtWaitOneTimeout(EVENT_MASK(0), TIME_US2I(100 * MICROSECONDS_PER_MILLISECOND));
+  event_mask = chEvtWaitOneTimeout(EVENT_MASK(0), chTimeUS2I(100 * MICROSECONDS_PER_MILLISECOND));
   chprintf(stream, "\t\teventmask = 0x%08X (should be 1)\n", event_mask);
   if (event_mask == EVENT_MASK(0)) {
     aosUtPassed(stream, &result);
@@ -176,7 +176,7 @@ aos_utresult_t utAlldHmc5883lFunc(BaseSequentialStream* stream, aos_unittest_t*
   aosSysGetUptime(&t);
   status |= hmc5883l_lld_read_data(((ut_hmc5883ldata_t*)ut->data)->driver, mdata, ((ut_hmc5883ldata_t*)ut->data)->timeout);
   while (t - start < MICROSECONDS_PER_SECOND) {
-    event_mask = chEvtWaitOneTimeout(EVENT_MASK(0), TIME_US2I(1000));
+    event_mask = chEvtWaitOneTimeout(EVENT_MASK(0), chTimeUS2I(1000));
     if (event_mask == EVENT_MASK(0)) {
       status |= hmc5883l_lld_read_data(((ut_hmc5883ldata_t*)ut->data)->driver, mdata, ((ut_hmc5883ldata_t*)ut->data)->timeout);
       data_reads++;
diff --git a/os/unittests/periphery-lld/src/ut_alld_lis331dlh.c b/os/unittests/periphery-lld/src/ut_alld_lis331dlh.c
index e10e06b..56378fa 100644
--- a/os/unittests/periphery-lld/src/ut_alld_lis331dlh.c
+++ b/os/unittests/periphery-lld/src/ut_alld_lis331dlh.c
@@ -219,6 +219,7 @@ aos_utresult_t utAlldLis331dlhFunc(BaseSequentialStream* stream, aos_unittest_t*
     }
     aosThdSSleep(1);
   }
+  event_mask = chEvtWaitOneTimeout(EVENT_MASK(3), TIME_IMMEDIATE);
   chEvtUnregister(((ut_lis331dlhdata_t*)(ut->data))->src, &el);
   if (status == APAL_STATUS_SUCCESS && success > 0) {
     aosUtPassed(stream, &result);
diff --git a/os/unittests/periphery-lld/src/ut_alld_mpr121.c b/os/unittests/periphery-lld/src/ut_alld_mpr121.c
index b8fdf11..2e5e30f 100644
--- a/os/unittests/periphery-lld/src/ut_alld_mpr121.c
+++ b/os/unittests/periphery-lld/src/ut_alld_mpr121.c
@@ -135,7 +135,7 @@ aos_utresult_t utAlldMpr121Func(BaseSequentialStream* stream, aos_unittest_t* ut
   do {
     aosSysGetUptime(&tcurrent);
     const aos_timestamp_t ttimeout = MICROSECONDS_PER_SECOND - ((tcurrent - tstart) % MICROSECONDS_PER_SECOND);
-    const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), TIME_US2I(ttimeout));
+    const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), chTimeUS2I(ttimeout));
     const eventflags_t eflags = chEvtGetAndClearFlags(&event_listener);
     if (emask == EVENT_MASK(INTERRUPT_EVENT_ID) && eflags == ((ut_mpr121data_t*)ut->data)->evtflags) {
       // interrupt detected
diff --git a/os/unittests/periphery-lld/src/ut_alld_vcnl4020.c b/os/unittests/periphery-lld/src/ut_alld_vcnl4020.c
index b33d967..fc3c674 100644
--- a/os/unittests/periphery-lld/src/ut_alld_vcnl4020.c
+++ b/os/unittests/periphery-lld/src/ut_alld_vcnl4020.c
@@ -169,7 +169,7 @@ aos_utresult_t utAlldVcnl4020Func(BaseSequentialStream* stream, aos_unittest_t*
   status |= vcnl4020_lld_writereg(((ut_vcnl4020data_t*)(ut->data))->vcnld, VCNL4020_LLD_REGADDR_INTCTRL, VCNL4020_LLD_INTCTRLREG_THRES_EN, ((ut_vcnl4020data_t*)(ut->data))->timeout);
   do {
     // read proximity data, interrupt event information and interrupt status
-    const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), TIME_US2I(10*MICROSECONDS_PER_MILLISECOND));
+    const eventmask_t emask = chEvtWaitOneTimeout(EVENT_MASK(INTERRUPT_EVENT_ID), chTimeUS2I(10*MICROSECONDS_PER_MILLISECOND));
     const eventflags_t eflags = chEvtGetAndClearFlags(&event_listener);
     status |= vcnl4020_lld_readprox(((ut_vcnl4020data_t*)(ut->data))->vcnld, &reg_16[0], ((ut_vcnl4020data_t*)(ut->data))->timeout);
     status |= vcnl4020_lld_readreg(((ut_vcnl4020data_t*)(ut->data))->vcnld, VCNL4020_LLD_REGADDR_INTSTATUS, &reg_8[2], ((ut_vcnl4020data_t*)(ut->data))->timeout);
diff --git a/periphery-lld/AMiRo-LLD b/periphery-lld/AMiRo-LLD
index 59c2837..cf1f756 160000
--- a/periphery-lld/AMiRo-LLD
+++ b/periphery-lld/AMiRo-LLD
@@ -1 +1 @@
-Subproject commit 59c2837266778acf1974df72318852ccb9d5e8bb
+Subproject commit cf1f756b0cb3a504a95343b00c436d93b82ef1a2
diff --git a/periphery-lld/periphAL.h b/periphery-lld/periphAL.h
index e00b0b3..9f3af14 100644
--- a/periphery-lld/periphAL.h
+++ b/periphery-lld/periphAL.h
@@ -56,12 +56,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 static inline void usleep(apalTime_t us)
 {
   // check if the specified time can be represented by the system
-  aosDbgCheck(us <= TIME_I2US(TIME_INFINITE));
+  aosDbgCheck(us <= chTimeI2US(TIME_INFINITE));
 
-  const systime_t st = TIME_US2I(us);
+  const sysinterval_t si = chTimeUS2I(us);
   // TIME_IMMEDIATE makes no sense and would even cause system halt
-  if (st != TIME_IMMEDIATE) {
-    chThdSleep(st);
+  if (si != TIME_IMMEDIATE) {
+    chThdSleep(si);
   }
   return;
 }
@@ -76,18 +76,8 @@ static inline void usleep(apalTime_t us)
  * @brief GPIO driver type.
  */
 struct apalGpio_t {
-  /*
-   * Workaround, since GPIOv2 (STM32F4XX) uses a different type than GPIOv1 (STM32F1XX).
-   */
-  #if defined(STM32F4XX)
-  stm32_gpio_t* port;
-  #elif defined(STM32F1XX)
-  GPIO_TypeDef* port;
-  #else
-  void* port;
-  #endif
-
-  uint8_t pad;
+  ioportid_t port;
+  iopadid_t pad;
 } PACKED_VAR;
 
 /**
@@ -183,16 +173,12 @@ static inline apalExitStatus_t apalControlGpioSet(const apalControlGpio_t* const
   return APAL_STATUS_OK;
 }
 
-#endif
-
-#if HAL_USE_PAL || defined(__DOXYGEN__)
-
 /**
- * @brief   Converts an apalGpioEdge_t to an ChibiOS EXT edge.
+ * @brief   Converts an apalGpioEdge_t to an ChibiOS PAL edge.
  */
-#define APAL2CH_EDGE(edge)                                        \
-  ((edge == APAL_GPIO_EDGE_RISING) ? PAL_EVENT_MODE_RISING_EDGE :    \
-    (edge == APAL_GPIO_EDGE_FALLING) ? PAL_EVENT_MODE_FALLING_EDGE : \
+#define APAL2CH_EDGE(edge)                                            \
+  ((edge == APAL_GPIO_EDGE_RISING) ? PAL_EVENT_MODE_RISING_EDGE :     \
+    (edge == APAL_GPIO_EDGE_FALLING) ? PAL_EVENT_MODE_FALLING_EDGE :  \
      (edge == APAL_GPIO_EDGE_BOTH) ? PAL_EVENT_MODE_BOTH_EDGES : 0)
 
 #endif
@@ -360,6 +346,8 @@ static inline apalExitStatus_t apalI2CMasterTransmit(apalI2CDriver_t* i2cd, cons
   i2cAcquireBus(i2cd);
 #endif
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
 #if defined(STM32F1XX_I2C)
   // Due to a hardware limitation, for STM32F1 platform the minimum number of bytes that can be received is two.
   msg_t status = MSG_OK;
@@ -373,6 +361,7 @@ static inline apalExitStatus_t apalI2CMasterTransmit(apalI2CDriver_t* i2cd, cons
 #else
   const msg_t status = i2cMasterTransmitTimeout(i2cd, addr, txbuf, txbytes, rxbuf, rxbytes, ((timeout >= TIME_INFINITE) ? TIME_INFINITE : TIME_US2I(timeout)) );
 #endif
+#pragma GCC diagnostic pop
 
 #if (I2C_USE_MUTUAL_EXCLUSION == TRUE)
   i2cReleaseBus(i2cd);
@@ -413,6 +402,8 @@ static inline apalExitStatus_t apalI2CMasterReceive(apalI2CDriver_t* i2cd, const
   i2cAcquireBus(i2cd);
 #endif
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
 #if defined(STM32F1XX_I2C)
   // Due to a hardware limitation, for STM32F1 platform the minimum number of bytes that can be received is two.
   msg_t status = MSG_OK;
@@ -426,6 +417,7 @@ static inline apalExitStatus_t apalI2CMasterReceive(apalI2CDriver_t* i2cd, const
 #else
   const msg_t status = i2cMasterReceiveTimeout(i2cd, addr, rxbuf, rxbytes, ((timeout >= TIME_INFINITE) ? TIME_INFINITE : TIME_US2I(timeout)) );
 #endif
+#pragma GCC diagnostic pop
 
 #if (I2C_USE_MUTUAL_EXCLUSION == TRUE)
   i2cReleaseBus(i2cd);
