commit 884499878182d0763bfd441d1c447cd8af1e4d8a
Author: Cung Sang <csang@techfak.uni-bielefeld.de>
Date:   Mon Apr 1 18:17:22 2019 +0200

    introduced UWB apps and UT on Light Ring breakout

diff --git a/modules/LightRing_1-2/module.h b/modules/LightRing_1-2/module.h
index f239269..add9006 100644
--- a/modules/LightRing_1-2/module.h
+++ b/modules/LightRing_1-2/module.h
@@ -85,11 +85,31 @@ extern SerialConfig moduleHalProgIfConfig;
  */
 extern SPIConfig moduleHalSpiLightConfig;
 
+#if defined(AMIROLLD_CFG_DW1000)
+/**
+ * @brief   SPI interface driver for UWB DW1000 module.
+ */
+#define MODULE_HAL_SPI_UWB                      SPID2
+
+/**
+ * @brief   Configuration for the high-speed SPI interface driver of DW1000 module.
+ */
+extern SPIConfig moduleHalSpiUwbHsConfig;
+
+/**
+ * @brief   Configuration for the low-speed SPI interface driver of DW1000 module.
+ */
+extern SPIConfig moduleHalSpiUwbLsConfig;
+
+#else
+
 /**
  * @brief   SPI interface driver for the breakout header.
  */
 #define MODULE_HAL_SPI_BREAKOUT                 SPID2
 
+#endif /* defined(AMIROLLD_CFG_DW1000) */
+
 /**
  * @brief   UART interface driver for the breakout header (alternative to serial).
  */
@@ -155,16 +175,6 @@ extern apalControlGpio_t moduleGpioBreakoutIo6;
 extern ROMCONST apalControlGpio_t moduleGpioSysUartDn;
 
 /**
- * @brief   IO_7 breakout signal GPIO.
- */
-extern apalControlGpio_t moduleGpioBreakoutIo7;
-
-/**
- * @brief   IO_8 breakout signal GPIO.
- */
-extern apalControlGpio_t moduleGpioBreakoutIo8;
-
-/**
  * @brief   IO_4 breakout signal GPIO.
  */
 extern apalControlGpio_t moduleGpioBreakoutIo4;
@@ -175,11 +185,6 @@ extern apalControlGpio_t moduleGpioBreakoutIo4;
 extern apalControlGpio_t moduleGpioBreakoutIo1;
 
 /**
- * @brief   IO_2 breakout signal GPIO.
- */
-extern apalControlGpio_t moduleGpioBreakoutIo2;
-
-/**
  * @brief   LED output signal GPIO.
  */
 extern ROMCONST apalControlGpio_t moduleGpioLed;
@@ -209,6 +214,49 @@ extern ROMCONST apalControlGpio_t moduleGpioSysPd;
  */
 extern ROMCONST apalControlGpio_t moduleGpioSysSync;
 
+#if defined(AMIROLLD_CFG_DW1000)
+
+/**
+ * @brief   DW1000 reset output signal
+ * @note    the reset pin should be drived as low by MCU to activate.
+ *          Then, put back the reset pin as input to MCU (tri-state float on the air
+ *          is not supported in AMiRo)
+ */
+extern ROMCONST apalControlGpio_t moduleGpioDw1000Reset;
+
+/**
+ * @brief   DW1000 wakeup signal
+ */
+extern ROMCONST apalControlGpio_t moduleGpioDw1000WakeUp;
+
+/**
+ * @brief   DW1000 interrupt IRQn input signal.
+ */
+extern ROMCONST apalControlGpio_t moduleGpioDw1000Irqn;
+
+/**
+ * @brief   DW1000 SPI chip select  output signal.
+ */
+extern ROMCONST apalControlGpio_t moduleGpioSpiChipSelect ;
+
+#else
+/**
+ * @brief   IO_2 breakout signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioBreakoutIo2;
+
+/**
+ * @brief   IO_7 breakout signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioBreakoutIo7;
+
+/**
+ * @brief   IO_8 breakout signal GPIO.
+ */
+extern apalControlGpio_t moduleGpioBreakoutIo8;
+
+#endif /* defined(AMIROLLD_CFG_DW1000) */
+
 /** @} */
 
 /*===========================================================================*/
@@ -263,10 +311,17 @@ extern ROMCONST apalControlGpio_t moduleGpioSysSync;
  */
 #define MODULE_OS_IOEVENTFLAGS_BREAKOUTIO7      AOS_IOEVENT_FLAG(PAL_PAD(LINE_IO_7))
 
+#if defined(AMIROLLD_CFG_DW1000)
+/**
+ * @brief   Event flag to be call dwt_isr() interrupt.
+ */
+#define MODULE_OS_IOEVENTFLAGS_DW1000      AOS_IOEVENT_FLAG(PAL_PAD(LINE_IO_8))
+#else
 /**
  * @brief   Event flag to be set on a IO_8 (breakout) interrupt.
  */
 #define MODULE_OS_IOEVENTFLAGS_BREAKOUTIO8      AOS_IOEVENT_FLAG(PAL_PAD(LINE_IO_8))
+#endif  /* defined(AMIROLLD_CFG_DW1000) */
 
 /**
  * @brief   Event flag to be set on a SYS_PD interrupt.
@@ -286,7 +341,17 @@ extern ROMCONST char* moduleShellPrompt;
  */
 #define MODULE_INIT_INTERRUPTS() {                                            \
   /* breakout interrupts must be enabled explicitely */                       \
+  MODULE_INIT_INTERRUPTS_DW1000();                                            \
 }
+#if defined(AMIROLLD_CFG_DW1000)
+  #define MODULE_INIT_INTERRUPTS_DW1000() {                                   \
+    palSetLineCallback(moduleGpioDw1000Irqn.gpio->line, aosSysGetStdIntCallback(), &moduleGpioDw1000Irqn.gpio->line); \
+    palEnableLineEvent(moduleGpioDw1000Irqn.gpio->line, APAL2CH_EDGE(moduleGpioDw1000Irqn.meta.edge));                \
+  }
+#else /* defined(AMIROLLD_CFG_DW1000) */
+  #define MODULE_INIT_INTERRUPTS_DW1000() {                                   \
+  }
+#endif /* defined(AMIROLLD_CFG_DW1000) */
 
 /**
  * @brief   Unit test initialization hook.
@@ -298,7 +363,16 @@ extern ROMCONST char* moduleShellPrompt;
   aosShellAddCommand(&aos.shell, &moduleUtAlldLed.shellcmd);                  \
   aosShellAddCommand(&aos.shell, &moduleUtAlldMic9404x.shellcmd);             \
   aosShellAddCommand(&aos.shell, &moduleUtAlldTlc5947.shellcmd);              \
+  MODULE_INIT_TESTS_DW1000();                                                 \
 }
+#if defined(AMIROLLD_CFG_DW1000)
+  #define MODULE_INIT_TESTS_DW1000() {                                        \
+    aosShellAddCommand(&aos.shell, &moduleUtAlldDw1000.shellcmd);             \
+  }
+#else /* defined(AMIROLLD_CFG_DW1000) */
+  #define MODULE_INIT_TESTS_DW1000() {                                        \
+  }
+#endif /* defined(AMIROLLD_CFG_DW1000) */
 
 /**
  * @brief   Periphery communication interfaces initialization hook.
@@ -313,7 +387,16 @@ extern ROMCONST char* moduleShellPrompt;
   i2cStart(&MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT, &moduleHalI2cEepromPwrmtrBreakoutConfig);  \
   /* SPI */                                                                   \
   spiStart(&MODULE_HAL_SPI_LIGHT, &moduleHalSpiLightConfig);                  \
+  MODULE_INIT_PERIPHERY_COMM_DW1000();                                        \
 }
+#if defined(AMIROLLD_CFG_DW1000)
+  #define MODULE_INIT_PERIPHERY_COMM_DW1000() {                               \
+  spiStart(&MODULE_HAL_SPI_UWB, &moduleHalSpiUwbLsConfig);                    \
+  }
+#else /* defined(AMIROLLD_CFG_DW1000) */
+  #define MODULE_INIT_PERIPHERY_COMM_DW1000() {                               \
+  }
+#endif /* defined(AMIROLLD_CFG_DW1000) */
 
 /**
  * @brief   Periphery communication interface deinitialization hook.
@@ -323,8 +406,35 @@ extern ROMCONST char* moduleShellPrompt;
   spiStop(&MODULE_HAL_SPI_LIGHT);                                             \
   /* I2C */                                                                   \
   i2cStop(&MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT);                            \
+  MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000();                                    \
   /* don't stop the serial driver so messages can still be printed */         \
 }
+#if defined(AMIROLLD_CFG_DW1000)
+#define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() {                             \
+  /* SPI */                                                                   \
+  spiStop(&MODULE_HAL_SPI_UWB);                                               \
+}
+#else /* defined(AMIROLLD_CFG_DW1000) */
+  #define MODULE_SHUTDOWN_PERIPHERY_COMM_DW1000() {                           \
+  }
+#endif /* defined(AMIROLLD_CFG_DW1000) */
+
+/**
+ * @brief   HOOK to call process_deca_irq() func when the dw1000 interrupt pin is activated.
+ */
+#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) {                               \
+  MODULE_MAIN_LOOP_IO_EVENT_DW1000();                                         \
+}
+#if defined(AMIROLLD_CFG_DW1000)
+  #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() {                                \
+    if(eventflags & MODULE_OS_IOEVENTFLAGS_DW1000) {                          \
+      process_deca_irq();                                                     \
+    }                                                                         \
+  }
+#else /* defined(AMIROLLD_CFG_DW1000) */
+  #define MODULE_MAIN_LOOP_IO_EVENT_DW1000() {                                \
+  }
+#endif /* defined(AMIROLLD_CFG_DW1000) */
 
 /** @} */
 
@@ -390,6 +500,13 @@ extern ROMCONST char* moduleShellPrompt;
 //#include <alld_SNx5C3221E.h>
 #include <alld_TLC5947.h>
 
+#if defined(AMIROLLD_CFG_DW1000)
+#include <alld_DW1000.h>
+
+extern DW1000Driver moduleLldDw1000;
+
+#endif /* defined(AMIROLLD_CFG_DW1000) */
+
 /**
  * @brief   EEPROM driver.
  */
@@ -452,6 +569,16 @@ extern TLC5947Driver moduleLldLedPwm;
 //#include <ut_alld_SNx5C3221E_v1.h>
 #include <ut_alld_TLC5947_v1.h>
 
+#if defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1)
+#include <ut_alld_DW1000_v1.h>
+
+/**
+ * @brief   DW1000 unit test object.
+ */
+extern aos_unittest_t moduleUtAlldDw1000;
+
+#endif /* defined(AMIROLLD_CFG_DW1000) && (AMIROLLD_CFG_DW1000 == 1) */
+
 /**
  * @brief   EEPROM unit test object.
  */
