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.c b/modules/LightRing_1-2/module.c
index f0f3dbc..6e57e55 100644
--- a/modules/LightRing_1-2/module.c
+++ b/modules/LightRing_1-2/module.c
@@ -69,6 +69,29 @@ SPIConfig moduleHalSpiLightConfig = {
   /* CR2                         */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
 };
 
+#if defined(AMIROLLD_CFG_DW1000)
+
+/*! SPI (high speed) configuration for DW1000 */
+SPIConfig moduleHalSpiUwbHsConfig = {
+  /* circular buffer mode        */ false,
+  /* callback function pointer   */ NULL,
+  /* chip select line port       */ PAL_PORT(LINE_SPI_SS_N),
+  /* chip select line pad number */ PAL_PAD(LINE_SPI_SS_N),
+  /* CR1                         */ 0,                                  // 36/2 Mbps
+  /* CR2                         */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,  // 0
+};
+/*! SPI (low speed) configuration for DW1000 */
+SPIConfig moduleHalSpiUwbLsConfig = {
+  /* circular buffer mode        */ false,
+  /* callback function pointer   */ NULL,
+  /* chip select line port       */ PAL_PORT(LINE_SPI_SS_N),
+  /* chip select line pad number */ PAL_PAD(LINE_SPI_SS_N),
+  /* CR1                         */ SPI_CR1_BR_1 | SPI_CR1_BR_0,        // 36/16 Mbps
+  /* CR2                         */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,  // 0
+};
+
+#endif /* defined(AMIROLLD_CFG_DW1000) */
+
 
 /*===========================================================================*/
 /**
@@ -212,22 +235,68 @@ ROMCONST apalControlGpio_t moduleGpioSysUartDn = {
   },
 };
 
+#if defined (AMIROLLD_CFG_DW1000)
 /**
- * @brief   IO_7 breakout signal GPIO.
+ * @brief   DW1000 interrrupt input signal GPIO.
  */
-static apalGpio_t _gpioBreakoutIo7 = {
+static apalGpio_t _gpioDw1000Irqn = {
+  /* line */  LINE_IO_8,            // (GPIOB, GPIOB_IO_8),
+};
+ROMCONST apalControlGpio_t moduleGpioDw1000Irqn = {
+  /* GPIO */ &_gpioDw1000Irqn,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_RISING,
+  },
+};
+
+/**
+ * @brief   DW1000 reset output signal GPIO.
+ */
+static apalGpio_t _gpioDw1000Reset = {
   /* line */ LINE_IO_7,
 };
-apalControlGpio_t moduleGpioBreakoutIo7 = {
-  /* GPIO */ &_gpioBreakoutIo7,
+ROMCONST apalControlGpio_t moduleGpioDw1000Reset = {
+  /* GPIO */ &_gpioDw1000Reset,
   /* meta */ {
-    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
+    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
     /* active state   */ APAL_GPIO_ACTIVE_LOW,
     /* interrupt edge */ APAL_GPIO_EDGE_NONE,
   },
 };
 
 /**
+ * @brief   IO_2 breakout signal GPIO.
+ */
+static apalGpio_t _gpioDw1000WakeUp = {
+  /* line */ LINE_IO_2,
+};
+ROMCONST apalControlGpio_t moduleGpioDw1000WakeUp = {
+  /* GPIO */ &_gpioDw1000WakeUp,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
+
+/**
+ * @brief   DW1000 SPI chip select output signal GPIO.
+ */
+static apalGpio_t _gpioSpiChipSelect = {
+  /* line */ LINE_SPI_SS_N,
+};
+ROMCONST apalControlGpio_t moduleGpioSpiChipSelect = {
+  /* GPIO */ &_gpioSpiChipSelect,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
+#else
+/**
  * @brief   IO_8 breakout signal GPIO.
  */
 static apalGpio_t _gpioBreakoutIo8 = {
@@ -243,13 +312,13 @@ apalControlGpio_t moduleGpioBreakoutIo8 = {
 };
 
 /**
- * @brief   IO_4 breakout signal GPIO.
+ * @brief   IO_7 breakout signal GPIO.
  */
-static apalGpio_t _gpioBreakoutIo4 = {
-  /* line */ LINE_IO_4,
+static apalGpio_t _gpioBreakoutIo7 = {
+  /* line */ LINE_IO_7,
 };
-apalControlGpio_t moduleGpioBreakoutIo4 = {
-  /* GPIO */ &_gpioBreakoutIo4,
+apalControlGpio_t moduleGpioBreakoutIo7 = {
+  /* GPIO */ &_gpioBreakoutIo7,
   /* meta */ {
     /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
     /* active state   */ APAL_GPIO_ACTIVE_LOW,
@@ -258,28 +327,44 @@ apalControlGpio_t moduleGpioBreakoutIo4 = {
 };
 
 /**
- * @brief   IO_1 breakout signal GPIO.
+ * @brief   IO_2 breakout signal GPIO.
  */
-static apalGpio_t _gpioBreakoutIo1 = {
-  /* line */ LINE_IO_1,
+static apalGpio_t _gpioBreakoutIo2 = {
+  /* line */ LINE_IO_2,
 };
-apalControlGpio_t moduleGpioBreakoutIo1 = {
-  /* GPIO */ &_gpioBreakoutIo1,
+apalControlGpio_t moduleGpioBreakoutIo2 = {
+  /* GPIO */ &_gpioBreakoutIo2,
   /* meta */ {
     /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
     /* active state   */ APAL_GPIO_ACTIVE_LOW,
     /* interrupt edge */ APAL_GPIO_EDGE_NONE,
   },
 };
+#endif  /* defined (AMIROLLD_CFG_DW1000) */
 
 /**
- * @brief   IO_2 breakout signal GPIO.
+ * @brief   IO_4 breakout signal GPIO.
  */
-static apalGpio_t _gpioBreakoutIo2 = {
-  /* line */ LINE_IO_2,
+static apalGpio_t _gpioBreakoutIo4 = {
+  /* line */ LINE_IO_4,
 };
-apalControlGpio_t moduleGpioBreakoutIo2 = {
-  /* GPIO */ &_gpioBreakoutIo2,
+apalControlGpio_t moduleGpioBreakoutIo4 = {
+  /* GPIO */ &_gpioBreakoutIo4,
+  /* meta */ {
+    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
+    /* active state   */ APAL_GPIO_ACTIVE_LOW,
+    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
+  },
+};
+
+/**
+ * @brief   IO_1 breakout signal GPIO.
+ */
+static apalGpio_t _gpioBreakoutIo1 = {
+  /* line */ LINE_IO_1,
+};
+apalControlGpio_t moduleGpioBreakoutIo1 = {
+  /* GPIO */ &_gpioBreakoutIo1,
   /* meta */ {
     /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
     /* active state   */ APAL_GPIO_ACTIVE_LOW,
@@ -450,6 +535,14 @@ TLC5947Driver moduleLldLedPwm = {
   /* XLAT signal GPIO   */ NULL,
 };
 
+#if defined(AMIROLLD_CFG_DW1000)
+DW1000Driver moduleLldDw1000 = {
+  /* SPI driver         */ &MODULE_HAL_SPI_UWB,
+  /* ext interrupt      */ &moduleGpioDw1000Irqn,
+  /* RESET DW1000       */ &moduleGpioDw1000Reset,
+};
+#endif /* defined(AMIROLLD_CFG_DW1000) */
+
 /** @} */
 
 /*===========================================================================*/
@@ -624,6 +717,50 @@ aos_unittest_t moduleUtAlldTlc5947 = {
   /* data           */ &moduleLldLedPwm,
 };
 
+#if defined(AMIROLLD_CFG_DW1000)
+/*
+ * UwB Driver (DW1000)
+ */
+static int _utShellCmdCb_Dw1000(BaseSequentialStream* stream, int argc, char* argv[])
+{
+  (void)argc;
+  (void)argv;
+
+  // Set the 3.3 V supply for powering the DW1000 module
+  ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = &moduleLldPowerSwitchV33;
+  ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->dw1000d = NULL;
+  aosUtRun(stream, &moduleUtAlldDw1000, NULL);
+  ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = NULL;
+
+  // Set the 1.8 V supply
+  ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = &moduleLldPowerSwitchV18;
+  ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->dw1000d = NULL;
+   aosUtRun(stream, &moduleUtAlldDw1000, NULL);
+  ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = NULL;
+
+  // Run the DW1000 module
+  ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->dw1000d = &moduleLldDw1000;
+  ((ut_dw1000data_t*)moduleUtAlldDw1000.data)->mic9404xd = NULL;
+  aosUtRun(stream, &moduleUtAlldDw1000, NULL);
+  return AOS_OK;
+}
+static ut_dw1000data_t _utAlldDw1000Data = {
+  /* driver DW1000    */ NULL,
+  /* driver MIC9404x  */ NULL,
+};
+aos_unittest_t moduleUtAlldDw1000 = {
+  /* info           */ "DW1000",
+  /* name           */ "UWB System",
+  /* test function  */ utAlldDw1000Func,
+  /* shell command  */ {
+    /* name     */ "unittest:Uwb",
+    /* callback */ _utShellCmdCb_Dw1000,
+    /* next     */ NULL,
+  },
+  /* data           */ &_utAlldDw1000Data,
+};
+#endif /* defined(AMIROLLD_CFG_DW1000) */
+
 #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
 
 /** @} */
