commit e05848a624d2cc4baf5043a3d2b1b2a7fd27b053
Author: Robin Ewers <rewers@techfak.uni-bielefeld.de>
Date:   Fri Sep 14 13:50:41 2018 +0200

    add dw1000 unittest

diff --git a/kernel/ChibiOS b/kernel/ChibiOS
index 3a1b71e..2722757 160000
--- a/kernel/ChibiOS
+++ b/kernel/ChibiOS
@@ -1 +1 @@
-Subproject commit 3a1b71ebdcf2687385f1b327feef0de7ccacb1f4
+Subproject commit 27227574f700b45e9a476af8dbae3fedbdfb8871
diff --git a/modules/LightRing_1-0/alldconf.h b/modules/LightRing_1-0/alldconf.h
index f855db3..67dca20 100644
--- a/modules/LightRing_1-0/alldconf.h
+++ b/modules/LightRing_1-0/alldconf.h
@@ -58,6 +58,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #define AMIROLLD_CFG_USE_TPS2051BDBV
 
+/**
+ * @brief   Enable flag for the DW1000.
+ */
+#define AMIROLLD_CFG_USE_DW1000
+
 #endif /* _ALLDCONF_H_ */
 
 /** @} */
diff --git a/modules/LightRing_1-0/module.c b/modules/LightRing_1-0/module.c
index 75b2912..8240fd6 100644
--- a/modules/LightRing_1-0/module.c
+++ b/modules/LightRing_1-0/module.c
@@ -16,14 +16,6 @@ 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    
- * @brief   Structures and constant for the LightRing module.
- *
- * @addtogroup lightring_module
- * @{
- */
-
 #include "module.h"
 
 #include <amiroos.h>
@@ -35,6 +27,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 /*===========================================================================*/
 
+
 /** @} */
 
 /*===========================================================================*/
@@ -71,12 +64,12 @@ SPIConfig moduleHalSpiLightConfig = {
   /* CR2                         */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
 };
 
-SPIConfig moduleHalSpiWlConfig = {
+SPIConfig moduleHalSpiUWBConfig = {
   /* circular buffer mode        */ false,
   /* callback function pointer   */ NULL,
   /* chip select line port       */ GPIOB,
   /* chip select line pad number */ GPIOB_WL_SS_N,
-  /* CR1                         */ SPI_CR1_BR_0,
+  /* CR1                         */ SPI_CR1_BR_0 | SPI_CR1_BR_1,
   /* CR2                         */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
 };
 
@@ -151,6 +144,8 @@ apalControlGpio_t moduleGpioSysUartDn = {
   },
 };
 
+//INFO WL_GDO2,WL_GDO0 /  -> UWB EXTI config.
+
 /**
  * @brief   WL_GDO2 input signal GPIO.
  */
@@ -278,6 +273,14 @@ TPS2051BDriver moduleLldPowerSwitchLaser = {
   /* laser overcurrent GPIO */ &moduleGpioLaserOc,
 };
 
+
+DW1000Driver moduleLldDW1000 = {
+  /* SPI driver */ &MODULE_HAL_SPI_UWB,
+  /* EXTI GPIO  */ &_gpioWlGdo2,
+  /* RESET GPIO */ &_gpioWlGdo2,
+
+};
+
 /** @} */
 
 /*===========================================================================*/
@@ -352,7 +355,26 @@ aos_unittest_t moduleUtAlldTps2051bdbv = {
   /* data           */ &moduleLldPowerSwitchLaser,
 };
 
+/* UWB Module */
+static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[])
+{
+  (void)argc;
+  (void)argv;
+  aosUtRun(stream,&moduleUtAlldDw1000, NULL);
+  return AOS_OK;
+}
+aos_unittest_t moduleUtAlldDw1000 = {
+  /* info           */ "DW1000",
+  /* name           */ "UWB Module",
+  /* test function  */ utAlldDw1000Func,
+  /* shell command  */ {
+    /* name     */ "unittest:UWB",
+    /* callback */ _utShellCmdCb_Dw1000,
+    /* next     */ NULL,
+  },
+  /* data           */ &moduleLldDW1000,
+};
+
 #endif /* AMIROOS_CFG_TESTS_ENABLE == true */
 
 /** @} */
-/** @} */
diff --git a/modules/LightRing_1-0/module.h b/modules/LightRing_1-0/module.h
index 4200e75..d6ba3e9 100644
--- a/modules/LightRing_1-0/module.h
+++ b/modules/LightRing_1-0/module.h
@@ -16,14 +16,6 @@ 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    
- * @brief   Structures and constant for the LightRing module.
- *
- * @addtogroup lightring_module
- * @{
- */
-
 #ifndef _AMIROOS_MODULE_H_
 #define _AMIROOS_MODULE_H_
 
@@ -34,6 +26,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 /*===========================================================================*/
 
+static void _alld_dw1000_callback(void* args);
+
 /** @} */
 
 /*===========================================================================*/
@@ -80,19 +74,19 @@ extern SerialConfig moduleHalProgIfConfig;
 #define MODULE_HAL_SPI_LIGHT                    SPID1
 
 /**
- * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
+ * @brief   SPI interface driver for UWB Module.
  */
-extern SPIConfig moduleHalSpiLightConfig;
+#define MODULE_HAL_SPI_UWB                      SPID2
 
 /**
- * @brief   SPI interface driver for the wireless transceiver.
+ * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
  */
-#define MODULE_HAL_SPI_WL                       SPID2
+extern SPIConfig moduleHalSpiLightConfig;
 
 /**
- * @brief   Configuration for the SPI interface driver to communicate with the wireless transceiver.
+ * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
  */
-extern SPIConfig moduleHalSpiWlConfig;
+extern SPIConfig moduleHalSpiUWBConfig;
 
 /**
  * @brief   Real-Time Clock driver.
@@ -200,6 +194,9 @@ extern apalControlGpio_t moduleGpioSysSync;
 extern const char* moduleShellPrompt;
 #endif
 
+
+
+
 /**
  * @brief   Interrupt initialization macro.
  * @note    SSSP related interrupt signals are already initialized in 'aos_system.c'.
@@ -209,10 +206,10 @@ extern const char* moduleShellPrompt;
   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);  \
+  palSetPadCallback(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, _alld_dw1000_callback, &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);  \
+  palSetPadCallback(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, _alld_dw1000_callback, &moduleGpioWlGdo0.gpio->pad);  \
   /*palEnablePadEvent(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, APAL2CH_EDGE(moduleGpioWlGdo0.meta.edge)); // this is broken for some reason*/   \
 }
 
@@ -224,6 +221,7 @@ extern const char* moduleShellPrompt;
   aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd);            \
   aosShellAddCommand(&aos.shell, &moduleUtAlldTlc5947.shellcmd);              \
   aosShellAddCommand(&aos.shell, &moduleUtAlldTps2051bdbv.shellcmd);          \
+  aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd);                \
 }
 
 /**
@@ -238,7 +236,7 @@ extern const char* moduleShellPrompt;
   i2cStart(&MODULE_HAL_I2C_EEPROM, &moduleHalI2cEepromConfig);                \
   /* SPI */                                                                   \
   spiStart(&MODULE_HAL_SPI_LIGHT, &moduleHalSpiLightConfig);                  \
-  spiStart(&MODULE_HAL_SPI_WL, &moduleHalSpiWlConfig);                        \
+  spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUWBConfig);                      \
 }
 
 /**
@@ -247,7 +245,7 @@ extern const char* moduleShellPrompt;
 #define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
   /* SPI */                                                                   \
   spiStop(&MODULE_HAL_SPI_LIGHT);                                             \
-  spiStop(&MODULE_HAL_SPI_WL);                                                \
+  spiStop(&MODULE_HAL_SPI_UWB);                                               \
   /* I2C */                                                                   \
   i2cStop(&MODULE_HAL_I2C_EEPROM);                                            \
   /* don't stop the serial driver so messages can still be printed */         \
@@ -303,6 +301,7 @@ extern const char* moduleShellPrompt;
 #include <alld_at24c01bn-sh-b.h>
 #include <alld_tlc5947.h>
 #include <alld_tps2051bdbv.h>
+#include <alld_dw1000.h>
 
 /**
  * @brief   EEPROM driver.
@@ -319,6 +318,43 @@ extern TLC5947Driver moduleLldLedPwm;
  */
 extern TPS2051BDriver moduleLldPowerSwitchLaser;
 
+/**
+ * @brief   DW1000 driver for UWB.
+ */
+extern DW1000Driver moduleLldDW1000;
+
+
+
+
+/*! ------------------------------------------------------------------------------------------------------------------
+ * Function: _alld_dw1000_callback()
+ *
+ * Low level abstract function to handle 'reset' adn 'irq' interrupt from DW1000
+ * Expects arg to be of iopadid_t* type, used to distinguish between irq or reset signal
+ */
+static void _alld_dw1000_callback(void* args) {
+
+    aosDbgCheck(true);
+
+
+    chSysLockFromISR();
+    if ((*(iopadid_t*) args) == moduleLldDW1000.gpio_reset->pad)
+    {
+        // dw1000 external indicate reset done
+    }
+    else if ((*(iopadid_t*) args) == moduleLldDW1000.gpio_exti->pad)
+    {
+        dwt_isr();
+    }
+    else
+    {
+        return;
+    }
+    chSysUnlockFromISR();
+
+}
+
+
 /** @} */
 
 /*===========================================================================*/
@@ -331,6 +367,7 @@ extern TPS2051BDriver moduleLldPowerSwitchLaser;
 #include <ut_alld_at24c01bn-sh-b.h>
 #include <ut_alld_tlc5947.h>
 #include <ut_alld_tps2051bdbv.h>
+#include <ut_alld_dw1000.h>
 
 /**
  * @brief   EEPROM unit test object.
@@ -347,10 +384,14 @@ extern aos_unittest_t moduleUtAlldTlc5947;
  */
 extern aos_unittest_t moduleUtAlldTps2051bdbv;
 
+/**
+ * @brief   DW1000 unit test object.
+ */
+extern aos_unittest_t moduleUtAlldDw1000;
+
+
 #endif /* AMIROOS_CFG_TESTS_ENABLE == true */
 
 /** @} */
 
 #endif /* _AMIROOS_MODULE_H_ */
-
-/** @} */
diff --git a/os/core/src/aos_iostream.c b/os/core/src/aos_iostream.c
index 548eae2..5c7ec43 100644
--- a/os/core/src/aos_iostream.c
+++ b/os/core/src/aos_iostream.c
@@ -132,7 +132,7 @@ static size_t _channelreadt(void *instance, uint8_t *bp, size_t n, sysinterval_t
 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);
+    return chnControl(((AosIOChannel*)instance)->asyncchannel, operation, arg));
   } else {
     return MSG_OK;
   }
diff --git a/os/unittests/periphery-lld/inc/ut_alld_dw1000.h b/os/unittests/periphery-lld/inc/ut_alld_dw1000.h
new file mode 100755
index 0000000..43f98eb
--- /dev/null
+++ b/os/unittests/periphery-lld/inc/ut_alld_dw1000.h
@@ -0,0 +1,40 @@
+/*
+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_UT_DW1000_LLD_HPP_
+#define _AMIROOS_UT_DW1000_LLD_HPP_
+
+#include <aos_unittest.h>
+#include <amiro-lld.h>
+
+#if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_DW1000)) || defined(__DOXYGEN__)
+
+#include <alld_dw1000.h>
+//#include <deca_instance.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+  aos_utresult_t utAlldDw1000Func(BaseSequentialStream* stream, aos_unittest_t* ut);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_DW1000) */
+
+#endif /* _AMIROOS_UT_DW1000_LLD_HPP_ */
diff --git a/os/unittests/periphery-lld/module.h b/os/unittests/periphery-lld/module.h
new file mode 100755
index 0000000..d6ba3e9
--- /dev/null
+++ b/os/unittests/periphery-lld/module.h
@@ -0,0 +1,397 @@
+/*
+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_MODULE_H_
+#define _AMIROOS_MODULE_H_
+
+/*===========================================================================*/
+/**
+ * @name Module specific functions
+ * @{
+ */
+/*===========================================================================*/
+
+static void _alld_dw1000_callback(void* args);
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name ChibiOS/HAL configuration
+ * @{
+ */
+/*===========================================================================*/
+#include <hal.h>
+
+/**
+ * @brief   CAN driver to use.
+ */
+#define MODULE_HAL_CAN                          CAND1
+
+/**
+ * @brief   Configuration for the CAN driver.
+ */
+extern CANConfig moduleHalCanConfig;
+
+/**
+ * @brief   I2C driver to access the EEPROM.
+ */
+#define MODULE_HAL_I2C_EEPROM                   I2CD2
+
+/**
+ * @brief   Configuration for the EEPROM I2C driver.
+ */
+extern I2CConfig moduleHalI2cEepromConfig;
+
+/**
+ * @brief   Serial driver of the programmer interface.
+ */
+#define MODULE_HAL_PROGIF                       SD1
+
+/**
+ * @brief   Configuration for the programmer serial interface driver.
+ */
+extern SerialConfig moduleHalProgIfConfig;
+
+/**
+ * @brief   SPI interface driver for the motion sensors (gyroscope and accelerometer).
+ */
+#define MODULE_HAL_SPI_LIGHT                    SPID1
+
+/**
+ * @brief   SPI interface driver for UWB Module.
+ */
+#define MODULE_HAL_SPI_UWB                      SPID2
+
+/**
+ * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
+ */
+extern SPIConfig moduleHalSpiLightConfig;
+
+/**
+ * @brief   Configuration for the SPI interface driver to communicate with the LED driver.
+ */
+extern SPIConfig moduleHalSpiUWBConfig;
+
+/**
+ * @brief   Real-Time Clock driver.
+ */
+#define MODULE_HAL_RTC                          RTCD1
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name GPIO definitions
+ * @{
+ */
+/*===========================================================================*/
+#include <amiro-lld.h>
+
+/**
+ * @brief   LIGHT_BANK output signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioLightBlank;
+
+/**
+ * @brief   LASER_EN output signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioLaserEn;
+
+/**
+ * @brief   LASER_OC input signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioLaserOc;
+
+/**
+ * @brief   SYS_UART_DN bidirectional signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioSysUartDn;
+
+/**
+ * @brief   WL_GDO2 input signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioWlGdo2;
+
+/**
+ * @brief   WL_GDO0 input signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioWlGdo0;
+
+/**
+ * @brief   LIGHT_XLAT output signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioLightXlat;
+
+/**
+ * @brief   SYS_PD bidirectional signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioSysPd;
+
+/**
+ * @brief   SYS_SYNC bidirectional signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioSysSync;
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name AMiRo-OS core configurations
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief   Event flag to be set on a LASER_OC interrupt.
+ */
+#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 << GPIOB_SYS_UART_DN)
+
+/**
+ * @brief   Event flag to be set on a WL_GDO2 interrupt.
+ */
+#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 << GPIOB_WL_GDO0)
+
+/**
+ * @brief   Event flag to be set on a SYS_PD interrupt.
+ */
+#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 << GPIOD_SYS_INT_N)
+
+#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
+/**
+ * @brief   Shell prompt text.
+ */
+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, _alld_dw1000_callback, &moduleGpioWlGdo2.gpio->pad);  \
+  palEnablePadEvent(moduleGpioWlGdo2.gpio->port, moduleGpioWlGdo2.gpio->pad, APAL2CH_EDGE(moduleGpioWlGdo2.meta.edge));   \
+  /* WL_GDO0 */                                                               \
+  palSetPadCallback(moduleGpioWlGdo0.gpio->port, moduleGpioWlGdo0.gpio->pad, _alld_dw1000_callback, &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() {                                                 \
+  /* add unit-test shell commands */                                          \
+  aosShellAddCommand(&aos.shell, &moduleUtAlldAt24c01bn.shellcmd);            \
+  aosShellAddCommand(&aos.shell, &moduleUtAlldTlc5947.shellcmd);              \
+  aosShellAddCommand(&aos.shell, &moduleUtAlldTps2051bdbv.shellcmd);          \
+  aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd);                \
+}
+
+/**
+ * @brief   Periphery communication interfaces initialization hook.
+ */
+#define MODULE_INIT_PERIPHERY_COMM() {                                        \
+  /* serial driver */                                                         \
+  sdStart(&MODULE_HAL_PROGIF, &moduleHalProgIfConfig);                        \
+  /* I2C */                                                                   \
+  moduleHalI2cEepromConfig.clock_speed = (AT24C01BN_LLD_I2C_MAXFREQUENCY < moduleHalI2cEepromConfig.clock_speed) ? AT24C01BN_LLD_I2C_MAXFREQUENCY : moduleHalI2cEepromConfig.clock_speed; \
+  moduleHalI2cEepromConfig.duty_cycle = (moduleHalI2cEepromConfig.clock_speed <= 100000) ? STD_DUTY_CYCLE : FAST_DUTY_CYCLE_2;  \
+  i2cStart(&MODULE_HAL_I2C_EEPROM, &moduleHalI2cEepromConfig);                \
+  /* SPI */                                                                   \
+  spiStart(&MODULE_HAL_SPI_LIGHT, &moduleHalSpiLightConfig);                  \
+  spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUWBConfig);                      \
+}
+
+/**
+ * @brief   Periphery communication interface deinitialization hook.
+ */
+#define MODULE_SHUTDOWN_PERIPHERY_COMM() {                                    \
+  /* SPI */                                                                   \
+  spiStop(&MODULE_HAL_SPI_LIGHT);                                             \
+  spiStop(&MODULE_HAL_SPI_UWB);                                               \
+  /* I2C */                                                                   \
+  i2cStop(&MODULE_HAL_I2C_EEPROM);                                            \
+  /* don't stop the serial driver so messages can still be printed */         \
+}
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Startup Shutdown Synchronization Protocol (SSSP)
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief   PD signal GPIO.
+ */
+#define moduleSsspGpioPd                        moduleGpioSysPd
+
+/**
+ * @brief   SYNC signal GPIO.
+ */
+#define moduleSsspGpioSync                      moduleGpioSysSync
+
+/**
+ * @brief   DN signal GPIO.
+ */
+#define moduleSsspGpioDn                        moduleGpioSysUartDn
+
+/**
+ * @brief   Event flags for PD signal events.
+ */
+#define MODULE_SSSP_EVENTFLAGS_PD               MODULE_OS_IOEVENTFLAGS_SYSPD
+
+/**
+ * @brief   Event flags for SYNC signal events.
+ */
+#define MODULE_SSSP_EVENTFLAGS_SYNC             MODULE_OS_IOEVENTFLAGS_SYSSYNC
+
+/**
+ * @brief   Event flags for DN signal events.
+ */
+#define MODULE_SSSP_EVENTFLAGS_DN               MODULE_OS_IOEVENTFLAGS_SYSUARTDN
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Low-level drivers
+ * @{
+ */
+/*===========================================================================*/
+#include <alld_at24c01bn-sh-b.h>
+#include <alld_tlc5947.h>
+#include <alld_tps2051bdbv.h>
+#include <alld_dw1000.h>
+
+/**
+ * @brief   EEPROM driver.
+ */
+extern AT24C01BNDriver moduleLldEeprom;
+
+/**
+ * @brief   LED PWM driver.
+ */
+extern TLC5947Driver moduleLldLedPwm;
+
+/**
+ * @brief   Power switch driver for the laser supply power.
+ */
+extern TPS2051BDriver moduleLldPowerSwitchLaser;
+
+/**
+ * @brief   DW1000 driver for UWB.
+ */
+extern DW1000Driver moduleLldDW1000;
+
+
+
+
+/*! ------------------------------------------------------------------------------------------------------------------
+ * Function: _alld_dw1000_callback()
+ *
+ * Low level abstract function to handle 'reset' adn 'irq' interrupt from DW1000
+ * Expects arg to be of iopadid_t* type, used to distinguish between irq or reset signal
+ */
+static void _alld_dw1000_callback(void* args) {
+
+    aosDbgCheck(true);
+
+
+    chSysLockFromISR();
+    if ((*(iopadid_t*) args) == moduleLldDW1000.gpio_reset->pad)
+    {
+        // dw1000 external indicate reset done
+    }
+    else if ((*(iopadid_t*) args) == moduleLldDW1000.gpio_exti->pad)
+    {
+        dwt_isr();
+    }
+    else
+    {
+        return;
+    }
+    chSysUnlockFromISR();
+
+}
+
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Unit tests (UT)
+ * @{
+ */
+/*===========================================================================*/
+#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
+#include <ut_alld_at24c01bn-sh-b.h>
+#include <ut_alld_tlc5947.h>
+#include <ut_alld_tps2051bdbv.h>
+#include <ut_alld_dw1000.h>
+
+/**
+ * @brief   EEPROM unit test object.
+ */
+extern aos_unittest_t moduleUtAlldAt24c01bn;
+
+/**
+ * @brief   LED PWM driver unit test object.
+ */
+extern aos_unittest_t moduleUtAlldTlc5947;
+
+/**
+ * @brief   Current-limited power switch (Laser output)
+ */
+extern aos_unittest_t moduleUtAlldTps2051bdbv;
+
+/**
+ * @brief   DW1000 unit test object.
+ */
+extern aos_unittest_t moduleUtAlldDw1000;
+
+
+#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
+
+/** @} */
+
+#endif /* _AMIROOS_MODULE_H_ */
diff --git a/os/unittests/periphery-lld/src/ut_alld_dw1000.c b/os/unittests/periphery-lld/src/ut_alld_dw1000.c
new file mode 100755
index 0000000..f17071b
--- /dev/null
+++ b/os/unittests/periphery-lld/src/ut_alld_dw1000.c
@@ -0,0 +1,142 @@
+/*
+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 <ut_alld_dw1000.h>
+
+#if ((AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_DW1000)) || defined(__DOXYGEN__)
+
+#include <aos_debug.h>
+#include <chprintf.h>
+#include <aos_thread.h>
+// No unit testing! -> Contains the Deca Demo Application
+#include <deca_instance.h>
+#include <alld_dw1000.h>
+#include <alld_dw1000_regs.h>
+#include <math.h>
+
+
+aos_utresult_t utAlldDw1000Func(BaseSequentialStream* stream, aos_unittest_t* ut) {
+
+    aosDbgCheck(ut->data != NULL);
+
+    aos_utresult_t result = {0, 0};
+
+    chprintf(stream, "init DW1000...\n");
+    dwt_initialise(DWT_LOADUCODE, (DW1000Driver*) ut->data);
+    chprintf(stream, "device ID should be: 0xDECA0130\nget device ID...\n");
+    uint32_t actual_deviceId = dwt_readdevid();
+    chprintf(stream, "actual device ID is: 0x%x\n", actual_deviceId);
+    aosThdMSleep(1);
+
+    if (actual_deviceId == DWT_DEVICE_ID){
+      aosUtPassed(stream, &result);
+    } else {
+      aosUtFailed(stream, &result);
+    }
+
+    /*chprintf(stream, "write-read test...\n");
+    uint32_t testvalue = 0x0A;
+    uint16_t panid = 0x00;
+
+    dwt_readfromdevice(PANADR_ID, PANADR_PAN_ID_OFFSET, 2, (uint8_t*) &panid);
+    chprintf(stream, "value PANADR register before write: %x\n", panid);
+    chprintf(stream, "write 0x%x to PANADR register...\n", testvalue);
+    dwt_setpanid(testvalue);
+    dwt_readfromdevice(PANADR_ID, PANADR_PAN_ID_OFFSET, 2, (uint8_t*) &panid);
+
+    chprintf(stream, "PANADR register is now: 0x%x\n", panid);
+
+    if (panid == testvalue){
+      aosUtPassed(stream, &result);
+    } else {
+      aosUtFailed(stream, &result);
+    }
+*/
+
+    dwt_setleds(0x03);
+
+    // RUN DECA-DEMO
+
+    instanceConfig_t chConfig;
+    chConfig.channelNumber = 2;            // channel
+    chConfig.preambleCode = 4;             // preambleCode
+    chConfig.pulseRepFreq = DWT_PRF_16M;   // prf
+    chConfig.dataRate = DWT_BR_6M8;        // datarate
+    chConfig.preambleLen = DWT_PLEN_128;   // preambleLength
+    chConfig.pacSize = DWT_PAC8;           // pacSize
+    chConfig.nsSFD = 0;                    // non-standard SFD
+    chConfig.sfdTO = (129 + 8 - 8);        // SFD timeout
+
+    sfConfig_t sfConfig;
+    sfConfig.slotDuration_ms = (10);        //slot duration in milliseconds (NOTE: the ranging exchange must be able to complete in this time
+                                            //e.g. tag sends a poll, 4 anchors send responses and tag sends the final + processing time
+    sfConfig.numSlots = (10);               //number of slots in the superframe (8 tag slots and 2 used for anchor to anchor ranging),
+    sfConfig.sfPeriod_ms = (10*10);         //in ms => 100 ms frame means 10 Hz location rate
+    sfConfig.tagPeriod_ms = (10*10);        //tag period in ms (sleep time + ranging time)
+    sfConfig.pollTxToFinalTxDly_us = (2500); //poll to final delay in microseconds (needs to be adjusted according to lengths of ranging frames)
+
+    //TODO Disable EXTI IRQ
+    //port_DisableEXT_IRQ();
+
+    // inittestapplication
+    // dwt_softreset(); // already done in instance_init()
+
+    // Set this instance mode (tag/anchor)
+    (void) instance_init(TAG, (DW1000Driver*) ut->data);
+    //int err = instance_init(TAG, (DW1000Driver*) ut->data);
+    (void) instance_readdeviceid();
+    //uint32_t deca_dev_id = instance_readdeviceid();
+
+    // TAG ID 0
+    instance_set_16bit_address(0);
+    // simulate DECA config Mode 2 (DIP 1100000)
+    instance_config(&chConfig, &sfConfig) ;
+
+    //TODO Enable EXTI IRQ
+    //port_EnableEXT_IRQ();
+
+    // Start Ranging
+
+    chprintf(stream, "start ranging...\n");
+
+
+    while(1) {
+        //int n = 0;
+        instance_data_t* inst = instance_get_local_structure_ptr(0);
+
+        int monitor_local = inst->monitor ;
+        int txdiff = (chVTGetSystemTimeX() - inst->timeofTx);
+
+        tag_run();
+        //if delayed TX scheduled but did not happen after expected time then it has failed... (has to be < slot period)
+        //if anchor just go into RX and wait for next message from tags/anchors
+        //if tag handle as a timeout
+        if( (monitor_local == 1) && ( txdiff > inst->slotDuration_ms) )  {
+            inst->wait4ack = 0;
+            tag_process_rx_timeout(inst);
+            inst->monitor = 0;
+        }
+    }
+
+    (void) instance_newrange();
+    //int rx = instance_newrange();
+
+    return result;
+}
+
+#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) && defined(AMIROLLD_CFG_USE_DW1000) */
diff --git a/os/unittests/unittests.mk b/os/unittests/unittests.mk
index f113c6b..332aa91 100644
--- a/os/unittests/unittests.mk
+++ b/os/unittests/unittests.mk
@@ -50,5 +50,6 @@ UNITTESTSCSRC = $(UNITTESTS_DIR)lld/src/ut_lld_adc.c \
                 $(UNITTESTS_DIR)periphery-lld/src/ut_alld_tps2051bdbv.c \
                 $(UNITTESTS_DIR)periphery-lld/src/ut_alld_tps62113.c \
                 $(UNITTESTS_DIR)periphery-lld/src/ut_alld_tps62113_ina219.c \
-                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_vcnl4020.c
+                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_vcnl4020.c \
+                $(UNITTESTS_DIR)periphery-lld/src/ut_alld_dw1000.c
 
diff --git a/periphery-lld/AMiRo-LLD b/periphery-lld/AMiRo-LLD
index a425176..cf1f756 160000
--- a/periphery-lld/AMiRo-LLD
+++ b/periphery-lld/AMiRo-LLD
@@ -1 +1 @@
-Subproject commit a4251761c52d6fe349a7e616adf5b4c4b42dfe93
+Subproject commit cf1f756b0cb3a504a95343b00c436d93b82ef1a2
